ACE_Utils::UUID Class Reference

#include <UUID.h>

Collaboration diagram for ACE_Utils::UUID:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 UUID (void)
 Constructor.

 UUID (const ACE_CString &uuidString)
 Construct a UUID from a string representation of an UUID.

 ~UUID (void)
ACE_UINT32 timeLow (void)
 Data Members for Class Attributes.

void timeLow (ACE_UINT32)
ACE_UINT16 timeMid (void)
void timeMid (ACE_UINT16)
ACE_UINT16 timeHiAndVersion (void)
void timeHiAndVersion (ACE_UINT16)
u_char clockSeqHiAndReserved (void)
void clockSeqHiAndReserved (u_char)
u_char clockSeqLow (void)
void clockSeqLow (u_char)
UUID_nodenode (void)
void node (UUID_node *)
ACE_CStringthr_id (void)
void thr_id (char *)
ACE_CStringpid (void)
void pid (char *)
const ACE_CStringto_string (void)
 Returns a string representation of the UUID.


Static Public Attributes

UUID NIL_UUID

Private Member Functions

 UUID (const UUID &)
 Relational Operations.

UUIDoperator= (const UUID &)

Private Attributes

ACE_UINT32 timeLow_
 Data Members for Class Attributes.

ACE_UINT16 timeMid_
ACE_UINT16 timeHiAndVersion_
u_char clockSeqHiAndReserved_
u_char clockSeqLow_
UUID_nodenode_
int node_release_
ACE_CString thr_id_
ACE_CString pid_
ACE_CStringas_string_

Constructor & Destructor Documentation

ACE_Utils::UUID::UUID void   ) 
 

Constructor.

Construct a nil UUID. Such a UUID has every one of it's data elements set to zero.

Definition at line 55 of file UUID.cpp.

References ACE_NEW, and node_release_.

00056     : timeLow_ (0),
00057       timeMid_ (0),
00058     timeHiAndVersion_ (0),
00059       clockSeqHiAndReserved_ (0),
00060       clockSeqLow_ (0),
00061       as_string_ (0)
00062   {
00063     ACE_NEW (node_,
00064              UUID_node);
00065 
00066     node_release_ = 1;
00067   }

ACE_Utils::UUID::UUID const ACE_CString uuid_string  ) 
 

Construct a UUID from a string representation of an UUID.

Special case for the nil UUID.

Support versions 1, 3, and 4 only

Definition at line 70 of file UUID.cpp.

References ACE_ASSERT, ACE_CString, ACE_DEBUG, ACE_NEW, ACE_String_Base< CHAR >::c_str(), clockSeqHiAndReserved(), clockSeqHiAndReserved_, clockSeqLow(), clockSeqLow_, ACE_String_Base< CHAR >::find(), ACE_String_Base< CHAR >::length(), LM_DEBUG, NIL_UUID, node_release_, ACE_Utils::UUID_node::nodeID(), ACE_Utils::UUID_node::NodeID, ssize_t, ACE_String_Base< CHAR >::substr(), timeHiAndVersion(), timeHiAndVersion_, timeLow(), timeLow_, timeMid(), timeMid_, and to_string().

00071     : timeLow_ (0),
00072       timeMid_ (0),
00073       timeHiAndVersion_ (0),
00074       clockSeqHiAndReserved_ (0),
00075       clockSeqLow_ (0),
00076       as_string_ (0)
00077   {
00078     ACE_NEW (node_,
00079              UUID_node);
00080 
00081     node_release_ = 1;
00082 
00083 
00084     if (uuid_string.length() < NIL_UUID.to_string ()->length ())
00085       {
00086         ACE_DEBUG ((LM_DEBUG,
00087                     "%N ACE_UUID::UUID - "
00088                     "IllegalArgument(incorrect string length)\n"));
00089         return;
00090       }
00091 
00092     /// Special case for the nil UUID.
00093     if (uuid_string == *NIL_UUID.to_string ())
00094       {
00095         bool copy_constructor_not_supported = false;
00096         ACE_ASSERT (copy_constructor_not_supported);
00097         //*this = NIL_UUID;
00098         ACE_UNUSED_ARG (copy_constructor_not_supported);
00099         return;
00100       }
00101 
00102     unsigned int timeLow;
00103     unsigned int timeMid;
00104     unsigned int timeHiAndVersion;
00105     unsigned int clockSeqHiAndReserved;
00106     unsigned int clockSeqLow;
00107     unsigned int node [UUID_node::NODE_ID_SIZE];
00108     char thr_pid_buf [BUFSIZ];
00109 
00110     if (uuid_string.length() == NIL_UUID.to_string()->length())
00111       {
00112         // This might seem quite strange this being in ACE, but it
00113         // seems to be a bit difficult to write a facade for ::sscanf
00114         // because some compilers dont support vsscanf, including
00115         // MSVC. It appears that most platforms support sscanf though
00116         // so we need to use it directly.
00117         const int nScanned =
00118           ::sscanf(uuid_string.c_str(),
00119                    "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
00120                    &timeLow,
00121                    &timeMid,
00122                    &timeHiAndVersion,
00123                    &clockSeqHiAndReserved,
00124                    &clockSeqLow,
00125                    &node[0],
00126                    &node[1],
00127                    &node[2],
00128                    &node[3],
00129                    &node[4],
00130                    &node[5]
00131                    );
00132 
00133         if (nScanned != 11)
00134           {
00135             ACE_DEBUG ((LM_DEBUG,
00136                         "UUID::UUID - "
00137                         "IllegalArgument(invalid string representation)\n"));
00138             return;
00139           }
00140       }
00141     else
00142       {
00143         const int nScanned =
00144           ::sscanf (uuid_string.c_str(),
00145                     "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s",
00146                     &timeLow,
00147                     &timeMid,
00148                     &timeHiAndVersion,
00149                     &clockSeqHiAndReserved,
00150                     &clockSeqLow,
00151                     &node[0],
00152                     &node[1],
00153                     &node[2],
00154                     &node[3],
00155                     &node[4],
00156                     &node[5],
00157                     thr_pid_buf
00158                     );
00159 
00160         if (nScanned != 12)
00161           {
00162             ACE_DEBUG ((LM_DEBUG,
00163                         "ACE_UUID::ACE_UUID - "
00164                         "IllegalArgument(invalid string representation)\n"));
00165             return;
00166           }
00167       }
00168 
00169     this->timeLow_ = static_cast<ACE_UINT32> (timeLow);
00170     this->timeMid_ = static_cast<ACE_UINT16> (timeMid);
00171     this->timeHiAndVersion_ = static_cast<ACE_UINT16> (timeHiAndVersion);
00172     this->clockSeqHiAndReserved_ = static_cast<u_char> (clockSeqHiAndReserved);
00173     this->clockSeqLow_ = static_cast<u_char> (clockSeqLow);
00174 
00175     UUID_node::NodeID nodeID;
00176     for (int i = 0; i < UUID_node::NODE_ID_SIZE; ++i)
00177       nodeID [i] = static_cast<u_char> (node[i]);
00178 
00179     this->node_->nodeID (nodeID);
00180 
00181     // Support varient 10- only
00182     if ((this->clockSeqHiAndReserved_ & 0xc0) != 0x80 && (this->clockSeqHiAndReserved_ & 0xc0) != 0xc0)
00183       {
00184         ACE_DEBUG ((LM_DEBUG,
00185                     "ACE_UUID_Impl::ACE_UUID_Impl - "
00186                     "IllegalArgument(unsupported variant)\n"));
00187         return;
00188       }
00189 
00190     /// Support versions 1, 3, and 4 only
00191     ACE_UINT16 V1 = this->timeHiAndVersion_;
00192 
00193     if ((V1 & 0xF000) != 0x1000 &&
00194         (V1 & 0xF000) != 0x3000 &&
00195       (V1 & 0xF000) != 0x4000)
00196       {
00197         ACE_DEBUG ((LM_DEBUG,
00198                     "ACE_UUID::ACE_UUID - "
00199                     "IllegalArgument(unsupported version)\n"));
00200         return;
00201       }
00202     if ((this->clockSeqHiAndReserved_ & 0xc0) == 0xc0)
00203       {
00204         if (uuid_string.length() == NIL_UUID.to_string()->length())
00205           {
00206             ACE_DEBUG ((LM_DEBUG,
00207                       "ACE_UUID::ACE_UUID - "
00208                         "IllegalArgument (Missing Thread and Process Id)\n"));
00209             return;
00210           }
00211         ACE_CString thr_pid_str (thr_pid_buf);
00212         ssize_t pos = thr_pid_str.find ('-');
00213         if (pos == -1)
00214           ACE_DEBUG ((LM_DEBUG,
00215                       "ACE_UUID::ACE_UUID - "
00216                       "IllegalArgument (Thread and Process Id format incorrect)\n"));
00217 
00218         this->thr_id_ = thr_pid_str.substr (0, pos);
00219       this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1);
00220       }
00221   }

ACE_Utils::UUID::~UUID void   ) 
 

Definition at line 223 of file UUID.cpp.

References as_string_, and node_release_.

00224   {
00225     if (node_release_)
00226       delete node_;
00227 
00228     if (as_string_ != 0)
00229       delete as_string_;
00230   }

ACE_Utils::UUID::UUID const UUID  )  [private]
 

Relational Operations.


Member Function Documentation

ACE_INLINE void ACE_Utils::UUID::clockSeqHiAndReserved u_char   ) 
 

Definition at line 54 of file UUID.inl.

References clockSeqHiAndReserved_.

00055   {
00056     this->clockSeqHiAndReserved_ = clockSeqHiAndReserved;
00057   }

ACE_INLINE u_char ACE_Utils::UUID::clockSeqHiAndReserved void   ) 
 

Definition at line 48 of file UUID.inl.

References clockSeqHiAndReserved_.

Referenced by ACE_Utils::UUID_Generator::generateUUID(), and UUID().

00049   {
00050     return this->clockSeqHiAndReserved_;
00051   }

ACE_INLINE void ACE_Utils::UUID::clockSeqLow u_char   ) 
 

Definition at line 66 of file UUID.inl.

References clockSeqLow_.

00067   {
00068     this->clockSeqLow_ = clockSeqLow;
00069   }

ACE_INLINE u_char ACE_Utils::UUID::clockSeqLow void   ) 
 

Definition at line 60 of file UUID.inl.

References clockSeqLow_.

Referenced by ACE_Utils::UUID_Generator::generateUUID(), and UUID().

00061   {
00062     return this->clockSeqLow_;
00063   }

ACE_INLINE void ACE_Utils::UUID::node UUID_node  ) 
 

Definition at line 78 of file UUID.inl.

References node_release_.

00079   {
00080     if (node_release_ == 1)
00081     delete node_;
00082 
00083     this->node_ = node;
00084     node_release_ = 0;
00085   }

ACE_INLINE UUID_node * ACE_Utils::UUID::node void   ) 
 

Definition at line 72 of file UUID.inl.

Referenced by ACE_Utils::UUID_Generator::generateUUID().

00073   {
00074     return this->node_;
00075   }

UUID& ACE_Utils::UUID::operator= const UUID  )  [private]
 

ACE_INLINE void ACE_Utils::UUID::pid char *   ) 
 

Definition at line 106 of file UUID.inl.

00107   {
00108     this->pid_ = pid;
00109   }

ACE_INLINE ACE_CString * ACE_Utils::UUID::pid void   ) 
 

Definition at line 100 of file UUID.inl.

Referenced by ACE_Utils::UUID_Generator::generateUUID().

00101   {
00102     return &this->pid_;
00103   }

ACE_INLINE void ACE_Utils::UUID::thr_id char *   ) 
 

Definition at line 94 of file UUID.inl.

00095   {
00096     this->thr_id_ = thr_id;
00097   }

ACE_INLINE ACE_CString * ACE_Utils::UUID::thr_id void   ) 
 

Definition at line 88 of file UUID.inl.

Referenced by ACE_Utils::UUID_Generator::generateUUID().

00089   {
00090     return &this->thr_id_;
00091   }

ACE_INLINE void ACE_Utils::UUID::timeHiAndVersion ACE_UINT16   ) 
 

Definition at line 42 of file UUID.inl.

References timeHiAndVersion_.

00043   {
00044     this->timeHiAndVersion_ = timeHiAndVersion;
00045   }

ACE_INLINE ACE_UINT16 ACE_Utils::UUID::timeHiAndVersion void   ) 
 

Definition at line 36 of file UUID.inl.

References timeHiAndVersion_.

Referenced by ACE_Utils::UUID_Generator::generateUUID(), and UUID().

00037   {
00038     return this->timeHiAndVersion_;
00039   }

ACE_INLINE void ACE_Utils::UUID::timeLow ACE_UINT32   ) 
 

Definition at line 18 of file UUID.inl.

References timeLow_.

00019   {
00020     this->timeLow_ = timelow;
00021   }

ACE_INLINE ACE_UINT32 ACE_Utils::UUID::timeLow void   ) 
 

Data Members for Class Attributes.

Definition at line 12 of file UUID.inl.

References timeLow_.

Referenced by ACE_Utils::UUID_Generator::generateUUID(), and UUID().

00013   {
00014     return this->timeLow_;
00015   }

ACE_INLINE void ACE_Utils::UUID::timeMid ACE_UINT16   ) 
 

Definition at line 30 of file UUID.inl.

References timeMid_.

00031   {
00032     this->timeMid_ = time_mid;
00033   }

ACE_INLINE ACE_UINT16 ACE_Utils::UUID::timeMid void   ) 
 

Definition at line 24 of file UUID.inl.

References timeMid_.

Referenced by ACE_Utils::UUID_Generator::generateUUID(), and UUID().

00025   {
00026     return this->timeMid_;
00027   }

const ACE_CString * ACE_Utils::UUID::to_string void   ) 
 

Returns a string representation of the UUID.

Only compute the string representation once.

Definition at line 233 of file UUID.cpp.

References ACE_CString, ACE_NEW_RETURN, as_string_, ACE_String_Base< CHAR >::c_str(), ACE_String_Base< CHAR >::length(), ACE_Utils::UUID_node::nodeID(), and ACE_OS::sprintf().

Referenced by UUID().

00234   {
00235     /// Only compute the string representation once.
00236     if (as_string_ == 0)
00237       {
00238         // Get a buffer exactly the correct size. Use the nil UUID as a
00239         // gauge.  Don't forget the trailing nul.
00240         size_t UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length ();
00241         char *buf;
00242 
00243         if ((thr_id_.length () != 0) && (pid_.length () != 0))
00244           {
00245             UUID_STRING_LENGTH += 2; //for '-'
00246             ACE_NEW_RETURN (buf,
00247                             char[UUID_STRING_LENGTH + 1],
00248                             0);
00249 
00250             ACE_OS::sprintf(buf,
00251                             "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s",
00252                             this->timeLow_,
00253                             this->timeMid_,
00254                             this->timeHiAndVersion_,
00255                             this->clockSeqHiAndReserved_,
00256                             this->clockSeqLow_,
00257                             (this->node_->nodeID ()) [0],
00258                             (this->node_->nodeID ()) [1],
00259                             (this->node_->nodeID ()) [2],
00260                             (this->node_->nodeID ()) [3],
00261                             (this->node_->nodeID ()) [4],
00262                             (this->node_->nodeID ()) [5],
00263                             thr_id_.c_str (),
00264                             pid_.c_str ()
00265                             );
00266           }
00267         else
00268           {
00269             ACE_NEW_RETURN (buf,
00270                             char[UUID_STRING_LENGTH + 1],
00271                             0);
00272 
00273             ACE_OS::sprintf (buf,
00274                              "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
00275                              this->timeLow_,
00276                              this->timeMid_,
00277                              this->timeHiAndVersion_,
00278                              this->clockSeqHiAndReserved_,
00279                              this->clockSeqLow_,
00280                              (this->node_->nodeID ()) [0],
00281                              (this->node_->nodeID ()) [1],
00282                              (this->node_->nodeID ()) [2],
00283                              (this->node_->nodeID ()) [3],
00284                              (this->node_->nodeID ()) [4],
00285                              (this->node_->nodeID ()) [5]
00286                              );
00287           }
00288 
00289         ACE_NEW_RETURN (this->as_string_,
00290                         ACE_CString (buf, UUID_STRING_LENGTH),
00291                         0);
00292         delete [] buf;
00293       }
00294 
00295     return as_string_;
00296   }


Member Data Documentation

ACE_CString* ACE_Utils::UUID::as_string_ [private]
 

The string representation of the UUID. This is created and updated only on demand.

Definition at line 148 of file UUID.h.

Referenced by to_string(), and ~UUID().

u_char ACE_Utils::UUID::clockSeqHiAndReserved_ [private]
 

Definition at line 139 of file UUID.h.

Referenced by clockSeqHiAndReserved(), and UUID().

u_char ACE_Utils::UUID::clockSeqLow_ [private]
 

Definition at line 140 of file UUID.h.

Referenced by clockSeqLow(), and UUID().

UUID ACE_Utils::UUID::NIL_UUID [static]
 

Definition at line 51 of file UUID.cpp.

Referenced by UUID().

UUID_node* ACE_Utils::UUID::node_ [private]
 

Definition at line 141 of file UUID.h.

int ACE_Utils::UUID::node_release_ [private]
 

Definition at line 142 of file UUID.h.

Referenced by node(), UUID(), and ~UUID().

ACE_CString ACE_Utils::UUID::pid_ [private]
 

Definition at line 144 of file UUID.h.

ACE_CString ACE_Utils::UUID::thr_id_ [private]
 

Definition at line 143 of file UUID.h.

ACE_UINT16 ACE_Utils::UUID::timeHiAndVersion_ [private]
 

Definition at line 138 of file UUID.h.

Referenced by timeHiAndVersion(), and UUID().

ACE_UINT32 ACE_Utils::UUID::timeLow_ [private]
 

Data Members for Class Attributes.

Definition at line 136 of file UUID.h.

Referenced by timeLow(), and UUID().

ACE_UINT16 ACE_Utils::UUID::timeMid_ [private]
 

Definition at line 137 of file UUID.h.

Referenced by timeMid(), and UUID().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:34:02 2006 for ACE by doxygen 1.3.6