qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r809781 - in /qpid/trunk/qpid/cpp: include/qpid/framing/Uuid.h include/qpid/sys/uuid.h include/qpid/sys/windows/uuid.h src/Makefile.am src/qpid/framing/Uuid.cpp src/qpid/sys/uuid.h src/qpid/sys/windows/uuid.h src/tests/txtest.cpp
Date Mon, 31 Aug 2009 23:41:54 GMT
Author: astitcher
Date: Mon Aug 31 23:41:53 2009
New Revision: 809781

URL: http://svn.apache.org/viewvc?rev=809781&view=rev
Log:
Working towards abstracting away the cross platform uuid mess:
* Stop including indirectly from uuid.h in qpid/framing/Uuid.h
  and move inline definitions there into the implementation file

Added:
    qpid/trunk/qpid/cpp/src/qpid/sys/uuid.h
      - copied, changed from r809772, qpid/trunk/qpid/cpp/include/qpid/sys/uuid.h
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.h
      - copied, changed from r809772, qpid/trunk/qpid/cpp/include/qpid/sys/windows/uuid.h
Removed:
    qpid/trunk/qpid/cpp/include/qpid/sys/uuid.h
    qpid/trunk/qpid/cpp/include/qpid/sys/windows/uuid.h
Modified:
    qpid/trunk/qpid/cpp/include/qpid/framing/Uuid.h
    qpid/trunk/qpid/cpp/src/Makefile.am
    qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp
    qpid/trunk/qpid/cpp/src/tests/txtest.cpp

Modified: qpid/trunk/qpid/cpp/include/qpid/framing/Uuid.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/framing/Uuid.h?rev=809781&r1=809780&r2=809781&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/framing/Uuid.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/framing/Uuid.h Mon Aug 31 23:41:53 2009
@@ -20,7 +20,6 @@
  */
 
 #include "qpid/CommonImportExport.h"
-#include "qpid/sys/uuid.h"
 #include "qpid/sys/IntegerTypes.h"
 
 #include <boost/array.hpp>
@@ -38,33 +37,31 @@
  *
  * Full value semantics, operators ==, < etc.  are provided by
  * boost::array so Uuid can be the key type in a map etc.
+ *
+ * TODO: change this implementation as it leaks boost into the
+ * client API
  */
 struct Uuid : public boost::array<uint8_t, 16> {
     /** If unique is true, generate a unique ID else a null ID. */
-    Uuid(bool unique=false) { if (unique) generate(); else clear(); }
+    Uuid(bool unique=false);
 
     /** Copy from 16 bytes of data. */
-    Uuid(const uint8_t* data) { assign(data); }
+    Uuid(const uint8_t* data);
+
+    // Default op= and copy ctor are fine.
+    // boost::array gives us ==, < etc.
 
     /** Copy from 16 bytes of data. */
-    void assign(const uint8_t* data) {
-        uuid_copy(c_array(), data);
-    }
+    void assign(const uint8_t* data);
 
     /** Set to a new unique identifier. */
-    void generate() { uuid_generate(c_array()); }
+    void generate();
 
     /** Set to all zeros. */
-    void clear() { uuid_clear(c_array()); }
+    void clear();
 
     /** Test for null (all zeros). */
-    // Force int 0/!0 to false/true; avoids compile warnings.
-    bool isNull() {
-        return !!uuid_is_null(data());
-    }
-
-    // Default op= and copy ctor are fine.
-    // boost::array gives us ==, < etc.
+    bool isNull();
 
     QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const;
     QPID_COMMON_EXTERN void decode(framing::Buffer& buf);

Modified: qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/Makefile.am?rev=809781&r1=809780&r2=809781&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ qpid/trunk/qpid/cpp/src/Makefile.am Mon Aug 31 23:41:53 2009
@@ -54,7 +54,7 @@
   qpid/sys/windows/Time.cpp \
   ../include/qpid/sys/windows/Time.h \
   qpid/sys/windows/uuid.cpp \
-  ../include/qpid/sys/windows/uuid.h \
+  qpid/sys/windows/uuid.h \
   windows/QpiddBroker.cpp \
   qpid/broker/windows/BrokerDefaults.cpp \
   qpid/broker/windows/SaslAuthenticator.cpp
@@ -461,7 +461,8 @@
   qpid/sys/Timer.cpp				\
   qpid/sys/Timer.h				\
   qpid/sys/Waitable.h				\
-  qpid/sys/alloca.h
+  qpid/sys/alloca.h				\
+  qpid/sys/uuid.h
 
 if HAVE_SASL
 libqpidcommon_la_SOURCES += qpid/sys/cyrus/CyrusSecurityLayer.h
@@ -782,7 +783,6 @@
   ../include/qpid/sys/SystemInfo.h		\
   ../include/qpid/sys/Thread.h			\
   ../include/qpid/sys/Time.h			\
-  ../include/qpid/sys/uuid.h			\
   ../include/qpid/messaging/Address.h 		\
   ../include/qpid/messaging/Connection.h 	\
   ../include/qpid/messaging/Codec.h 	        \

Modified: qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp?rev=809781&r1=809780&r2=809781&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp Mon Aug 31 23:41:53 2009
@@ -17,6 +17,8 @@
  */
 
 #include "qpid/framing/Uuid.h"
+
+#include "qpid/sys/uuid.h"
 #include "qpid/Exception.h"
 #include "qpid/framing/Buffer.h"
 #include "qpid/framing/reply_exceptions.h"
@@ -28,6 +30,35 @@
 
 static const size_t UNPARSED_SIZE=36; 
 
+Uuid::Uuid(bool unique) {
+    if (unique) {
+        generate();
+    } else {
+        clear();
+    }
+}
+
+Uuid::Uuid(const uint8_t* data) {
+    assign(data);
+}
+
+void Uuid::assign(const uint8_t* data) {
+    uuid_copy(c_array(), data);
+}
+
+void Uuid::generate() {
+    uuid_generate(c_array());
+}
+
+void Uuid::clear() {
+    uuid_clear(c_array());
+}
+
+// Force int 0/!0 to false/true; avoids compile warnings.
+bool Uuid::isNull() {
+    return !!uuid_is_null(data());
+}
+
 void Uuid::encode(Buffer& buf) const {
     buf.putRawData(data(), size());
 }

Copied: qpid/trunk/qpid/cpp/src/qpid/sys/uuid.h (from r809772, qpid/trunk/qpid/cpp/include/qpid/sys/uuid.h)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/uuid.h?p2=qpid/trunk/qpid/cpp/src/qpid/sys/uuid.h&p1=qpid/trunk/qpid/cpp/include/qpid/sys/uuid.h&r1=809772&r2=809781&rev=809781&view=diff
==============================================================================
    (empty)

Copied: qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.h (from r809772, qpid/trunk/qpid/cpp/include/qpid/sys/windows/uuid.h)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.h?p2=qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.h&p1=qpid/trunk/qpid/cpp/include/qpid/sys/windows/uuid.h&r1=809772&r2=809781&rev=809781&view=diff
==============================================================================
    (empty)

Modified: qpid/trunk/qpid/cpp/src/tests/txtest.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/txtest.cpp?rev=809781&r1=809780&r2=809781&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/txtest.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/txtest.cpp Mon Aug 31 23:41:53 2009
@@ -33,7 +33,7 @@
 #include "qpid/client/SubscriptionManager.h"
 #include "qpid/framing/Array.h"
 #include "qpid/framing/Buffer.h"
-#include "qpid/sys/uuid.h"
+#include "qpid/framing/Uuid.h"
 #include "qpid/sys/Thread.h"
 
 using namespace qpid;
@@ -130,8 +130,6 @@
     std::string src;
     std::string dest;
     Thread thread;
-    uuid_t uuid;
-    char uuidStr[37]; // Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + trailing \0
     framing::Xid xid;
 
     Transfer(const std::string& to, const std::string& from) : src(to), dest(from),
xid(0x4c414e47, "", from) {}
@@ -184,9 +182,8 @@
     }
 
     void setNewXid(framing::Xid& xid) {
-        ::uuid_generate(uuid);
-        ::uuid_unparse(uuid, uuidStr);
-        xid.setGlobalId(uuidStr);
+        framing::Uuid uuid(true);
+        xid.setGlobalId(uuid.str());
     }
 };
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message