summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2003-07-28 18:03:16 +0000
committerbala <balanatarajan@users.noreply.github.com>2003-07-28 18:03:16 +0000
commit89cb8d8589b19900b224d676b2f68488072ad50e (patch)
tree5157759d9ee5e6e91333ee01cb6e3d6cb3ba5057
parent0afb2105b9462242288c15c1bca774894eba031c (diff)
downloadATCD-89cb8d8589b19900b224d676b2f68488072ad50e.tar.gz
ChangeLogTag:Mon Jul 28 13:01:49 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r--ChangeLog13
-rw-r--r--ace/UUID.cpp688
-rw-r--r--ace/UUID.h310
-rw-r--r--ace/UUID.i211
-rw-r--r--ace/UUID.inl210
-rw-r--r--tests/UUIDTest.cpp34
6 files changed, 723 insertions, 743 deletions
diff --git a/ChangeLog b/ChangeLog
index b1e207d003d..f74eb3f87e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Mon Jul 28 13:01:49 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * ace/UUID.h:
+ * ace/UUID.cpp: The implementations are now placed in a namespace
+ ACE_Utils. Since we can now use namespaces, adding them to a
+ namspace made more sense.
+
+ * ace/UUID.i: File UUID.i is now renamed to be UUID.inl
+
+ * ace/UUID.inl: New file.
+
+ * tests/UUIDTest.cpp: Changes to confirm to the above changes.
+
Mon Jul 28 12:49:23 2003 Chad Elliott <elliott_c@ociweb.com>
* bin/MakeProjectCreator/modules/TemplateParser.pm:
diff --git a/ace/UUID.cpp b/ace/UUID.cpp
index c3a4f5b5b20..f28ff9dddc6 100644
--- a/ace/UUID.cpp
+++ b/ace/UUID.cpp
@@ -1,131 +1,120 @@
//$Id$
-#include "ace/OS.h"
-#include "ace/Log_Msg.h"
-#include "ace/UUID.h"
+#include "OS.h"
+#include "Log_Msg.h"
+#include "UUID.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UUID.inl"
+#endif /* __ACE_INLINE__ */
ACE_RCSID (ace,
UUID,
"$Id$")
-UUID_node::UUID_node (void)
+namespace ACE_Utils
{
- for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
- {
- nodeID_[i] = 0;
- }
-}
-UUID_node::NodeID&
-UUID_node::nodeID (void)
-{
- return nodeID_;
-}
-
-void
-UUID_node::nodeID (NodeID& nodeID)
-{
- for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
- {
- nodeID_[i] = nodeID[i];
- }
-}
+ UUID_node::UUID_node (void)
+ {
+ for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
+ {
+ nodeID_[i] = 0;
+ }
+ }
-ACE_UUID ACE_UUID::NIL_UUID;
+ UUID_node::NodeID&
+ UUID_node::nodeID (void)
+ {
+ return nodeID_;
+ }
-/// Construct a nil UUID. Such a UUID has every one of it's data
-/// elements set to zero.
-ACE_UUID::ACE_UUID(void)
- : timeLow_ (0),
- timeMid_ (0),
- timeHiAndVersion_ (0),
- clockSeqHiAndReserved_ (0),
- clockSeqLow_ (0),
- as_string_ (0)
-{
- ACE_NEW (node_,
- UUID_node);
+ void
+ UUID_node::nodeID (NodeID& nodeID)
+ {
+ for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
+ {
+ nodeID_[i] = nodeID[i];
+ }
+ }
- node_release_ = 1;
-}
+ UUID UUID::NIL_UUID;
-ACE_UUID::ACE_UUID(const ACE_UUID &right)
- : timeLow_ (0),
- timeMid_ (0),
+ /// Construct a nil UUID. Such a UUID has every one of it's data
+ /// elements set to zero.
+ UUID::UUID(void)
+ : timeLow_ (0),
+ timeMid_ (0),
timeHiAndVersion_ (0),
- clockSeqHiAndReserved_ (0),
- clockSeqLow_ (0),
- as_string_ (0)
-{
- node_release_ = 0;
- *this = right;
-}
+ clockSeqHiAndReserved_ (0),
+ clockSeqLow_ (0),
+ as_string_ (0)
+ {
+ ACE_NEW (node_,
+ UUID_node);
-/// Construct a UUID from a string representation of an UUID.
-ACE_UUID::ACE_UUID (const ACE_CString& uuid_string)
- : timeLow_ (0),
- timeMid_ (0),
- timeHiAndVersion_ (0),
- clockSeqHiAndReserved_ (0),
- clockSeqLow_ (0),
- as_string_ (0)
-{
- ACE_NEW (node_,
- UUID_node);
+ node_release_ = 1;
+ }
- node_release_ = 1;
+ UUID::UUID(const UUID &right)
+ : timeLow_ (0),
+ timeMid_ (0),
+ timeHiAndVersion_ (0),
+ clockSeqHiAndReserved_ (0),
+ clockSeqLow_ (0),
+ as_string_ (0)
+ {
+ node_release_ = 0;
+ *this = right;
+ }
- ACE_TRACE ("ACE_UUID::ACE_UUID");
+ /// Construct a UUID from a string representation of an UUID.
+ UUID::UUID (const ACE_CString& uuid_string)
+ : timeLow_ (0),
+ timeMid_ (0),
+ timeHiAndVersion_ (0),
+ clockSeqHiAndReserved_ (0),
+ clockSeqLow_ (0),
+ as_string_ (0)
+ {
+ ACE_NEW (node_,
+ UUID_node);
- if (uuid_string.length() < NIL_UUID.to_string()->length())
- {
- ACE_DEBUG ((LM_DEBUG,
- "%N ACE_UUID::ACE_UUID - "
- "IllegalArgument(incorrect string length)\n"));
- return;
- }
+ node_release_ = 1;
- /// Special case for the nil UUID.
- if (uuid_string == *NIL_UUID.to_string())
- {
- *this = NIL_UUID;
- return;
- }
+ ACE_TRACE ("UUID::UUID");
+
+ if (uuid_string.length() < NIL_UUID.to_string()->length())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "%N ACE_UUID::UUID - "
+ "IllegalArgument(incorrect string length)\n"));
+ return;
+ }
- unsigned int timeLow;
- unsigned int timeMid;
- unsigned int timeHiAndVersion;
- unsigned int clockSeqHiAndReserved;
- unsigned int clockSeqLow;
- unsigned int node [UUID_node::NODE_ID_SIZE];
- char thr_pid_buf [BUFSIZ];
+ /// Special case for the nil UUID.
+ if (uuid_string == *NIL_UUID.to_string())
+ {
+ *this = NIL_UUID;
+ return;
+ }
- if (uuid_string.length() == NIL_UUID.to_string()->length())
- {
- // This might seem quite strange this being in ACE, but it seems to
- // be a bit difficult to write a facade for ::sscanf because some
- // compilers dont support vsscanf, including MSVC. It appears that
- // most platforms support sscanf though so we need to use it
- // directly.
-#if defined (ACE_HAS_PACE)
- int nScanned = ::pace_sscanf(uuid_string.c_str(),
- "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
- &timeLow,
- &timeMid,
- &timeHiAndVersion,
- &clockSeqHiAndReserved,
- &clockSeqLow,
- &node[0],
- &node[1],
- &node[2],
- &node[3],
- &node[4],
- &node[5]
- );
-
-#else
+ unsigned int timeLow;
+ unsigned int timeMid;
+ unsigned int timeHiAndVersion;
+ unsigned int clockSeqHiAndReserved;
+ unsigned int clockSeqLow;
+ unsigned int node [UUID_node::NODE_ID_SIZE];
+ char thr_pid_buf [BUFSIZ];
- int nScanned = ::sscanf(uuid_string.c_str(),
+ if (uuid_string.length() == NIL_UUID.to_string()->length())
+ {
+ // This might seem quite strange this being in ACE, but it seems to
+ // be a bit difficult to write a facade for ::sscanf because some
+ // compilers dont support vsscanf, including MSVC. It appears that
+ // most platforms support sscanf though so we need to use it
+ // directly.
+ int nScanned = ::sscanf(uuid_string.c_str(),
"%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
&timeLow,
&timeMid,
@@ -139,36 +128,16 @@ ACE_UUID::ACE_UUID (const ACE_CString& uuid_string)
&node[4],
&node[5]
);
-#endif
if (nScanned != 11)
{
ACE_DEBUG ((LM_DEBUG,
- "ACE_UUID::ACE_UUID - "
+ "UUID::UUID - "
"IllegalArgument(invalid string representation)"));
return;
}
}
else
{
-#if defined (ACE_HAS_PACE)
- int nScanned = ::pace_sscanf(uuid_string.c_str(),
- "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s",
- &timeLow,
- &timeMid,
- &timeHiAndVersion,
- &clockSeqHiAndReserved,
- &clockSeqLow,
- &node[0],
- &node[1],
- &node[2],
- &node[3],
- &node[4],
- &node[5],
- thr_pid_buf
- );
-
-#else
-
int nScanned = ::sscanf(uuid_string.c_str(),
"%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s",
&timeLow,
@@ -184,7 +153,6 @@ ACE_UUID::ACE_UUID (const ACE_CString& uuid_string)
&node[5],
thr_pid_buf
);
-#endif
if (nScanned != 12)
{
ACE_DEBUG ((LM_DEBUG,
@@ -194,81 +162,81 @@ ACE_UUID::ACE_UUID (const ACE_CString& uuid_string)
}
}
- this->timeLow_ = ACE_static_cast (ACE_UINT64, timeLow);
- this->timeMid_ = ACE_static_cast (ACE_UINT16, timeMid);
- this->timeHiAndVersion_ = ACE_static_cast (ACE_UINT16, timeHiAndVersion);
- this->clockSeqHiAndReserved_ = ACE_static_cast (u_char, clockSeqHiAndReserved);
- this->clockSeqLow_ = ACE_static_cast (u_char, clockSeqLow);
+ this->timeLow_ = ACE_static_cast (ACE_UINT64, timeLow);
+ this->timeMid_ = ACE_static_cast (ACE_UINT16, timeMid);
+ this->timeHiAndVersion_ = ACE_static_cast (ACE_UINT16, timeHiAndVersion);
+ this->clockSeqHiAndReserved_ = ACE_static_cast (u_char, clockSeqHiAndReserved);
+ this->clockSeqLow_ = ACE_static_cast (u_char, clockSeqLow);
- UUID_node::NodeID nodeID;
- for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
- nodeID [i] = ACE_static_cast (u_char, node[i]);
+ UUID_node::NodeID nodeID;
+ for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
+ nodeID [i] = ACE_static_cast (u_char, node[i]);
- this->node_->nodeID (nodeID);
+ this->node_->nodeID (nodeID);
- // Support varient 10- only
- if ((this->clockSeqHiAndReserved_ & 0xc0) != 0x80 && (this->clockSeqHiAndReserved_ & 0xc0) != 0xc0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "ACE_UUID_Impl::ACE_UUID_Impl - "
- "IllegalArgument(unsupported variant)"));
- return;
- }
+ // Support varient 10- only
+ if ((this->clockSeqHiAndReserved_ & 0xc0) != 0x80 && (this->clockSeqHiAndReserved_ & 0xc0) != 0xc0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID_Impl::ACE_UUID_Impl - "
+ "IllegalArgument(unsupported variant)"));
+ return;
+ }
- /// Support versions 1, 3, and 4 only
- ACE_UINT16 V1 = this->timeHiAndVersion_;
+ /// Support versions 1, 3, and 4 only
+ ACE_UINT16 V1 = this->timeHiAndVersion_;
- if ((V1 & 0xF000) != 0x1000 &&
- (V1 & 0xF000) != 0x3000 &&
+ if ((V1 & 0xF000) != 0x1000 &&
+ (V1 & 0xF000) != 0x3000 &&
(V1 & 0xF000) != 0x4000)
- {
- ACE_DEBUG ((LM_DEBUG,
- "ACE_UUID::ACE_UUID - "
- "IllegalArgument(unsupported version)"));
- return;
- }
- if ((this->clockSeqHiAndReserved_ & 0xc0) == 0xc0)
- {
- if (uuid_string.length() == NIL_UUID.to_string()->length())
- {
- ACE_DEBUG ((LM_DEBUG,
- "ACE_UUID::ACE_UUID - "
- "IllegalArgument (Missing Thread and Process Id)"));
- return;
- }
- ACE_CString thr_pid_str (thr_pid_buf);
- int pos = thr_pid_str.find ('-');
- if (pos == -1)
+ {
ACE_DEBUG ((LM_DEBUG,
"ACE_UUID::ACE_UUID - "
- "IllegalArgument (Thread and Process Id format incorrect)"));
+ "IllegalArgument(unsupported version)"));
+ return;
+ }
+ if ((this->clockSeqHiAndReserved_ & 0xc0) == 0xc0)
+ {
+ if (uuid_string.length() == NIL_UUID.to_string()->length())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::ACE_UUID - "
+ "IllegalArgument (Missing Thread and Process Id)"));
+ return;
+ }
+ ACE_CString thr_pid_str (thr_pid_buf);
+ int pos = thr_pid_str.find ('-');
+ if (pos == -1)
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::ACE_UUID - "
+ "IllegalArgument (Thread and Process Id format incorrect)"));
- this->thr_id_ = thr_pid_str.substr (0, pos);
+ this->thr_id_ = thr_pid_str.substr (0, pos);
this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1);
- }
-}
+ }
+ }
-ACE_UUID::~ACE_UUID (void)
-{
- if (node_release_)
- delete node_;
+ UUID::~UUID (void)
+ {
+ if (node_release_)
+ delete node_;
- if (as_string_ != 0)
- delete as_string_;
-}
+ if (as_string_ != 0)
+ delete as_string_;
+ }
-const ACE_CString*
-ACE_UUID::to_string (void)
-{
- /// Only compute the string representation once.
- if (as_string_ == 0)
- {
- // Get a buffer exactly the correct size. Use the nil UUID as a
- // gauge. Don't forget the trailing nul.
- int UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length ();
- char *buf;
+ const ACE_CString*
+ UUID::to_string (void)
+ {
+ /// Only compute the string representation once.
+ if (as_string_ == 0)
+ {
+ // Get a buffer exactly the correct size. Use the nil UUID as a
+ // gauge. Don't forget the trailing nul.
+ int UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length ();
+ char *buf;
- if ((thr_id_.length () != 0) && (pid_.length () != 0))
+ if ((thr_id_.length () != 0) && (pid_.length () != 0))
{
UUID_STRING_LENGTH += 2; //for '-'
ACE_NEW_RETURN (buf,
@@ -292,122 +260,122 @@ ACE_UUID::to_string (void)
pid_.c_str ()
);
}
- else
- {
- ACE_NEW_RETURN (buf,
- char[UUID_STRING_LENGTH + 1],
- 0);
-
- ACE_OS::sprintf(buf,
- "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
- this->timeLow_,
- this->timeMid_,
- this->timeHiAndVersion_,
- this->clockSeqHiAndReserved_,
- this->clockSeqLow_,
- (this->node_->nodeID ()) [0],
+ else
+ {
+ ACE_NEW_RETURN (buf,
+ char[UUID_STRING_LENGTH + 1],
+ 0);
+
+ ACE_OS::sprintf(buf,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
+ this->timeLow_,
+ this->timeMid_,
+ this->timeHiAndVersion_,
+ this->clockSeqHiAndReserved_,
+ this->clockSeqLow_,
+ (this->node_->nodeID ()) [0],
(this->node_->nodeID ()) [1],
- (this->node_->nodeID ()) [2],
- (this->node_->nodeID ()) [3],
- (this->node_->nodeID ()) [4],
- (this->node_->nodeID ()) [5]
- );
- }
- ACE_NEW_RETURN (this->as_string_,
- ACE_CString (buf, UUID_STRING_LENGTH),
- 0);
- delete buf;
- }
+ (this->node_->nodeID ()) [2],
+ (this->node_->nodeID ()) [3],
+ (this->node_->nodeID ()) [4],
+ (this->node_->nodeID ()) [5]
+ );
+ }
+ ACE_NEW_RETURN (this->as_string_,
+ ACE_CString (buf, UUID_STRING_LENGTH),
+ 0);
+ delete buf;
+ }
- return as_string_;
-}
+ return as_string_;
+ }
-ACE_UUID_Generator::ACE_UUID_Generator ()
- : timeLast_ (0)
-{
- ACE_NEW (lock_,
+ UUID_Generator::UUID_Generator ()
+ : timeLast_ (0)
+ {
+ ACE_NEW (lock_,
ACE_SYNCH_MUTEX);
- destroy_lock_ = 1;
-}
+ destroy_lock_ = 1;
+ }
-ACE_UUID_Generator::~ACE_UUID_Generator()
-{
- if (destroy_lock_)
- delete lock_;
-}
+ UUID_Generator::~UUID_Generator()
+ {
+ if (destroy_lock_)
+ delete lock_;
+ }
-void
-ACE_UUID_Generator::init (void)
-{
- ACE_OS::macaddr_node_t macaddress;
- int result =
- ACE_OS::getmacaddress (&macaddress);
+ void
+ UUID_Generator::init (void)
+ {
+ ACE_OS::macaddr_node_t macaddress;
+ int result =
+ ACE_OS::getmacaddress (&macaddress);
- UUID_node::NodeID nodeID;
- if (result != -1)
- {
- ACE_DEBUG ((LM_DEBUG,
- "%02X-%02X-%02X-%02X-%02X-%02X\n",
- macaddress.node [0],
- macaddress.node [1],
- macaddress.node [2],
- macaddress.node [3],
- macaddress.node [4],
- macaddress.node [5]));
-
- ACE_OS::memcpy (&nodeID,
- macaddress.node,
- sizeof (nodeID));
- }
- else
- {
- nodeID [0] = ACE_static_cast (u_char, ACE_OS::rand());
- nodeID [1] = ACE_static_cast (u_char, ACE_OS::rand());
- nodeID [2] = ACE_static_cast (u_char, ACE_OS::rand());
- nodeID [3] = ACE_static_cast (u_char, ACE_OS::rand());
- nodeID [4] = ACE_static_cast (u_char, ACE_OS::rand());
- nodeID [5] = ACE_static_cast (u_char, ACE_OS::rand());
- }
+ UUID_node::NodeID nodeID;
+ if (result != -1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "%02X-%02X-%02X-%02X-%02X-%02X\n",
+ macaddress.node [0],
+ macaddress.node [1],
+ macaddress.node [2],
+ macaddress.node [3],
+ macaddress.node [4],
+ macaddress.node [5]));
+
+ ACE_OS::memcpy (&nodeID,
+ macaddress.node,
+ sizeof (nodeID));
+ }
+ else
+ {
+ nodeID [0] = ACE_static_cast (u_char, ACE_OS::rand());
+ nodeID [1] = ACE_static_cast (u_char, ACE_OS::rand());
+ nodeID [2] = ACE_static_cast (u_char, ACE_OS::rand());
+ nodeID [3] = ACE_static_cast (u_char, ACE_OS::rand());
+ nodeID [4] = ACE_static_cast (u_char, ACE_OS::rand());
+ nodeID [5] = ACE_static_cast (u_char, ACE_OS::rand());
+ }
- this->get_timestamp (timeLast_);
+ this->get_timestamp (timeLast_);
- {
- ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, *lock_);
- uuid_state_.timestamp = timeLast_;
- uuid_state_.node.nodeID (nodeID);
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, *lock_);
+ uuid_state_.timestamp = timeLast_;
+ uuid_state_.node.nodeID (nodeID);
+ }
}
-}
-void
-ACE_UUID_Generator::generateUUID (ACE_UUID& uuid,ACE_UINT16 version, u_char variant)
-{
- UUID_time timestamp;
- this->get_timestamp (timestamp);
+ void
+ UUID_Generator::generateUUID (UUID& uuid,ACE_UINT16 version, u_char variant)
+ {
+ UUID_time timestamp;
+ this->get_timestamp (timestamp);
- // Construct a Version 1 UUID with the information in the arguements.
- uuid.timeLow (ACE_static_cast (ACE_UINT32, timestamp & 0xFFFFFFFF));
- uuid.timeMid (ACE_static_cast(ACE_UINT16, (timestamp >> 32) & 0xFFFF));
+ // Construct a Version 1 UUID with the information in the arguements.
+ uuid.timeLow (ACE_static_cast (ACE_UINT32, timestamp & 0xFFFFFFFF));
+ uuid.timeMid (ACE_static_cast(ACE_UINT16, (timestamp >> 32) & 0xFFFF));
- ACE_UINT16 tHAV = ACE_static_cast (ACE_UINT16, (timestamp >> 48) & 0xFFFF);
- tHAV |= (version << 12);
- uuid.timeHiAndVersion (tHAV);
+ ACE_UINT16 tHAV = ACE_static_cast (ACE_UINT16, (timestamp >> 48) & 0xFFFF);
+ tHAV |= (version << 12);
+ uuid.timeHiAndVersion (tHAV);
- u_char cseqHAV;
- {
- ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
- uuid.clockSeqLow (uuid_state_.clockSequence & 0xFF);
- cseqHAV = (uuid_state_.clockSequence & 0x3f00) >> 8;
- uuid_state_.timestamp = timestamp;
- }
+ u_char cseqHAV;
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
+ uuid.clockSeqLow (uuid_state_.clockSequence & 0xFF);
+ cseqHAV = (uuid_state_.clockSequence & 0x3f00) >> 8;
+ uuid_state_.timestamp = timestamp;
+ }
- cseqHAV |= variant;
- uuid.clockSeqHiAndReserved (cseqHAV);
- uuid.node (&(uuid_state_.node));
+ cseqHAV |= variant;
+ uuid.clockSeqHiAndReserved (cseqHAV);
+ uuid.node (&(uuid_state_.node));
- if (variant == 0xc0)
+ if (variant == 0xc0)
{
ACE_thread_t thr_id = ACE_OS::thr_self ();
ACE_hthread_t thr_handle;
@@ -422,98 +390,98 @@ ACE_UUID_Generator::generateUUID (ACE_UUID& uuid,ACE_UINT16 version, u_char vari
ACE_static_cast (int, ACE_OS::getpid ()));
uuid.pid (buf);
}
-}
+ }
-ACE_UUID*
-ACE_UUID_Generator::generateUUID (ACE_UINT16 version, u_char variant)
-{
- ACE_UUID* uuid;
- ACE_NEW_RETURN (uuid,
- ACE_UUID,
- 0);
+ UUID*
+ UUID_Generator::generateUUID (ACE_UINT16 version, u_char variant)
+ {
+ UUID* uuid;
+ ACE_NEW_RETURN (uuid,
+ UUID,
+ 0);
- this->generateUUID (*uuid, version, variant);
- return uuid;
-}
+ this->generateUUID (*uuid, version, variant);
+ return uuid;
+ }
-/// Obtain a new timestamp. If UUID's are being generated too quickly
-/// the clock sequence will be incremented
-void
-ACE_UUID_Generator::get_timestamp (UUID_time& timestamp)
-{
- this->get_systemtime(timestamp);
+ /// Obtain a new timestamp. If UUID's are being generated too quickly
+ /// the clock sequence will be incremented
+ void
+ UUID_Generator::get_timestamp (UUID_time& timestamp)
+ {
+ this->get_systemtime(timestamp);
- /// Account for the clock being set back. Increment the clock
- /// sequence.
- if (timestamp <= timeLast_)
- {
+ /// Account for the clock being set back. Increment the clock
+ /// sequence.
+ if (timestamp <= timeLast_)
{
- ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
- uuid_state_.clockSequence = (uuid_state_.clockSequence + 1) & ACE_UUID_CLOCK_SEQ_MASK;
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
+ uuid_state_.clockSequence = (uuid_state_.clockSequence + 1) & ACE_UUID_CLOCK_SEQ_MASK;
+ }
}
- }
- /// If the system time ticked since the last UUID was generated. Set
- /// the clock sequence back.
- else if (timestamp > timeLast_)
- {
+ /// If the system time ticked since the last UUID was generated. Set
+ /// the clock sequence back.
+ else if (timestamp > timeLast_)
{
- ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
- uuid_state_.clockSequence = 0;
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
+ uuid_state_.clockSequence = 0;
+ }
}
- }
- timeLast_ = timestamp;
-}
+ timeLast_ = timestamp;
+ }
-/**
- * ACE_Time_Value is in POSIX time, seconds since Jan 1, 1970. UUIDs use
- * time in 100ns ticks since 15 October 1582. The difference is:
- * 15 Oct 1582 - 1 Jan 1600: 17 days in Oct, 30 in Nov, 31 in Dec +
- * 17 years and 4 leap days (1584, 88, 92 and 96)
- * 1 Jan 1600 - 1 Jan 1900: 3 centuries + 73 leap days ( 25 in 17th cent.
- * and 24 each in 18th and 19th centuries)
- * 1 Jan 1900 - 1 Jan 1970: 70 years + 17 leap days.
- * This adds up, in days: (17+30+31+365*17+4)+(365*300+73)+(365*70+17) or
- * 122192928000000000U (0x1B21DD213814000) 100 ns ticks.
- */
-void
-ACE_UUID_Generator::get_systemtime (UUID_time & timestamp)
-{
- const UUID_time timeOffset = 0;
- //const UUID_time timeOffset = 0x1B21DD213814000;
+ /**
+ * ACE_Time_Value is in POSIX time, seconds since Jan 1, 1970. UUIDs use
+ * time in 100ns ticks since 15 October 1582. The difference is:
+ * 15 Oct 1582 - 1 Jan 1600: 17 days in Oct, 30 in Nov, 31 in Dec +
+ * 17 years and 4 leap days (1584, 88, 92 and 96)
+ * 1 Jan 1600 - 1 Jan 1900: 3 centuries + 73 leap days ( 25 in 17th cent.
+ * and 24 each in 18th and 19th centuries)
+ * 1 Jan 1900 - 1 Jan 1970: 70 years + 17 leap days.
+ * This adds up, in days: (17+30+31+365*17+4)+(365*300+73)+(365*70+17) or
+ * 122192928000000000U (0x1B21DD213814000) 100 ns ticks.
+ */
+ void
+ UUID_Generator::get_systemtime (UUID_time & timestamp)
+ {
+ const UUID_time timeOffset = 0;
+ //const UUID_time timeOffset = 0x1B21DD213814000;
- /// Get the time of day, convert to 100ns ticks then add the offset.
- ACE_Time_Value now = ACE_OS::gettimeofday();
- UUID_time time = now.sec() * 10000000 + now.usec() * 10;
- timestamp = time + timeOffset;
+ /// Get the time of day, convert to 100ns ticks then add the offset.
+ ACE_Time_Value now = ACE_OS::gettimeofday();
+ UUID_time time = now.sec() * 10000000 + now.usec() * 10;
+ timestamp = time + timeOffset;
}
-ACE_SYNCH_MUTEX*
-ACE_UUID_Generator::lock (void)
-{
- return this->lock_;
-}
+ ACE_SYNCH_MUTEX*
+ UUID_Generator::lock (void)
+ {
+ return this->lock_;
+ }
-ACE_SYNCH_MUTEX*
-ACE_UUID_Generator::lock (ACE_SYNCH_MUTEX* lock,
- int release_lock_)
-{
- if (destroy_lock_)
- delete lock_;
+ ACE_SYNCH_MUTEX*
+ UUID_Generator::lock (ACE_SYNCH_MUTEX* lock,
+ int release_lock_)
+ {
+ if (destroy_lock_)
+ delete lock_;
+
+ ACE_SYNCH_MUTEX* prev_lock = this->lock_;
+ this->lock_ = lock;
+ this->destroy_lock_ = release_lock_;
+ return prev_lock;
+ }
+
+};
- ACE_SYNCH_MUTEX* prev_lock = this->lock_;
- this->lock_ = lock;
- this->destroy_lock_ = release_lock_;
- return prev_lock;
-}
-#if !defined (__ACE_INLINE__)
-#include "ace/UUID.i"
-#endif /* __ACE_INLINE__ */
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Singleton <ACE_UUID_Generator, ACE_SYNCH_MUTEX>;
+template class ACE_Singleton <ACE_Utils::UUID_Generator, ACE_SYNCH_MUTEX>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Singleton <ACE_UUID_Generator, ACE_SYNCH_MUTEX>
+#pragma instantiate ACE_Singleton <ACE_Utils::UUID_Generator, ACE_SYNCH_MUTEX>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/ace/UUID.h b/ace/UUID.h
index 4fb1850cc03..ce69d6c7a81 100644
--- a/ace/UUID.h
+++ b/ace/UUID.h
@@ -12,221 +12,221 @@
#ifndef ACE_UUID_H
#define ACE_UUID_H
-
#include /**/ "ace/pre.h"
+
#include "ace/OS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
#include "ace/SString.h"
#include "ace/Singleton.h"
#include "ace/Synch.h"
-/// Class to hold a MAC address
-class ACE_Export UUID_node
+namespace ACE_Utils
{
- public:
+ /// Class to hold a MAC address
+ class ACE_Export UUID_node
+ {
+ public:
- /// Constructor
- UUID_node (void);
+ /// Constructor
+ UUID_node (void);
- enum {NODE_ID_SIZE = 6};
- typedef u_char NodeID[NODE_ID_SIZE];
+ enum {NODE_ID_SIZE = 6};
+ typedef u_char NodeID[NODE_ID_SIZE];
- NodeID& nodeID (void);
- void nodeID (NodeID&);
+ NodeID& nodeID (void);
+ void nodeID (NodeID&);
- /// Assignment Operation
- UUID_node &operator=(const UUID_node &right);
+ /// Assignment Operation
+ UUID_node &operator=(const UUID_node &right);
- /// Equality Operations
- bool operator == (const UUID_node& right) const;
- bool operator != (const UUID_node& right) const;
+ /// Equality Operations
+ bool operator == (const UUID_node& right) const;
+ bool operator != (const UUID_node& right) const;
- /// Relational Operations
- bool operator < (const UUID_node& right) const;
+ /// Relational Operations
+ bool operator < (const UUID_node& right) const;
- private:
- NodeID nodeID_;
-};
+ private:
+ NodeID nodeID_;
+ };
-/**
- * @class ACE_UUID
- *
- * ACE_UUID represents a Universally Unique IDentifier (UUID) as
- * described in (the expired) INTERNET-DRAFT specification entitled
- * UUIDs and GUIDs. All instances of UUID are of the time-based
- * variety. That is, the version number part of the timeHiAndVersion
- * field is 1.
- *
- * The default constructor creates a nil UUID.
- *
- * UUIDs have value semantics. In addition, they may be compared for
- * ordering and equality.
- *
- * Additionally in this implementation provisions have been made to include
- * process and thread ids to make the UUIDs more unique. The variant 0xc0
- * has been added to facilitate this.
- */
-class ACE_Export ACE_UUID
-{
- public:
- /// Constructor
- ACE_UUID(void);
+ /**
+ * @class ACE_UUID
+ *
+ * ACE_UUID represents a Universally Unique IDentifier (UUID) as
+ * described in (the expired) INTERNET-DRAFT specification entitled
+ * UUIDs and GUIDs. All instances of UUID are of the time-based
+ * variety. That is, the version number part of the timeHiAndVersion
+ * field is 1.
+ *
+ * The default constructor creates a nil UUID.
+ *
+ * UUIDs have value semantics. In addition, they may be compared for
+ * ordering and equality.
+ *
+ * Additionally in this implementation provisions have been made to include
+ * process and thread ids to make the UUIDs more unique. The variant 0xc0
+ * has been added to facilitate this.
+ */
+ class ACE_Export UUID
+ {
+ public:
- /// Copy constructor
- ACE_UUID(const ACE_UUID &right);
+ /// Constructor
+ UUID (void);
- /// Constructs a UUID from a string representation.
- ACE_UUID (const ACE_CString& uuidString);
+ /// Copy constructor
+ UUID (const UUID &right);
- // Destructor
- ~ACE_UUID (void);
+ /// Constructs a UUID from a string representation.
+ UUID (const ACE_CString& uuidString);
- ACE_UINT32 timeLow (void);
- void timeLow (ACE_UINT32);
+ // Destructor
+ ~UUID (void);
- ACE_UINT16 timeMid (void);
- void timeMid (ACE_UINT16);
+ ACE_UINT32 timeLow (void);
+ void timeLow (ACE_UINT32);
- ACE_UINT16 timeHiAndVersion (void);
- void timeHiAndVersion (ACE_UINT16);
+ ACE_UINT16 timeMid (void);
+ void timeMid (ACE_UINT16);
- u_char clockSeqHiAndReserved (void);
- void clockSeqHiAndReserved (u_char);
+ ACE_UINT16 timeHiAndVersion (void);
+ void timeHiAndVersion (ACE_UINT16);
- u_char clockSeqLow (void);
- void clockSeqLow (u_char);
+ u_char clockSeqHiAndReserved (void);
+ void clockSeqHiAndReserved (u_char);
- UUID_node* node (void);
- void node (UUID_node*);
+ u_char clockSeqLow (void);
+ void clockSeqLow (u_char);
- ACE_CString* thr_id (void);
- void thr_id (char*);
+ UUID_node* node (void);
+ void node (UUID_node*);
- ACE_CString* pid (void);
- void pid (char*);
+ ACE_CString* thr_id (void);
+ void thr_id (char*);
- /// Returns a string representation of the UUID
- const ACE_CString* to_string (void);
+ ACE_CString* pid (void);
+ void pid (char*);
- static ACE_UUID NIL_UUID;
+ /// Returns a string representation of the UUID
+ const ACE_CString* to_string (void);
- /// Assignment Operation
- ACE_UUID & operator=(const ACE_UUID &right);
+ static UUID NIL_UUID;
- /// Equality Operations
- bool operator==(const ACE_UUID &right) const;
- bool operator!=(const ACE_UUID &right) const;
+ /// Assignment Operation
+ UUID & operator= (const UUID &right);
- /// Relational Operations
- bool operator< (const ACE_UUID &right) const;
- bool operator> (const ACE_UUID &right) const;
- bool operator<=(const ACE_UUID &right) const;
- bool operator>=(const ACE_UUID &right) const;
+ /// Equality Operations
+ bool operator== (const UUID &right) const;
+ bool operator!= (const UUID &right) const;
- private:
+ /// Relational Operations
+ bool operator< (const UUID &right) const;
+ bool operator> (const UUID &right) const;
+ bool operator<= (const UUID &right) const;
+ bool operator>= (const UUID &right) const;
- /// Data Members for Class Attributes
- ACE_UINT32 timeLow_;
- ACE_UINT16 timeMid_;
- ACE_UINT16 timeHiAndVersion_;
- u_char clockSeqHiAndReserved_;
- u_char clockSeqLow_;
- UUID_node* node_;
- int node_release_;
- ACE_CString thr_id_;
- ACE_CString pid_;
+ private:
- /// The string representation of the UUID. This is created and
- /// updated only on demand.
- ACE_CString *as_string_;
-};
+ /// Data Members for Class Attributes
+ ACE_UINT32 timeLow_;
+ ACE_UINT16 timeMid_;
+ ACE_UINT16 timeHiAndVersion_;
+ u_char clockSeqHiAndReserved_;
+ u_char clockSeqLow_;
+ UUID_node* node_;
+ int node_release_;
+ ACE_CString thr_id_;
+ ACE_CString pid_;
+ /// The string representation of the UUID. This is created and
+ /// updated only on demand.
+ ACE_CString *as_string_;
+ };
-/**
- * @class ACE_UUID_Generator
- *
- * Singleton class that generates UUIDs.
- *
- */
-class ACE_Export ACE_UUID_Generator
-{
- public:
- enum {ACE_UUID_CLOCK_SEQ_MASK = 0x3FFF};
+ /**
+ * @class ACE_UUID_Generator
+ *
+ * Singleton class that generates UUIDs.
+ *
+ */
+ class ACE_Export UUID_Generator
+ {
+ public:
- ACE_UUID_Generator();
- ~ACE_UUID_Generator();
+ enum {ACE_UUID_CLOCK_SEQ_MASK = 0x3FFF};
- void init (void);
+ UUID_Generator();
+ ~UUID_Generator();
- /// 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
- void generateUUID(ACE_UUID&, ACE_UINT16 version=0x0001, u_char variant=0x80);
+ void init (void);
- /// Format timestamp, clockseq, and nodeID into a VI UUID. For
- /// generating UUID's with thread and process ids use variant=0xc0
- ACE_UUID* generateUUID (ACE_UINT16 version=0x0001, u_char variant=0x80);
+ /// 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
+ void generateUUID (UUID&, ACE_UINT16 version=0x0001, u_char variant=0x80);
- /// Type to represent UTC as a count of 100 nanosecond intervals
- /// since 00:00:00.00, 15 October 1582.
- typedef ACE_UINT64 UUID_time;
+ /// Format timestamp, clockseq, and nodeID into a VI UUID. For
+ /// generating UUID's with thread and process ids use variant=0xc0
+ UUID* generateUUID (ACE_UINT16 version=0x0001, u_char variant=0x80);
- /// The locking strategy prevents multiple generators from accessing
- /// the UUID_state at the same time. Get the locking strategy.
- ACE_SYNCH_MUTEX* lock (void);
+ /// Type to represent UTC as a count of 100 nanosecond intervals
+ /// since 00:00:00.00, 15 October 1582.
+ typedef ACE_UINT64 UUID_time;
- /// Set a new locking strategy and return the old one.
- ACE_SYNCH_MUTEX* lock (ACE_SYNCH_MUTEX*lock,
- int release_lock);
+ /// The locking strategy prevents multiple generators from accessing
+ /// the UUID_state at the same time. Get the locking strategy.
+ ACE_SYNCH_MUTEX* lock (void);
+ /// Set a new locking strategy and return the old one.
+ ACE_SYNCH_MUTEX* lock (ACE_SYNCH_MUTEX*lock,
+ int release_lock);
- private:
- /// The system time when that last uuid was generated.
- UUID_time timeLast_;
+ private:
- /// Type to contain the UUID generator persistent state. This will
- /// be kept in memory mapped shared memory
- struct UUID_State
- {
- UUID_time timestamp;
- UUID_node node;
- ACE_UINT16 clockSequence;
- };
+ /// The system time when that last uuid was generated.
+ UUID_time timeLast_;
- /// Obtain a UUID timestamp. Compensate for the fact that the time
- /// obtained from getSystem time has a resolution less than 100ns.
+ /// Type to contain the UUID generator persistent state. This will
+ /// be kept in memory mapped shared memory
+ struct UUID_State
+ {
+ UUID_time timestamp;
+ UUID_node node;
+ ACE_UINT16 clockSequence;
+ };
+
+ /// Obtain a UUID timestamp. Compensate for the fact that the time
+ /// obtained from getSystem time has a resolution less than 100ns.
void get_timestamp (UUID_time& timestamp);
- /// 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
+ /// 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
/// the Christian calendar).
- void get_systemtime( UUID_time& timeNow);
+ void get_systemtime( UUID_time& timeNow);
- /// The UUID generator persistent state.
- UUID_State uuid_state_;
+ /// The UUID generator persistent state.
+ UUID_State uuid_state_;
- ACE_SYNCH_MUTEX* lock_;
- int destroy_lock_;
-};
+ ACE_SYNCH_MUTEX* lock_;
+ int destroy_lock_;
+ };
-typedef ACE_Singleton <ACE_UUID_Generator, ACE_SYNCH_MUTEX> ACE_UUID_GENERATOR;
+ typedef ACE_Singleton <UUID_Generator, ACE_SYNCH_MUTEX> UUID_GENERATOR;
+
+};
#if defined (__ACE_INLINE__)
-#include "ace/UUID.i"
+#include "ace/UUID.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif // ACE_UUID_H
-
-
-
-
-
-
-
-
-
-
diff --git a/ace/UUID.i b/ace/UUID.i
deleted file mode 100644
index 29f22a517fb..00000000000
--- a/ace/UUID.i
+++ /dev/null
@@ -1,211 +0,0 @@
-//$Id$
-// -*- C++ -*-
-
-/// Data Members for Class Attributes
-ACE_INLINE ACE_UINT32
-ACE_UUID::timeLow (void)
-{
- return this->timeLow_;
-}
-
-ACE_INLINE void
-ACE_UUID::timeLow (ACE_UINT32 timelow)
-{
- this->timeLow_ = timelow;
-}
-
-ACE_INLINE ACE_UINT16
-ACE_UUID::timeMid (void)
-{
- return this->timeMid_;
-}
-
-ACE_INLINE void
-ACE_UUID::timeMid (ACE_UINT16 time_mid)
-{
- this->timeMid_ = time_mid;
-}
-
-ACE_INLINE ACE_UINT16
-ACE_UUID::timeHiAndVersion (void)
-{
- return this->timeHiAndVersion_;
-}
-
-ACE_INLINE void
-ACE_UUID::timeHiAndVersion (ACE_UINT16 timeHiAndVersion)
-{
- this->timeHiAndVersion_ = timeHiAndVersion;
-}
-
-ACE_INLINE u_char
-ACE_UUID::clockSeqHiAndReserved (void)
-{
- return this->clockSeqHiAndReserved_;
-}
-
-ACE_INLINE void
-ACE_UUID::clockSeqHiAndReserved (u_char clockSeqHiAndReserved)
-{
- this->clockSeqHiAndReserved_ = clockSeqHiAndReserved;
-}
-
-ACE_INLINE u_char
-ACE_UUID::clockSeqLow (void)
-{
- return this->clockSeqLow_;
-}
-
-ACE_INLINE void
-ACE_UUID::clockSeqLow (u_char clockSeqLow)
-{
- this->clockSeqLow_ = clockSeqLow;
-}
-
-ACE_INLINE UUID_node*
-ACE_UUID::node (void)
-{
- return this->node_;
-}
-
-ACE_INLINE void
-ACE_UUID::node (UUID_node* node)
-{
- if (node_release_ == 1)
- delete node_;
-
- this->node_ = node;
- node_release_ = 0;
-}
-
-ACE_INLINE ACE_CString*
-ACE_UUID::thr_id (void)
-{
- return &this->thr_id_;
-}
-
-ACE_INLINE void
-ACE_UUID::thr_id (char* thr_id)
-{
- this->thr_id_ = thr_id;
-}
-
-ACE_INLINE ACE_CString*
-ACE_UUID::pid (void)
-{
- return &this->pid_;
-}
-
-ACE_INLINE void
-ACE_UUID::pid (char* pid)
-{
- this->pid_ = pid;
-}
-
-ACE_INLINE ACE_UUID&
-ACE_UUID::operator = (const ACE_UUID &right)
-{
- *this = right;
- return *this;
-}
-
-ACE_INLINE bool
-ACE_UUID::operator == (const ACE_UUID &right) const
-{
- ACE_UUID rt (right);
- if ((timeLow_ != rt.timeLow ()) ||
- (timeMid_ != rt.timeMid ()) ||
- (timeHiAndVersion_ != rt.timeHiAndVersion ()) ||
- (clockSeqHiAndReserved_ != rt.clockSeqHiAndReserved ()) ||
- (clockSeqLow_ != rt.clockSeqLow ()) ||
- (node_ != rt.node ()))
- {
- return false;
- }
-
- return true;
-}
-
-ACE_INLINE bool
-ACE_UUID::operator != (const ACE_UUID &right) const
-{
- return !(*this == right);
-}
-
-ACE_INLINE bool
-ACE_UUID::operator < (const ACE_UUID &rt) const
-{
- ACE_UUID right (rt);
- if ((timeLow_ < right.timeLow ()) ||
- (timeMid_ < right.timeMid ()) ||
- (timeHiAndVersion_ < right.timeHiAndVersion ()) ||
- (clockSeqHiAndReserved_ < right.clockSeqHiAndReserved ()) ||
- (clockSeqLow_ < right.clockSeqLow ()) ||
- (node_ < right.node ()))
- {
- return true;
- }
-
- return false;
-}
-
-ACE_INLINE bool
-ACE_UUID::operator > (const ACE_UUID &right) const
-{
- return right < *this;
-}
-
-ACE_INLINE bool
-ACE_UUID::operator <= (const ACE_UUID &right) const
-{
- return !(*this > right);
-}
-
-ACE_INLINE bool
-ACE_UUID::operator >= (const ACE_UUID &right) const
-{
- return !(*this < right);
-}
-
-ACE_INLINE UUID_node&
-UUID_node::operator = (const UUID_node &right)
-{
- *this = right;
- return *this;
-}
-
-ACE_INLINE bool
-UUID_node::operator == (const UUID_node& rt) const
-{
- UUID_node right = rt;
- for (size_t i = 0; i < NODE_ID_SIZE; ++i)
- {
- if (nodeID_ [i] != right.nodeID ()[i])
- {
- return false;
- }
- }
- return true;
-}
-
-ACE_INLINE bool
-UUID_node::operator != (const UUID_node& right) const
-{
- return !(*this == right);
-}
-
-ACE_INLINE bool
-UUID_node::operator < (const UUID_node& rt) const
-{
- UUID_node right = rt;
- for (size_t i = 0; i < NODE_ID_SIZE; ++i)
- if (nodeID_ [i] < right.nodeID ()[i])
- return true;
-
- return false;
-}
-
-
-
-
-
diff --git a/ace/UUID.inl b/ace/UUID.inl
new file mode 100644
index 00000000000..dcf060520ce
--- /dev/null
+++ b/ace/UUID.inl
@@ -0,0 +1,210 @@
+//$Id$
+// -*- C++ -*-
+
+namespace ACE_Utils
+{
+
+ /// Data Members for Class Attributes
+ ACE_INLINE ACE_UINT32
+ UUID::timeLow (void)
+ {
+ return this->timeLow_;
+ }
+
+ ACE_INLINE void
+ UUID::timeLow (ACE_UINT32 timelow)
+ {
+ this->timeLow_ = timelow;
+ }
+
+ ACE_INLINE ACE_UINT16
+ UUID::timeMid (void)
+ {
+ return this->timeMid_;
+ }
+
+ ACE_INLINE void
+ UUID::timeMid (ACE_UINT16 time_mid)
+ {
+ this->timeMid_ = time_mid;
+ }
+
+ ACE_INLINE ACE_UINT16
+ UUID::timeHiAndVersion (void)
+ {
+ return this->timeHiAndVersion_;
+ }
+
+ ACE_INLINE void
+ UUID::timeHiAndVersion (ACE_UINT16 timeHiAndVersion)
+ {
+ this->timeHiAndVersion_ = timeHiAndVersion;
+ }
+
+ ACE_INLINE u_char
+ UUID::clockSeqHiAndReserved (void)
+ {
+ return this->clockSeqHiAndReserved_;
+ }
+
+ ACE_INLINE void
+ UUID::clockSeqHiAndReserved (u_char clockSeqHiAndReserved)
+ {
+ this->clockSeqHiAndReserved_ = clockSeqHiAndReserved;
+ }
+
+ ACE_INLINE u_char
+ UUID::clockSeqLow (void)
+ {
+ return this->clockSeqLow_;
+ }
+
+ ACE_INLINE void
+ UUID::clockSeqLow (u_char clockSeqLow)
+ {
+ this->clockSeqLow_ = clockSeqLow;
+ }
+
+ ACE_INLINE UUID_node*
+ UUID::node (void)
+ {
+ return this->node_;
+ }
+
+ ACE_INLINE void
+ UUID::node (UUID_node* node)
+ {
+ if (node_release_ == 1)
+ delete node_;
+
+ this->node_ = node;
+ node_release_ = 0;
+ }
+
+ ACE_INLINE ACE_CString*
+ UUID::thr_id (void)
+ {
+ return &this->thr_id_;
+ }
+
+ ACE_INLINE void
+ UUID::thr_id (char* thr_id)
+ {
+ this->thr_id_ = thr_id;
+ }
+
+ ACE_INLINE ACE_CString*
+ UUID::pid (void)
+ {
+ return &this->pid_;
+ }
+
+ ACE_INLINE void
+ UUID::pid (char* pid)
+ {
+ this->pid_ = pid;
+ }
+
+ ACE_INLINE UUID&
+ UUID::operator = (const UUID &right)
+ {
+ *this = right;
+ return *this;
+ }
+
+ ACE_INLINE bool
+ UUID::operator == (const UUID &right) const
+ {
+ UUID rt (right);
+ if ((timeLow_ != rt.timeLow ()) ||
+ (timeMid_ != rt.timeMid ()) ||
+ (timeHiAndVersion_ != rt.timeHiAndVersion ()) ||
+ (clockSeqHiAndReserved_ != rt.clockSeqHiAndReserved ()) ||
+ (clockSeqLow_ != rt.clockSeqLow ()) ||
+ (node_ != rt.node ()))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ ACE_INLINE bool
+ UUID::operator != (const UUID &right) const
+ {
+ return !(*this == right);
+ }
+
+ ACE_INLINE bool
+UUID::operator < (const UUID &rt) const
+ {
+ UUID right (rt);
+ if ((timeLow_ < right.timeLow ()) ||
+ (timeMid_ < right.timeMid ()) ||
+ (timeHiAndVersion_ < right.timeHiAndVersion ()) ||
+ (clockSeqHiAndReserved_ < right.clockSeqHiAndReserved ()) ||
+ (clockSeqLow_ < right.clockSeqLow ()) ||
+ (node_ < right.node ()))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ACE_INLINE bool
+ UUID::operator > (const UUID &right) const
+ {
+ return right < *this;
+ }
+
+ ACE_INLINE bool
+ UUID::operator <= (const UUID &right) const
+ {
+ return !(*this > right);
+ }
+
+ ACE_INLINE bool
+ UUID::operator >= (const UUID &right) const
+ {
+ return !(*this < right);
+ }
+
+ ACE_INLINE UUID_node&
+ UUID_node::operator = (const UUID_node &right)
+ {
+ *this = right;
+ return *this;
+ }
+
+ ACE_INLINE bool
+ UUID_node::operator == (const UUID_node& rt) const
+ {
+ UUID_node right = rt;
+ for (size_t i = 0; i < NODE_ID_SIZE; ++i)
+ {
+ if (nodeID_ [i] != right.nodeID ()[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ ACE_INLINE bool
+ UUID_node::operator != (const UUID_node& right) const
+ {
+ return !(*this == right);
+ }
+
+ ACE_INLINE bool
+ UUID_node::operator < (const UUID_node& rt) const
+ {
+ UUID_node right = rt;
+ for (size_t i = 0; i < NODE_ID_SIZE; ++i)
+ if (nodeID_ [i] < right.nodeID ()[i])
+ return true;
+
+ return false;
+ }
+};
diff --git a/tests/UUIDTest.cpp b/tests/UUIDTest.cpp
index 3a034e65579..3174aeeaae5 100644
--- a/tests/UUIDTest.cpp
+++ b/tests/UUIDTest.cpp
@@ -17,7 +17,7 @@ int
Tester::init (void)
{
///Initialise the UUID Generator
- ACE_UUID_GENERATOR::instance ()->init ();
+ ACE_Utils::UUID_GENERATOR::instance ()->init ();
return 0;
}
@@ -25,30 +25,31 @@ int
Tester::test (void)
{
// Generate UUID
- ACE_UUID* uuid = ACE_UUID_GENERATOR::instance ()->generateUUID ();
+ ACE_Utils::UUID* uuid = ACE_Utils::UUID_GENERATOR::instance ()->generateUUID ();
ACE_CString uuid_str (uuid->to_string ()->c_str ());
ACE_DEBUG ((LM_DEBUG,
- "Generated UUID\n %s\n",
- uuid_str.c_str ()));
+ "Generated UUID\n %s\n",
+ uuid_str.c_str ()));
delete uuid;
// Construct UUID from string
- ACE_UUID new_uuid (uuid_str);
+ ACE_Utils::UUID new_uuid (uuid_str);
ACE_DEBUG ((LM_DEBUG,
- "UUID Constructed from above Generated UUID\n %s\n",
- new_uuid.to_string ()->c_str ()));
+ "UUID Constructed from above Generated UUID\n %s\n",
+ new_uuid.to_string ()->c_str ()));
// Generate UUID with process and thread ids.
- ACE_UUID* uuid_with_tp_id = ACE_UUID_GENERATOR::instance ()->generateUUID (0x0001, 0xc0);
+ ACE_Utils::UUID* uuid_with_tp_id =
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (0x0001, 0xc0);
ACE_DEBUG ((LM_DEBUG,
- "UUID with Thread and Process ID\n %s\n",
- uuid_with_tp_id->to_string ()->c_str ()));
+ "UUID with Thread and Process ID\n %s\n",
+ uuid_with_tp_id->to_string ()->c_str ()));
// Construct UUID from string
- ACE_UUID new_uuid_with_tp_id (uuid_with_tp_id->to_string ()->c_str ());
+ ACE_Utils::UUID new_uuid_with_tp_id (uuid_with_tp_id->to_string ()->c_str ());
ACE_DEBUG ((LM_DEBUG,
- "UUID with Thread and Process ID reconstructed from above UUID \n %s\n",
- new_uuid_with_tp_id.to_string ()->c_str ()));
+ "UUID with Thread and Process ID reconstructed from above UUID \n %s\n",
+ new_uuid_with_tp_id.to_string ()->c_str ()));
delete uuid_with_tp_id;
return 0;
@@ -64,7 +65,7 @@ int run_main(int, ACE_TCHAR* [])
{
ACE_DEBUG((LM_DEBUG,
- "UUIDTest: Tester::init failed\n"));
+ "UUIDTest: Tester::init failed\n"));
return -1;
}
@@ -73,16 +74,15 @@ int run_main(int, ACE_TCHAR* [])
if (testRetValue == 0)
{
ACE_DEBUG((LM_DEBUG,
- "UUIDTest succeeded\n"));
+ "UUIDTest succeeded\n"));
}
else
{
ACE_DEBUG((LM_DEBUG,
- "UUIDTest failed\n"));
+ "UUIDTest failed\n"));
}
ACE_END_TEST;
return testRetValue;
}
-