44 numeric_limits<time_t>::min(),
45 numeric_limits<suseconds_t>::min()
97 UuidCreateNil( &(this->theID_) );
99 uuid_clear(this->theID_);
110 if (IsConsecutive()){
116 RPC_STATUS status=RPC_S_OK;
117 result = (TRUE==UuidIsNil(
118 (uuid_t * )(&theID_),
121 BIASASSERT(status==RPC_S_OK);
123 result = (1==uuid_is_null(theID_));
132 char *tmp =
const_cast<char *
>(sID.c_str());
133 unsigned char * cUUIDwin =
reinterpret_cast<unsigned char *
>(tmp);
137 if (UuidFromString(cUUIDwin, &theID_)!=RPC_S_OK) {
138 BIASERR(
"UUID could not be read!");
141 else IsValid_ =
true;
145 if (sID.length()!=36)
146 BIASERR(
"Wrong size of string to construct from: "<<sID);
147 if (uuid_parse(sID.c_str(), theID_)!=0) {
148 BIASERR(
"UUID could not be read!");
151 else IsValid_ =
true;
160 this->IsValid_ =
true;
169 (
void*)(&(theID_.Data4[8-
sizeof(n)])),
175 std::stringstream ss;
177 ss<<
"00000000-0000-0000-0000-";
179 ss<<setfill(
'0')<<setw(12)<<noshowbase<<hex<<n;
180 return SetFromString( ss.str() );
187 if ( !IsConsecutive() ){
189 BIASERR(
"cannot extract non-consecutive uuid into long");
198 (theID_.Data2 !=1) ||
199 (theID_.Data3 !=0) ||
200 (theID_.Data4[0]!=0) ||
204 BIASWARNONCE(
"you are trying to GetLong a consecutive ID "<<endl
206 <<
"with data fields that dont match the reserved consecutive pattern: \"<longID>-0001-0000-0000-*"
207 <<
"This is inconsistent !");
211 # endif // BIAS_DEBUG
216 std::istringstream iss;
221 std::string::size_type pos = s.rfind(
'-');
222 if (pos != string::npos){
224 iss.str( s.substr(pos+1, 12) );
267 return AssignUUID_Consecutive();
269 return AssignUUID_Global();
279 this->SetFromLong(g_uniqueCounter);
283 this->IsValid_ =
true;
295 HRESULT hr = UuidCreate( &theID_);
298 case RPC_S_UUID_LOCAL_ONLY:
299 BIASERR(
"UUID_LOCAL_ONLY guaranteed uniqueness for the generating machine, only!");
303 BIASERR(
"Could not create UUID!");
307 uuid_generate_time(theID_);
309 uuid_time(theID_, &CurTime);
310 if ((CurTime.tv_sec < LastGenerationTime_.tv_sec) ||
311 ((CurTime.tv_sec == LastGenerationTime_.tv_sec) &&
312 (CurTime.tv_usec <= LastGenerationTime_.tv_usec))) {
321 uuid_generate_time(theID_);
324 uuid_generate_time(theID_);
326 uuid_time(theID_, &CurTime);
328 if ((CurTime.tv_sec < LastGenerationTime_.tv_sec) ||
329 ((CurTime.tv_sec == LastGenerationTime_.tv_sec) &&
330 (CurTime.tv_usec <= LastGenerationTime_.tv_usec))) {
339 uuid_generate_time(theID_);
342 uuid_time(theID_, &CurTime);
344 if ((CurTime.tv_sec < LastGenerationTime_.tv_sec) ||
345 ((CurTime.tv_sec == LastGenerationTime_.tv_sec) &&
346 (CurTime.tv_usec <= LastGenerationTime_.tv_usec))) {
356 LastGenerationTime_.tv_sec = CurTime.tv_sec;
357 LastGenerationTime_.tv_usec = CurTime.tv_usec;
361 this->IsValid_ =
true;
368 unsigned char * cUUIDwin;
369 UuidToString (const_cast<uuid_t*>(&theID_), &cUUIDwin);
370 sUUID = (
char *)cUUIDwin;
373 uuid_unparse(theID_, cUUID);
388 BIASERR(
"Not yet implemented!");
395 uuid_generate_time(t->
theID_);
397 timeval CreationTime;
398 thetime = uuid_time(theID_, &CreationTime);
406 BIASERR(
"Not yet implemented!");
410 timeval CreationTime;
411 uuid_time(theID_, &CreationTime);
434 GUID tmpGUID = ((GUID)
id.theID_);
435 if (UuidFromString((
unsigned char*)suid.c_str(), &tmpGUID)!=RPC_S_OK)
437 if (uuid_parse(suid.c_str(),
id.theID_)!=0)
440 BIASERR(
"UUID could not be read from \""<<suid<<
"\"");
442 is.setstate(std::ios_base::failbit | std::ios_base::badbit);
453 #if defined(__x86_64__) || defined(__sparc64__) || \
454 defined(__arch64__) || defined(__powerpc64__) || defined (__s390x__)
459 static const string mc= max_consecutive.
GetString();
460 return (this->GetString()<=mc);
469 return (
unsigned char *)theID_;
477 BIASASSERT(rawid!=NULL);
479 memcpy((
unsigned char *)theID_, rawid, 16);
480 if (IsConsecutive()) {
void GetString(std::string &sUUID) const
writes the UUID into a string object
time_t GetUUIDCreationTime() const
returns the time used to create the uuid (just seconds)
static UUID GenerateUUID_Consecutive()
jw
timeval GetUUIDCreationTimeStruct() const
returns the time used to create the uuid (seconds and usecs)
UUID()
default constructor does NOT create a valid UUID to avoid performance decrease in case someone wants ...
void AssignUUID_Consecutive()
jw
void AssignUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
function to assign a fresh, unique ID.
bool IsConsecutive() const
undefined behaviour if uuid is invalid
static long g_uniqueCounter
global counter to create next unique consecutive program run-unique ID.
bool SetFromString(const std::string &sID)
construct from string containing ascii uuid.
bool SetFromLong(const unsigned long &n)
construct from a unique long.
void clear()
NULLS the class members, invalidates this UID ( not unique anymore).
static timeval LastGenerationTime_
when creating a uuid, current time is compared against the time saved during the last uuid generation...
const unsigned char * GetUUIDRaw() const
get the pointer to the Uc[16] array with the raw uuid
std::string GetString() const
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
unsigned long GetLong() const
get least significant value of UID as long value.
class BIASImageBase_EXPORT UUID
forward declaration for stream operators
interface class for producing/storing Universally Unique IDentifiers
uuid_t theID_
the data fields of the uuid
static UUID GenerateUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
static function which simply produces a uuid and returns
void AssignUUID_Global()
jw
BIASCommon_EXPORT std::istream & operator>>(std::istream &is, BIAS::TimeStamp &ts)
Standard input operator for TimeStamps.
void SetUUIDRaw(const unsigned char *rawid)
static UUID GenerateUUID_Global()
jw