DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::OksNameTable Struct Reference

The struct OksNameTable is used to generate unique strings. More...

#include <kernel.hpp>

Public Member Functions

 OksNameTable ()
OksString * get ()
void reset ()

Private Attributes

long count

Static Private Attributes

static const char symbols []

Detailed Description

The struct OksNameTable is used to generate unique strings.

The generated string contains ASCII characters (allowed characters defined by string 'symbols')

Each generated string is short as possible

Calls of get will give the following sequency: "0", "1", ..., "9", "a", "b", ..., "z", "A", ..., "?", "00", "01", ..., "09", "0a", "0b", ..., "0Z", "0A", ..., "0?", "10", "11", ..., "19", "1a", ... etc.

Definition at line 443 of file kernel.hpp.

Constructor & Destructor Documentation

◆ OksNameTable()

dunedaq::oks::OksNameTable::OksNameTable ( )
inline

Definition at line 446 of file kernel.hpp.

446{ reset(); }

Member Function Documentation

◆ get()

OksString * dunedaq::oks::OksNameTable::get ( )

Definition at line 570 of file kernel.cpp.

571{
572 static const size_t slen(sizeof(symbols) - 1);
573 static const size_t slen2(slen * slen);
574
575 char b[16], *buf = b;
576
577 count++;
578
579 *buf++ = symbols[count % slen];
580
581 if ((size_t)count >= slen) {
582 *buf++ = symbols[(count / slen) % slen];
583
584 if ((size_t)count >= slen2) {
585 *buf++ = symbols[(count / slen2) % slen];
586 }
587 }
588
589 *buf = '\0';
590
591 return new OksString(b);
592}
OksString()
to deallocate memory when destroyed
Definition object.hpp:421
static const char symbols[]
Definition kernel.hpp:452

◆ reset()

void dunedaq::oks::OksNameTable::reset ( )
inline

Definition at line 449 of file kernel.hpp.

449{ count = -1; }

Member Data Documentation

◆ count

long dunedaq::oks::OksNameTable::count
private

Definition at line 453 of file kernel.hpp.

◆ symbols

const char dunedaq::oks::OksNameTable::symbols
staticprivate
Initial value:
= "0123456789"
"abcdefghijklmnoprstuvwxyz"
"ABCDEFGHIJKLMNOPRSTUVWXYZ"

Definition at line 452 of file kernel.hpp.


The documentation for this struct was generated from the following files: