Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | Related Functions | List of all members
BIAS::UUID Class Reference

interface class for producing/storing Universally Unique IDentifiers More...

#include <Base/Image/UUID.hh>

+ Inheritance diagram for BIAS::UUID:
+ Collaboration diagram for BIAS::UUID:

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
void AssignUUID (const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
 function to assign a fresh, unique ID. More...
 
void AssignUUID_Consecutive ()
 jw More...
 
void AssignUUID_Global ()
 jw More...
 
void clear ()
 NULLS the class members, invalidates this UID ( not unique anymore). More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
unsigned long GetLong () const
 get least significant value of UID as long value. More...
 
void GetString (std::string &sUUID) const
 writes the UUID into a string object More...
 
std::string GetString () const
 
time_t GetUUIDCreationTime () const
 returns the time used to create the uuid (just seconds) More...
 
timeval GetUUIDCreationTimeStruct () const
 returns the time used to create the uuid (seconds and usecs) More...
 
const unsigned char * GetUUIDRaw () const
 get the pointer to the Uc[16] array with the raw uuid More...
 
void Invalidate ()
 sets the valid flag to false and clears data JW 09/2005: added clear in addition to just setting bool flag invalid. More...
 
bool IsConsecutive () const
 undefined behaviour if uuid is invalid More...
 
bool IsNil () const
 
bool IsValid () const
 checks whether this uuid is valid(true) or unitialized(false) More...
 
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found More...
 
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel More...
 
bool operator!= (const UUID &id) const
 "not equal"-operator, uses result of operator== More...
 
bool operator< (const UUID &id) const
 the operator< does not express temporal ordering, it does only compare the data areas of the two ids, e.g. More...
 
bool operator<= (const UUID &id) const
 operator<= does not express temporal ordering, it does only compare the data areas of the two ids !!! More...
 
UUIDoperator= (const UUID &id)
 standard assignment operator More...
 
bool operator== (const UUID &id) const
 comparison operator only compares ids, no check of validities More...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
bool SetFromLong (const unsigned long &n)
 construct from a unique long. More...
 
bool SetFromString (const std::string &sID)
 construct from string containing ascii uuid. More...
 
void SetUUIDRaw (const unsigned char *rawid)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
 UUID ()
 default constructor does NOT create a valid UUID to avoid performance decrease in case someone wants to create many UIDS that are not really used. More...
 
 UUID (const uuid_t &id)
 use this if you want to create a UUID "manually" More...
 
 UUID (const BIAS::UUID &id)
 copy constructor, calls operator= internally. More...
 
 UUID (const std::string &sID)
 construct from string containing ascii uuid More...
 
 UUID (const unsigned long &n)
 construct from string containing a unique long. More...
 
virtual ~UUID ()
 

Static Public Member Functions

static UUID GenerateUUID (const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
 static function which simply produces a uuid and returns More...
 
static UUID GenerateUUID_Consecutive ()
 jw More...
 
static UUID GenerateUUID_Global ()
 jw More...
 
static long int GetGlobalDebugLevel ()
 
static void SetGlobalDebugLevel (long int lev)
 

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 

Protected Attributes

long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
std::map< std::string, long int > _String2Debuglevel
 
bool IsValid_
 flag indicating whether this uuid has been assigned a value yet More...
 
uuid_t theID_
 the data fields of the uuid More...
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long g_uniqueCounter = 0
 global counter to create next unique consecutive program run-unique ID. More...
 
static long int GlobalDebugLevel = 0
 
static timeval LastGenerationTime_
 when creating a uuid, current time is compared against the time saved during the last uuid generation More...
 

Friends

BIASImageBase_EXPORT std::ostream & operator<< (std::ostream &os, const UUID &id)
 
BIASImageBase_EXPORT std::istream & operator>> (std::istream &is, UUID &id)
 

Related Functions

(Note that these are not member functions.)

BIASImageBase_EXPORT std::ostream & operator<< (std::ostream &os, const UUID &id)
 write a UUID to a stream More...
 
BIASImageBase_EXPORT std::istream & operator>> (std::istream &is, UUID &id)
 reads a UUID from a stream More...
 

Detailed Description

interface class for producing/storing Universally Unique IDentifiers

Test:
MyTestFile.cpp

A UUID is a u unique structure. It is usually a 128 bit value computed from the MAC address of the network adapter (which means "spatial uniqueness") and a high resolution timestamp providing "temporal uniqueness". In addition you

  @attention temporal uniqueness is only obtained if time is monotonic,
  i.e. you MUST NOT turn back the clock (-> NTP ?)

  For information: generating 1.000.000 UIDS on WIN32 takes approx. 
  180 msec. (jw)
Todo:
The UUID representation is not platform independant, in particular generating a consecutive ID on Windows and reading it on Linux will not work! (JW)
  @author koeser 09/2003, W32: Jan Woetzel 08/2005  
Examples:
ExampleCamera.cpp, ExampleEmpty.cpp, ExampleUUID.cpp, and ExampleV4L.cpp.

Definition at line 98 of file UUID.hh.

Constructor & Destructor Documentation

BIAS::UUID::~UUID ( )
virtual

Definition at line 52 of file UUID.cpp.

BIAS::UUID::UUID ( )

default constructor does NOT create a valid UUID to avoid performance decrease in case someone wants to create many UIDS that are not really used.

(Jan Woetzel 08/2005)

Definition at line 56 of file UUID.cpp.

BIAS::UUID::UUID ( const uuid_t &  id)
explicit

use this if you want to create a UUID "manually"

Definition at line 69 of file UUID.cpp.

BIAS::UUID::UUID ( const BIAS::UUID id)

copy constructor, calls operator= internally.

Definition at line 63 of file UUID.cpp.

BIAS::UUID::UUID ( const std::string &  sID)
explicit

construct from string containing ascii uuid

Definition at line 81 of file UUID.cpp.

BIAS::UUID::UUID ( const unsigned long &  n)
explicit

construct from string containing a unique long.

User has to assert uniqueness himself, e.g. by a global counter.

Author
Jan Woetzel 2005

Definition at line 86 of file UUID.cpp.

Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

void BIAS::UUID::AssignUUID ( const bool &  consecutively = DEFAULT_UUID_CONSECUTIVELY)

function to assign a fresh, unique ID.

Parameters
consecutively,:true to use a sequential, dense counter instead of 16 Byte MAC like UID. The ID will be unique for each program run. Please mind the differnec to a sequential (local unique only) UUID w hich is unique for the machine, not only the run. False to generate universally valid one.
Author
Jan Woetzel 08/2005
Examples:
ExampleV4L.cpp.

Definition at line 264 of file UUID.cpp.

Referenced by GenerateUUID().

void BIAS::UUID::AssignUUID_Consecutive ( )

jw

Definition at line 277 of file UUID.cpp.

Referenced by GenerateUUID_Consecutive().

void BIAS::UUID::AssignUUID_Global ( )

jw

Definition at line 289 of file UUID.cpp.

Referenced by GenerateUUID_Global().

void BIAS::UUID::clear ( )

NULLS the class members, invalidates this UID ( not unique anymore).

Jan Woetzel 08/2005

Definition at line 93 of file UUID.cpp.

Referenced by BIAS::operator<<().

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

BIAS::UUID BIAS::UUID::GenerateUUID ( const bool &  consecutively = DEFAULT_UUID_CONSECUTIVELY)
static
BIAS::UUID BIAS::UUID::GenerateUUID_Consecutive ( )
static

jw

Definition at line 245 of file UUID.cpp.

References AssignUUID_Consecutive().

BIAS::UUID BIAS::UUID::GenerateUUID_Global ( )
static

jw

Definition at line 254 of file UUID.cpp.

References AssignUUID_Global().

int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

unsigned long BIAS::UUID::GetLong ( ) const

get least significant value of UID as long value.

Useful in conjunction with SetFromLong if you want to use unique counters instead of real UIDs. !!Must not be called for non-consecutive uuids!!

Returns
least significant UID value
Author
Jan Woetzel 2005

Definition at line 185 of file UUID.cpp.

void BIAS::UUID::GetString ( std::string &  sUUID) const

writes the UUID into a string object

Definition at line 366 of file UUID.cpp.

Referenced by IsConsecutive(), BIAS::operator<<(), BIAS::ImageIO::Save(), and BIAS::VideoSource::WriteDirect_().

std::string BIAS::UUID::GetString ( ) const

Definition at line 379 of file UUID.cpp.

time_t BIAS::UUID::GetUUIDCreationTime ( ) const

returns the time used to create the uuid (just seconds)

Definition at line 386 of file UUID.cpp.

References theID_.

timeval BIAS::UUID::GetUUIDCreationTimeStruct ( ) const

returns the time used to create the uuid (seconds and usecs)

Definition at line 404 of file UUID.cpp.

const unsigned char * BIAS::UUID::GetUUIDRaw ( ) const

get the pointer to the Uc[16] array with the raw uuid

Definition at line 464 of file UUID.cpp.

void BIAS::UUID::Invalidate ( )
inline

sets the valid flag to false and clears data JW 09/2005: added clear in addition to just setting bool flag invalid.

Definition at line 215 of file UUID.hh.

bool BIAS::UUID::IsConsecutive ( ) const

undefined behaviour if uuid is invalid

Definition at line 450 of file UUID.cpp.

References GetString(), and BIAS::UUID.

bool BIAS::UUID::IsNil ( ) const
Examples:
ExampleImageLoad.cpp.

Definition at line 108 of file UUID.cpp.

bool BIAS::UUID::IsValid ( ) const
inline
long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
bool BIAS::UUID::operator!= ( const UUID id) const
inline

"not equal"-operator, uses result of operator==

Definition at line 191 of file UUID.hh.

bool BIAS::UUID::operator< ( const UUID id) const
inline

the operator< does not express temporal ordering, it does only compare the data areas of the two ids, e.g.

for sorting, map-storage

Definition at line 288 of file UUID.hh.

bool BIAS::UUID::operator<= ( const UUID id) const
inline

operator<= does not express temporal ordering, it does only compare the data areas of the two ids !!!

Definition at line 299 of file UUID.hh.

UUID & BIAS::UUID::operator= ( const UUID id)
inline

standard assignment operator

Definition at line 310 of file UUID.hh.

bool BIAS::UUID::operator== ( const UUID id) const
inline

comparison operator only compares ids, no check of validities

Definition at line 271 of file UUID.hh.

void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

bool BIAS::UUID::SetFromLong ( const unsigned long &  n)

construct from a unique long.

User has to assert uniqueness himslef, e.g. by a global counter.

Returns
true if succesful
Author
Jan Woetzel 2005

Definition at line 158 of file UUID.cpp.

bool BIAS::UUID::SetFromString ( const std::string &  sID)

construct from string containing ascii uuid.

Thsiu routine is slow! (1.000.000 times take approx 16 seconds, JW)

Returns
true if succesful

Definition at line 130 of file UUID.cpp.

Referenced by BIAS::operator>>(), and BIAS::VideoStream::SplitIntoFiles().

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

void BIAS::UUID::SetUUIDRaw ( const unsigned char *  rawid)

Definition at line 474 of file UUID.cpp.

void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

Friends And Related Function Documentation

BIASImageBase_EXPORT std::ostream & operator<< ( std::ostream &  os,
const UUID id 
)
related

write a UUID to a stream

BIASImageBase_EXPORT std::ostream& operator<< ( std::ostream &  os,
const UUID id 
)
friend
BIASImageBase_EXPORT std::istream & operator>> ( std::istream &  is,
UUID id 
)
related

reads a UUID from a stream

BIASImageBase_EXPORT std::istream& operator>> ( std::istream &  is,
UUID id 
)
friend

Member Data Documentation

long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

long BIAS::UUID::g_uniqueCounter = 0
staticprotected

global counter to create next unique consecutive program run-unique ID.

Definition at line 246 of file UUID.hh.

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.

bool BIAS::UUID::IsValid_
protected

flag indicating whether this uuid has been assigned a value yet

Definition at line 236 of file UUID.hh.

timeval BIAS::UUID::LastGenerationTime_
staticprotected
Initial value:
= {
numeric_limits<time_t>::min(),
numeric_limits<suseconds_t>::min()
}

when creating a uuid, current time is compared against the time saved during the last uuid generation

Hint: If you have WIN32 compilation problems look for WIN32_LEAN_AND_MEAN and windows.h (JW)

Definition at line 243 of file UUID.hh.

uuid_t BIAS::UUID::theID_
protected

the data fields of the uuid

Definition at line 233 of file UUID.hh.

Referenced by GetUUIDCreationTime().


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