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 ()
 
OksStringget ()
 
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 410 of file kernel.hpp.

Constructor & Destructor Documentation

◆ OksNameTable()

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

Definition at line 412 of file kernel.hpp.

Member Function Documentation

◆ get()

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

Definition at line 621 of file kernel.cpp.

622{
623 static const size_t slen(sizeof(symbols)-1);
624 static const size_t slen2(slen*slen);
625
626 char b[16], *buf = b;
627
628 count++;
629
630 *buf++ = symbols[count%slen];
631
632 if((size_t)count >= slen) {
633 *buf++ = symbols[(count/slen)%slen];
634
635 if((size_t)count >= slen2) {
636 *buf++ = symbols[(count/slen2)%slen];
637 }
638 }
639
640 *buf = '\0';
641
642 return new OksString(b);
643}
static const char symbols[]
Definition kernel.hpp:420

◆ reset()

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

Definition at line 415 of file kernel.hpp.

415{count = -1;}

Member Data Documentation

◆ count

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

Definition at line 421 of file kernel.hpp.

◆ symbols

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

Definition at line 420 of file kernel.hpp.


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