#include <UUID.h>
Collaboration diagram for ACE_Utils::UUID_Generator:

Public Types | |
| typedef ACE_UINT64 | UUID_time |
| enum | { ACE_UUID_CLOCK_SEQ_MASK = 0x3FFF } |
Public Member Functions | |
| UUID_Generator () | |
| ~UUID_Generator () | |
| void | init (void) |
| void | generateUUID (UUID &, ACE_UINT16 version=0x0001, u_char variant=0x80) |
| UUID * | generateUUID (ACE_UINT16 version=0x0001, u_char variant=0x80) |
| ACE_SYNCH_MUTEX * | lock (void) |
| ACE_SYNCH_MUTEX * | lock (ACE_SYNCH_MUTEX *lock, int release_lock) |
| Set a new locking strategy and return the old one. | |
Private Member Functions | |
| void | get_timestamp (UUID_time ×tamp) |
| void | get_systemtime (UUID_time &timeNow) |
| the Christian calendar). | |
Private Attributes | |
| UUID_time | timeLast_ |
| The system time when that last uuid was generated. | |
| UUID_State | uuid_state_ |
| The UUID generator persistent state. | |
| ACE_SYNCH_MUTEX * | lock_ |
| int | destroy_lock_ |
|
|
Type to represent UTC as a count of 100 nanosecond intervals since 00:00:00.00, 15 October 1582. Definition at line 180 of file UUID.h. Referenced by generateUUID(), get_systemtime(), and get_timestamp(). |
|
|
Definition at line 162 of file UUID.h.
00162 {ACE_UUID_CLOCK_SEQ_MASK = 0x3FFF};
|
|
|
Definition at line 298 of file UUID.cpp. References ACE_NEW, ACE_SYNCH_MUTEX, and destroy_lock_.
00299 : timeLast_ (0) 00300 { 00301 ACE_NEW (lock_, 00302 ACE_SYNCH_MUTEX); 00303 destroy_lock_ = 1; 00304 } |
|
|
Definition at line 306 of file UUID.cpp. References destroy_lock_.
00307 {
00308 if (destroy_lock_)
00309 delete lock_;
00310 }
|
|
||||||||||||
|
Format timestamp, clockseq, and nodeID into a VI UUID. For generating UUID's with thread and process ids use variant=0xc0 Definition at line 398 of file UUID.cpp. References ACE_NEW_RETURN, and generateUUID().
00399 {
00400 UUID* uuid;
00401 ACE_NEW_RETURN (uuid,
00402 UUID,
00403 0);
00404
00405 this->generateUUID (*uuid, version, variant);
00406 return uuid;
00407 }
|
|
||||||||||||||||
|
Format timestamp, clockseq, and nodeID into an UUID of the specified version and variant. For generating UUID's with thread and process ids use variant=0xc0 Definition at line 356 of file UUID.cpp. References ACE_GUARD, ACE_SYNCH_MUTEX, ACE_Utils::UUID::clockSeqHiAndReserved(), ACE_Utils::UUID::clockSeqLow(), ACE_Utils::UUID_Generator::UUID_State::clockSequence, get_timestamp(), ACE_Utils::UUID_Generator::UUID_State::node, ACE_Utils::UUID::node(), ACE_Utils::UUID::pid(), ACE_OS::sprintf(), ACE_Utils::UUID::thr_id(), ACE_Utils::UUID::timeHiAndVersion(), ACE_Utils::UUID::timeLow(), ACE_Utils::UUID::timeMid(), ACE_Utils::UUID_Generator::UUID_State::timestamp, ACE_Thread_ID::to_string(), uuid_state_, and UUID_time. Referenced by generateUUID().
00357 {
00358 UUID_time timestamp;
00359 this->get_timestamp (timestamp);
00360
00361
00362 // Construct a Version 1 UUID with the information in the arguements.
00363 uuid.timeLow (static_cast<ACE_UINT32> (timestamp & 0xFFFFFFFF));
00364 uuid.timeMid (static_cast<ACE_UINT16> ((timestamp >> 32) & 0xFFFF));
00365
00366
00367 ACE_UINT16 tHAV = static_cast<ACE_UINT16> ((timestamp >> 48) & 0xFFFF);
00368 tHAV |= (version << 12);
00369 uuid.timeHiAndVersion (tHAV);
00370
00371 u_char cseqHAV;
00372 {
00373 ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
00374 uuid.clockSeqLow (static_cast<u_char> (uuid_state_.clockSequence & 0xFF));
00375 cseqHAV = static_cast<u_char> ((uuid_state_.clockSequence & 0x3f00) >> 8);
00376 uuid_state_.timestamp = timestamp;
00377 }
00378
00379 cseqHAV |= variant;
00380 uuid.clockSeqHiAndReserved (cseqHAV);
00381 uuid.node (&(uuid_state_.node));
00382
00383 if (variant == 0xc0)
00384 {
00385 ACE_Thread_ID thread_id;
00386 char buf [BUFSIZ];
00387 thread_id.to_string (buf);
00388 uuid.thr_id (buf);
00389
00390 ACE_OS::sprintf (buf,
00391 "%d",
00392 static_cast<int> (ACE_OS::getpid ()));
00393 uuid.pid (buf);
00394 }
00395 }
|
|
|
the Christian calendar). Obtain the system time in UTC as a count of 100 nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to Definition at line 443 of file UUID.cpp. References ACE_UINT64, ACE_UINT64_LITERAL, ACE_OS::gettimeofday(), ACE_Time_Value::to_usec(), and UUID_time. Referenced by get_timestamp().
00444 {
00445 const UUID_time timeOffset = ACE_UINT64_LITERAL (0x1B21DD213814000);
00446
00447 /// Get the time of day, convert to 100ns ticks then add the offset.
00448 ACE_Time_Value now = ACE_OS::gettimeofday();
00449 ACE_UINT64 time;
00450 now.to_usec (time);
00451 time = time * 10;
00452 timestamp = time + timeOffset;
00453 }
|
|
|
Obtain a UUID timestamp. Compensate for the fact that the time obtained from getSystem time has a resolution less than 100ns. Definition at line 412 of file UUID.cpp. References ACE_GUARD, ACE_SYNCH_MUTEX, ACE_UUID_CLOCK_SEQ_MASK, ACE_Utils::UUID_Generator::UUID_State::clockSequence, get_systemtime(), timeLast_, uuid_state_, and UUID_time. Referenced by generateUUID(), and init().
00413 {
00414 ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
00415
00416 this->get_systemtime(timestamp);
00417
00418 // Account for the clock being set back. Increment the clock /
00419 // sequence.
00420 if (timestamp <= timeLast_)
00421 uuid_state_.clockSequence = static_cast<u_char> ((uuid_state_.clockSequence + 1) & ACE_UUID_CLOCK_SEQ_MASK);
00422
00423 // If the system time ticked since the last UUID was
00424 // generated. Set / the clock sequence back.
00425 else if (timestamp > timeLast_)
00426 uuid_state_.clockSequence = 0;
00427
00428 timeLast_ = timestamp;
00429 }
|
|
|
Definition at line 313 of file UUID.cpp. References ACE_GUARD, ACE_SYNCH_MUTEX, get_timestamp(), ACE_OS::getmacaddress(), ACE_OS::memcpy(), ACE_Utils::UUID_Generator::UUID_State::node, ACE_OS::macaddr_node_t::node, ACE_Utils::UUID_node::nodeID(), ACE_Utils::UUID_node::NodeID, ACE_OS::rand(), timeLast_, ACE_Utils::UUID_Generator::UUID_State::timestamp, and uuid_state_.
00314 {
00315 ACE_OS::macaddr_node_t macaddress;
00316 int result =
00317 ACE_OS::getmacaddress (&macaddress);
00318
00319 UUID_node::NodeID nodeID;
00320 if (result != -1)
00321 {
00322 // ACE_DEBUG ((LM_DEBUG,
00323 // "%02X-%02X-%02X-%02X-%02X-%02X\n",
00324 // macaddress.node [0],
00325 // macaddress.node [1],
00326 // macaddress.node [2],
00327 // macaddress.node [3],
00328 // macaddress.node [4],
00329 // macaddress.node [5]));
00330
00331 ACE_OS::memcpy (&nodeID,
00332 macaddress.node,
00333 sizeof (nodeID));
00334 }
00335 else
00336 {
00337 nodeID [0] = static_cast<u_char> (ACE_OS::rand());
00338 nodeID [1] = static_cast<u_char> (ACE_OS::rand());
00339 nodeID [2] = static_cast<u_char> (ACE_OS::rand());
00340 nodeID [3] = static_cast<u_char> (ACE_OS::rand());
00341 nodeID [4] = static_cast<u_char> (ACE_OS::rand());
00342 nodeID [5] = static_cast<u_char> (ACE_OS::rand());
00343 }
00344
00345 this->get_timestamp (timeLast_);
00346
00347 {
00348 ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, *lock_);
00349 uuid_state_.timestamp = timeLast_;
00350 uuid_state_.node.nodeID (nodeID);
00351 }
00352 }
|
|
||||||||||||
|
Set a new locking strategy and return the old one.
Definition at line 462 of file UUID.cpp. References ACE_SYNCH_MUTEX, and destroy_lock_.
00464 {
00465 if (destroy_lock_)
00466 delete lock_;
00467
00468 ACE_SYNCH_MUTEX* prev_lock = this->lock_;
00469 this->lock_ = lock;
00470 this->destroy_lock_ = release_lock_;
00471 return prev_lock;
00472 }
|
|
|
The locking strategy prevents multiple generators from accessing the UUID_state at the same time. Get the locking strategy. Definition at line 456 of file UUID.cpp.
00457 {
00458 return this->lock_;
00459 }
|
|
|
Definition at line 218 of file UUID.h. Referenced by lock(), UUID_Generator(), and ~UUID_Generator(). |
|
|
|
|
|
The system time when that last uuid was generated.
Definition at line 194 of file UUID.h. Referenced by get_timestamp(), and init(). |
|
|
The UUID generator persistent state.
Definition at line 215 of file UUID.h. Referenced by generateUUID(), get_timestamp(), and init(). |
1.3.6