activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r397654 [10/12] - in /incubator/activemq/trunk/openwire-cpp: ./ src/ src/command/ src/gram/ src/gram/java/ src/gram/java/org/ src/gram/java/org/apache/ src/gram/java/org/apache/activemq/ src/gram/java/org/apache/activemq/openwire/ src/gram/...
Date Thu, 27 Apr 2006 21:59:44 GMT
Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Socket.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Socket.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Socket.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Socket.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Socket_hpp_
+#define Ppr_Socket_hpp_
+
+#include "ISocket.hpp"
+#ifndef unix
+#include <Winsock2.h> // SOCKET
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace net
+    {
+      using namespace ifr;
+
+/*
+ *
+ */
+class Socket : public ISocket
+{
+public:
+#ifdef unix
+    typedef int SocketHandle;
+#else
+    typedef SOCKET SocketHandle;
+#endif
+    static const SocketHandle INVALID_SOCKET_HANDLE = (SocketHandle) -1;
+private:
+    SocketHandle socketHandle;
+public:
+    /** Construct a non-connected socket.
+    */
+    Socket ();
+    /** Construct a connected or bound socket based on given
+        socket handle.
+    */
+    Socket (SocketHandle socketHandle);
+    /** Destruct.
+        Releases the socket handle but not
+        gracefully shut down the connection.
+    */
+    virtual ~Socket();
+public:
+    /**
+    */
+    virtual void connect (const char* host, int port) throw (SocketException);
+    /**
+    */
+    virtual void setSoTimeout (int millisec) throw (SocketException);
+    /**
+    */
+    virtual int  getSoTimeout () const;
+    /**
+    */
+    virtual int  receive (char* buff, int size) throw (SocketException);
+    /**
+    */
+    virtual int  send (const unsigned char* buff, int size) throw (SocketException);
+    /**
+    */
+    virtual int  send (const char* buff, int size) throw (SocketException);
+    /**
+    */
+    virtual void close ();
+    /**
+    */
+    virtual bool isConnected() const;
+protected:
+    SocketHandle getSocketHandle () {
+        return socketHandle;
+    }
+    void setSocketHandle (SocketHandle socketHandle) {
+        this->socketHandle = socketHandle;
+    }
+public:
+#ifndef unix
+    // WINDOWS needs initialization of winsock
+    class StaticSocketInitializer {
+    private:
+        p<SocketException> socketInitError;
+    public:
+        p<SocketException> getSocketInitError () {
+            return socketInitError;
+        }
+        StaticSocketInitializer ();
+        virtual ~StaticSocketInitializer ();
+    };
+    static StaticSocketInitializer staticSocketInitializer;
+#endif
+
+};
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Socket_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketException.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketException.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketException.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketException.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_SocketException_hpp_
+#define Ppr_SocketException_hpp_
+
+#include <stdexcept>
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace net
+    {
+      using namespace std;
+
+/**
+ */
+class SocketException : public exception
+{
+protected:
+    string msg;
+public:
+    SocketException(const char* message) : msg (message) {};
+    virtual ~SocketException() throw() {}
+    virtual const char* what() const throw () {
+      return msg.c_str();
+    }
+} ;
+
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_SocketException_hpp_*/
+

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketFactory.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketFactory.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketFactory.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/SocketFactory.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_SocketFactory_hpp_
+#define Ppr_SocketFactory_hpp_
+
+#include "ppr/net/ISocketFactory.hpp"
+#include "ppr/net/Socket.hpp"
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace net
+    {
+      using namespace std;
+
+/*
+ *
+ */
+class SocketFactory : public ISocketFactory
+{
+public:
+    /** Creates an unconnected TCP/IP socket ready to call connect() on.
+    */
+    virtual p<ISocket> createSocket() {
+        return new Socket();
+    }
+};
+
+/* namespave */
+    }
+  }
+}
+
+#endif /*Ppr_SocketFactory_hpp_*/
+

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ppr/net/Uri.hpp"
+
+using namespace apache::ppr::net;
+
+#ifdef unix
+#define _stricmp strcasecmp
+#endif
+
+Uri::Uri (const string& absoluteUri) : port_(0), bits_ (IS_FAIL)
+{
+  if (absoluteUri.empty()) {
+    bits_ = IS_EMPTY;
+    return;
+  }
+  //
+  // scheme
+  //
+  size_t pColonSlashSlash = absoluteUri.find ("://");
+  if (pColonSlashSlash == absoluteUri.npos) return; // must contain "://"
+  scheme_ = absoluteUri.substr (0, pColonSlashSlash);
+  size_t pHost = pColonSlashSlash + 3; // strlen ("://")
+
+  //
+  // host, port, authority_
+  //
+  size_t pColonOrSlash = absoluteUri.find_first_of (":/", pHost);
+  if (pColonOrSlash != absoluteUri.npos && absoluteUri[pColonOrSlash] == ':') {
+    host_ = absoluteUri.substr (pHost, pColonOrSlash - pHost);
+    long port = atol(absoluteUri.substr (pColonOrSlash + 1).c_str());
+    if (port < 0 || port > 65535) return; // If port is present, it must be between 0 and 65535.
+    port_ = (unsigned short) port;
+    pColonOrSlash = absoluteUri.find ('/', pColonOrSlash + 1); // Make pColonOrSlash point to slash.
+    if (pColonOrSlash != absoluteUri.npos) {
+      authority_ = absoluteUri.substr (pHost, pColonOrSlash - pHost);
+    } else {
+      authority_ = absoluteUri.substr (pHost);
+    }
+  } else {
+    port_ = getDefaultPort (scheme_);
+    if (pColonOrSlash == absoluteUri.npos) {
+      host_ = absoluteUri.substr (pHost);
+    } else {
+      host_ = absoluteUri.substr (pHost, pColonOrSlash - pHost);
+    }
+    authority_ = host_;
+  }
+
+  //
+  // path
+  //
+  if (pColonOrSlash == absoluteUri.npos) {
+    path_ = "/";
+  } else {
+    size_t pQuery = absoluteUri.find ('?', pColonOrSlash);
+    if (pQuery == absoluteUri.npos) {
+      path_ = absoluteUri.substr (pColonOrSlash);
+    } else {
+      path_ = absoluteUri.substr (pColonOrSlash, pQuery - pColonOrSlash);
+      //
+      // query
+      //
+      query_ = absoluteUri.substr (pQuery + 1);
+    }
+  }
+
+  // isFail
+  if (!scheme_.empty() && !path_.empty()) {
+    bits_ = 0;
+  }
+}
+
+Uri::Uri (string uri, const Uri& baseUri) : port_(0), bits_ (IS_FAIL)
+{
+  if (uri[0] == '/') {
+    //
+    // uri is absolute path
+    //
+    *this = baseUri;
+    size_t pQuery = uri.find ('?');
+    if (pQuery == uri.npos) {
+      path_ = uri;
+      query_.clear();
+    } else {
+      path_ = uri.substr (0, pQuery);
+      query_ = uri.substr (pQuery + 1);
+    }
+  } else {
+    size_t pColonOrSlash = uri.find_first_of ("/:");
+    if (pColonOrSlash != uri.npos && uri[pColonOrSlash] == ':' && pColonOrSlash == uri.find ("://")) {
+      //
+      // uri is an Uri
+      //
+      *this = uri;
+    } else {
+      //
+      // uri is a relative path
+      //
+
+      // Copy everything from base Uri to this instance.
+      // We will change path and query only...
+      *this = baseUri;
+
+      // Resolve ".." and "." in beginning of uri:
+      // Check for last slash in base Uri (where to insert uri)
+      size_t pLastSlash = path_.rfind ('/');
+      while (uri.length() > 0 && uri[0] == '.') {
+        if (uri.length() == 1) {
+          // uri is exactly "."
+          uri.clear();
+          break;
+        } else if (uri[1] == '/') {
+          // uri begins with "./"
+          uri = uri.substr (2);
+        } else if (uri[1] == '.') {
+          //
+          // Uri begins with ".." but we dont know the next character...
+          //
+          if (uri.length() == 2) {
+            // uri is exactly ".."
+            uri.clear();
+            // Navigate upwards in directory tree (of path_)
+            if (pLastSlash != path_.npos && pLastSlash > 0) {
+              assert (string ("/1/2/").rfind ('/') == 4); // just to make sure how rfind() works...
+              assert (string ("/1/2/").rfind ('/', 4) == 4); // --""--
+              assert (string ("/1/2/").rfind ('/', 3) == 2); // --""--
+              assert (string ("/").rfind ('/', 0) == 0); // --""--
+              pLastSlash = path_.rfind ('/', pLastSlash - 1);
+            }
+            break;
+          } else if (uri[2] == '/') {
+            // uri begins with "../"
+            uri = uri.substr (3);
+            // Navigate upwards in directory tree (of path_)
+            if (pLastSlash != path_.npos && pLastSlash > 0) {
+              assert (string ("/1/2/").rfind ('/') == 4); // just to make sure how rfind() works...
+              assert (string ("/1/2/").rfind ('/', 4) == 4); // --""--
+              assert (string ("/1/2/").rfind ('/', 3) == 2); // --""--
+              assert (string ("/").rfind ('/', 0) == 0); // --""--
+              pLastSlash = path_.rfind ('/', pLastSlash - 1);
+            }
+          }
+        } 
+      }
+
+      // Check for query in given uri (in order to split path from query, as we do in this class)
+      size_t pQuery = uri.find ('?');
+
+      if (pQuery == uri.npos) {
+        // No query in the uri
+        if (pLastSlash != path_.npos) {
+          // Append URI after last slash in base Uri's path
+          path_ = path_.substr (0, pLastSlash + 1) + uri;
+        } else {
+          // No slash found in base Uri's path. Append a slash in beginning.
+          path_ = "/" + uri;
+        }
+        // Clear the query
+        query_.clear();
+      } else {
+        // Query in the uri
+        if (pLastSlash != path_.npos) {
+          // Append URI after last slash in base Uri's path
+          path_ = path_.substr (0, pLastSlash + 1) + uri.substr (0, pQuery);
+        } else {
+          // No slash found in base Uri's path. Append a slash in beginning.
+          path_ = "/" + uri.substr (0, pQuery);
+        }
+        // Get the query from uri.
+        query_ = uri.substr (pQuery + 1);
+      }
+      
+    }
+  }
+}
+
+unsigned short Uri::getDefaultPort (const string& scheme)
+{
+  if (_stricmp (scheme.c_str(), "http") == 0) {
+    return 80;
+  } else if (_stricmp (scheme.c_str(), "https") == 0) {
+    return 443;
+  } else if (_stricmp (scheme.c_str(), "ftp") == 0) {
+    return 21;
+  } else if (_stricmp (scheme.c_str(), "ssh") == 0) {
+    return 22;
+  } else if (_stricmp (scheme.c_str(), "telnet") == 0) {
+    return 23;
+  } else if (_stricmp (scheme.c_str(), "smtp") == 0) {
+    return 25;
+  } else if (_stricmp (scheme.c_str(), "pop3") == 0) {
+    return 110;
+  } else if (_stricmp (scheme.c_str(), "radius") == 0) {
+    return 1812;
+  } else {
+    return 0;
+  }
+}
+
+bool Uri::isSecure() const
+{
+  if (_stricmp (scheme_.c_str(), "https") == 0 ||
+      _stricmp (scheme_.c_str(), "ssh") == 0 ||
+      _stricmp (scheme_.c_str(), "ftps") == 0)
+  {
+    return true;
+  } else {
+    return false;
+  }
+}
+

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Uri_hpp_
+#define Ppr_Uri_hpp_
+
+#include <string>
+#include <assert.h>
+#include <stdlib.h>
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace net
+    {
+      using namespace std;
+
+/*
+ * Splits an Uri string into it's basic parts.
+ * @author David Fahlander, PortWise
+ */
+class Uri
+{
+public:
+  // Constructs an empty URI.
+  Uri() : port_(0), bits_ (IS_EMPTY) {};
+
+  // Constructs an URI based on given absolute URI string.
+  Uri(const string& absoluteUri);
+
+  /** Construct an Uri based on an URI and a base Uri.
+
+    Given URI can be a relative path, an absolute path or an entire Uri.
+    If given URI is an absolute URI (begins with <scheme> "://", baseUri is ignored.
+    If given URI begins with ".." or "." the constructed Uri will resolve the real
+    path without "." or "..".
+
+    @param uri URI relative to baseUri
+    @baseUri The Uri of the document that referred to given URI.
+  */
+  Uri (string uri, const Uri& baseUri);
+public:
+  /** Get scheme.
+  */
+  const string& scheme() const {return scheme_;}
+  /** Get host.
+  */
+  const string& host() const {return host_;}
+
+  /** Returns the port (if scheme supports port).
+    If the port was omitted in the string that constructed the URI, the default
+    port for that scheme is returned (if there is a default port for it). If no
+    default port exists for the scheme and port was omitted in the string that
+    constructed the URI, 0 is returned.
+
+    For example, the URI
+      http://127.0.0.1:8081/index.html has the port 8081 and the URI
+      http://www.apache.org/index.html has the port 80 (default HTTP port).
+
+    The default port-table is defined in Uri::getDefaultPort().
+  */
+  unsigned short port() const {return port_;}
+
+  /** Returns the authority.
+    The authority is equivalent to the host header when an HTTP URI is used. If a default
+    port is used, the port part of the authority may be omitted. For example, the URI
+      http://www.apache.org/index.html has the authority "www.apache.org" and the URI
+      http://127.0.0.1:8081/index.html has the authority "127.0.0.1:8081".
+  */
+  const string& authority() const {return authority_;}
+
+  /** Returns the path (without query).
+    If no path, an empty string is returned.
+  */
+  const string& path() const {return path_;}
+
+  /** Returns the query. If no query, an empty string is returned.
+  */
+  const string& query() const {return query_;}
+
+  /** Returns true if URI has a query.
+  */
+  bool hasQuery () const {return !query_.empty();}
+
+  /** Returns the path and query part of the URI.
+  */
+  string pathAndQuery() const {return (hasQuery() ? path() + "?" + query() : path());}
+
+  /** Returns true if the URI failed to be interpreted in any of the constructors used.
+  */
+  bool isFail () const { return ((bits_ & IS_FAIL) != 0); }
+
+  /** Returns true if the URI is empty.
+  */
+  bool isEmpty () const { return ((bits_ & IS_EMPTY) != 0); }
+
+  /** Returns true if the URI is a URL using a secure scheme such as https.
+  */
+  bool isSecure() const;
+
+  /** Converts this URI into a string.
+  */
+  string toString() const {
+    if (isEmpty() || isFail()) {
+      return "";
+    } else if (hasQuery()) {
+      return scheme() + "://" + authority() + path() + "?" + query();
+    } else {
+      return scheme() + "://" + authority() + path();
+    }
+  }
+public:
+  /** Returns the default port if given scheme is a protocol that is recognized
+      by this implementation.
+  */
+  static unsigned short getDefaultPort (const string& scheme);
+private:
+  string scheme_;
+  string host_;
+  unsigned short port_;
+  string authority_;
+  string path_;
+  string query_;
+private:
+  static const unsigned char IS_EMPTY = 0x01;
+  static const unsigned char IS_FAIL  = 0x02;
+  unsigned char bits_;
+};
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Uri_hpp_*/
+

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Semaphore.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Semaphore.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Semaphore.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Semaphore.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Semaphore_hpp_
+#define Ppr_Semaphore_hpp_
+
+#if defined MACOSX
+#include <errno.h>
+#include <time.h>
+#include <pthread.h>
+#elif defined(__unix__) || defined(unix)
+#ifndef unix
+#define unix
+#endif
+#include <errno.h>
+#include <time.h>
+#include <semaphore.h>
+#endif
+#if defined(WIN32) || defined(__CYGWIN__) && !defined unix
+#if ( !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400)
+#pragma message "Unsupported platform, Windows NT 4.0 or later required"
+#endif
+#include <windows.h>
+#endif
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4100) // warning C4100: unreferenced formal parameter
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace thread
+    {
+
+/*
+ *
+ */
+class Semaphore
+{
+private:
+#ifdef MACOSX
+    // MacOSX lacks support for timedwait() on a semaphore. Need to build a semaphore upon a condition.
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+    int counter;
+#elif defined unix
+    sem_t semaphore ;
+#else
+    HANDLE semaphore ;
+#endif
+
+public:
+    Semaphore(int initialSize = 0) ;
+    ~Semaphore() ;
+
+    void notify() ;
+    void notify(int count) ;
+    void wait() ;
+    bool wait(int timeout_sec, time_t now = -1) ;
+    bool trywait() ;
+} ;
+
+// Optimize all methods via inline code
+
+inline Semaphore::Semaphore(int initialSize)
+{
+#ifdef MACOSX
+  pthread_cond_init (&cond, NULL);
+  pthread_mutex_init (&mutex, NULL);
+  counter = initialSize;
+#elif defined unix
+  sem_init(&semaphore, 0 /* local to process */, initialSize) ;
+#else 
+  semaphore = CreateSemaphore(NULL, initialSize, 1000000, NULL) ;
+#endif
+}
+
+inline Semaphore::~Semaphore()
+{
+#ifdef MACOSX
+  pthread_mutex_destroy (&mutex);
+  pthread_cond_destroy (&cond);
+#elif defined unix
+  sem_destroy(&semaphore) ;
+#else
+  CloseHandle(semaphore) ;
+#endif
+}
+
+inline void Semaphore::notify()
+{
+#ifdef MACOSX
+  pthread_mutex_lock (&mutex);
+  ++counter;
+  pthread_cond_signal (&cond);
+  pthread_mutex_unlock (&mutex);
+#elif defined unix
+  sem_post(&semaphore) ;
+#else
+  ReleaseSemaphore(semaphore, 1, NULL) ;
+#endif
+}
+
+inline void Semaphore::notify(int count)
+{
+#ifdef MACOSX
+  pthread_mutex_lock (&mutex);
+  counter += count;
+  pthread_cond_signal (&cond);
+  pthread_mutex_unlock (&mutex);
+#elif defined unix
+  while( count != 0 )
+  {
+    sem_post(&semaphore) ;
+    --count ;
+  }
+#else
+  ReleaseSemaphore(semaphore, count, NULL) ;
+#endif
+}
+
+inline void Semaphore::wait()
+{
+#ifdef MACOSX
+  pthread_mutex_lock (&mutex);
+  while (counter == 0) {
+    pthread_cond_wait (&cond, &mutex);
+  }
+  --counter;
+  pthread_mutex_unlock (&mutex);
+#elif defined unix
+  sem_wait(&semaphore) ;
+#else
+  DWORD rc = WaitForSingleObject(semaphore, INFINITE) ;
+  assert(rc == WAIT_OBJECT_0) ;
+#endif
+}
+
+/*
+ * Waits specified number of seconds until it gives up. Returns false
+ * if semaphore is signaled, true when timeout is reached.
+ */
+inline bool Semaphore::wait(int timeout, time_t now)
+{
+#ifdef MACOSX
+  if (now == -1) time(&now) ;
+  timespec ts ;
+  ts.tv_sec = now + timeout ;
+  ts.tv_nsec = 0 ;
+
+  pthread_mutex_lock (&mutex);
+  while (counter == 0) {
+    if (pthread_cond_timedwait (&cond, &mutex, &ts) == ETIMEDOUT) {
+      pthread_mutex_unlock (&mutex);
+      return true;
+    }
+  }
+  --counter;
+  pthread_mutex_unlock (&mutex);
+  return true;
+#elif defined unix
+  if (now == -1)
+    time(&now) ;
+
+  timespec ts ;
+  ts.tv_sec = now + timeout ;
+  ts.tv_nsec = 0 ;
+
+  do
+  { 
+    int rc = sem_timedwait(&semaphore, &ts) ;
+
+    if (rc == 0)
+      return false ;
+
+    int errvalue = errno ;
+      
+    // Timeout occurred?
+    if ( errvalue == ETIMEDOUT)
+      return true ;
+
+    assert(errvalue != EDEADLK) ;
+    assert(errvalue != EINVAL) ;
+  }
+  while( true ) ;
+
+  return true ;
+#else
+  DWORD rc = WaitForSingleObject(semaphore, timeout * 1000) ;
+  return (rc == WAIT_OBJECT_0 ? false : true) ;
+#endif
+}
+
+/*
+ *  Returns false if some error occured or semaphore has zero count, true
+ *  if semaphore successfully was decreased.
+ */
+inline bool Semaphore::trywait()
+{
+#ifdef MACOSX
+  pthread_mutex_lock (&mutex);
+  if (counter == 0) {
+    pthread_mutex_unlock (&mutex);
+    return false;
+  } else {
+    --counter;
+    pthread_mutex_unlock (&mutex);
+    return true;
+  }
+#elif defined unix
+  int rc = sem_trywait(&semaphore) ;
+  return ( rc == 0 ) ? true : false ;
+#else
+  DWORD rc = WaitForSingleObject(semaphore, 0) ;
+  return (rc == WAIT_OBJECT_0 ? true : false) ;
+#endif
+}
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Semaphore_hpp_*/
+

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/SimpleMutex.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/SimpleMutex.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/SimpleMutex.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/SimpleMutex.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_SimpleMutex_hpp_
+#define Ppr_SimpleMutex_hpp_
+
+#ifdef unix
+#include <pthread.h>
+#endif
+#if defined(WIN32) || defined(__CYGWIN__) && !defined unix
+#if ( !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400)
+#pragma message "Unsupported platform, Windows NT 4.0 or later required"
+#endif
+#include <windows.h>
+#endif
+#include <assert.h>
+
+#ifndef LOCKED_SCOPE
+#define LOCKED_SCOPE(M) ::apache::ppr::thread::SimpleMutex::Lock _scope_lock_ (M)
+#define LOCKED_SCOPE_UNLOCK _scope_lock_.unlock()
+#define LOCKED_SCOPE_RELOCK _scope_lock_.relock()
+#endif
+
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace thread
+    {
+
+/*
+ *
+ */
+class SimpleMutex
+{
+public:
+    class Lock {
+    private:
+        SimpleMutex* mutex;
+        bool locked;
+    public:
+        Lock (SimpleMutex& mutex) : mutex (&mutex), locked (true) {
+            mutex.lock();
+        }
+        Lock (p<SimpleMutex>& mutex) : mutex (getptr(mutex)), locked (true) {
+            mutex->lock();
+        }
+        Lock (SimpleMutex* mutex) : mutex (mutex), locked (true) {
+            mutex->lock();
+        }
+        ~Lock () {
+            if (locked) mutex->unlock();
+        }
+    public:
+        void unlock () {
+            if (locked) {
+                mutex->unlock();
+                locked = false;
+            }
+        }
+        void relock () {
+            if (!locked) {
+                mutex->lock();
+                locked = true;
+            }
+        }
+    };
+private:
+#ifdef unix
+    pthread_mutex_t mutex ;
+#else
+    CRITICAL_SECTION  mutex ;
+#endif
+
+public:
+    SimpleMutex() ;
+    virtual ~SimpleMutex() ;
+
+    bool trylock() ;
+    void lock() ;
+    void unlock() ;
+} ;
+
+// Optimize all methods via inline code
+
+inline SimpleMutex::SimpleMutex()
+{
+#ifdef unix
+    pthread_mutexattr_t attr ;
+    pthread_mutexattr_init(&attr) ;
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) ;
+    pthread_mutex_init(&mutex, &attr) ;
+    pthread_mutexattr_destroy(&attr) ;
+#else
+    InitializeCriticalSection(&mutex) ;
+#endif
+}
+
+inline SimpleMutex::~SimpleMutex()
+{
+#ifdef unix
+    pthread_mutex_destroy(&mutex) ;
+#else
+    DeleteCriticalSection(&mutex) ;
+#endif
+}
+
+inline bool SimpleMutex::trylock()
+{
+#ifdef unix
+    int try_l = pthread_mutex_trylock(&mutex) ;
+    if (try_l == 0)
+        return true;
+    else
+        return false ;
+#else
+    return (TryEnterCriticalSection(&mutex) != 0) ;
+#endif
+}
+
+inline void SimpleMutex::lock()
+{
+#ifdef unix
+    pthread_mutex_lock(&mutex) ;
+#else
+    EnterCriticalSection(&mutex) ;
+#endif
+}
+
+inline void SimpleMutex::unlock()
+{
+#ifdef unix
+    pthread_mutex_unlock(&mutex) ;
+#else
+    LeaveCriticalSection(&mutex) ;
+#endif
+}
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_SimpleMutex_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <memory> // auto_ptr
+#ifdef unix
+#include <errno.h> // EINTR
+#else
+#include <process.h> // _endthreadex
+#endif
+#include "ppr/thread/Thread.hpp"
+
+using namespace apache::ppr::thread;
+
+struct InternalThreadParam
+{
+    p<Thread> threadObject ;
+} ;
+
+#ifdef unix
+static struct ThreadStaticInitializer {
+    // Thread Attribute member
+    pthread_attr_t threadAttribute;
+    // Static Initializer:
+    ThreadStaticInitializer() {
+        pthread_attr_init (&threadAttribute);
+        pthread_attr_setdetachstate (&threadAttribute, PTHREAD_CREATE_JOINABLE);
+    }
+} threadStaticInitializer;
+#endif
+
+/*
+ *
+ */
+Thread::Thread() : started (false), joined (false)
+{
+}
+
+/*
+ *
+ */
+Thread::~Thread()
+{
+}
+
+/*
+ *
+ */
+void Thread::start() throw (runtime_error)
+{
+    if( this->started )
+        throw runtime_error ("Thread already started");
+
+    auto_ptr<InternalThreadParam> threadParam (new InternalThreadParam()) ;
+    threadParam->threadObject = smartify(this) ; // smartify() turns this-pointer into a smart pointer.
+#ifdef unix
+    int err = pthread_create(
+                &this->threadHandle,
+                &threadStaticInitializer.threadAttribute,
+                internal_thread_function,
+                threadParam.get() ) ;
+    if( err != 0 )
+        throw runtime_error ("Coud not start thread") ;
+#else
+    this->threadHandle = CreateThread(NULL, 0, internal_thread_function, threadParam.get(), 0, NULL) ;
+    if (this->threadHandle == NULL)
+        throw runtime_error ("Coud not start thread") ;
+#endif
+    started = true ;
+    threadParam.release() ; // (Does not delete threadParam).
+    // threadParam is deleted in internal_thread_function() after when run() has returned.
+}
+
+p<exception> Thread::join()
+{
+    if( !this->started )
+        throw runtime_error ("Thread::join() called without having called Thread::start()");
+
+    if( !this->joined )
+#ifdef unix
+        pthread_join(this->threadHandle, NULL) ;
+#else
+        WaitForSingleObject (this->threadHandle, INFINITE) ;
+#endif
+    this->joined = true ;
+    return threwnException ;
+}
+
+void Thread::sleep(int millisecs)
+{
+#ifdef unix
+    struct timespec rec, rem ;
+    rec.tv_sec = millisecs / 1000 ;
+    rec.tv_nsec = (millisecs % 1000) * 1000000 ;
+    while ( nanosleep( &rec, &rem ) == EINTR ) ;
+#else
+    Sleep (millisecs) ;
+#endif
+}
+
+#ifdef unix
+void* Thread::internal_thread_function (void* param)
+#else
+unsigned long WINAPI Thread::internal_thread_function (void* param)
+#endif
+{
+    InternalThreadParam* itp = (InternalThreadParam*) param ;
+    try
+    {
+        itp->threadObject->run() ;
+    }
+    catch (exception* e)
+    {
+        itp->threadObject->threwnException = newptr (e) ;
+    }
+    catch (exception& e)
+    {
+        itp->threadObject->threwnException = new exception (e) ;
+    }
+    catch (p<exception> e)
+    {
+        itp->threadObject->threwnException = e ;
+    }
+    catch (...)
+    {
+        itp->threadObject->threwnException = new runtime_error ("An unknown exception was thrown") ;
+    }
+    p<Thread> threadObject = itp->threadObject ;
+    delete itp ;
+#ifdef unix
+    return NULL ;
+#else
+    // Return 0 if no exception was threwn. Otherwise -1.
+    unsigned long retval = (threadObject->threwnException == NULL ? 0 : -1) ;
+    _endthreadex(retval) ; // Needed when using threads and CRT in Windows. Otherwise memleak can appear.
+    return retval ;
+#endif
+}
+
+#ifdef UNITTEST
+
+#include <iostream>
+
+class MyThread : public Thread
+{
+public:
+    bool throwException;
+protected:
+    virtual void run () throw (p<exception>) 
+    {
+        cout << "Running thread" << endl;
+        if (throwException) {
+            cout << "Throwing exception" << endl;
+            throw p<exception> (new runtime_error ("Oops, something went wrong"));
+        } else {
+            cout << "Not throwing exception" << endl;
+        }
+    }
+};
+
+void testThread()
+{
+    p<MyThread> t1 = new MyThread();
+    p<MyThread> t2 = new MyThread();
+    t1->throwException = false;
+    t2->throwException = true;
+    t1->start();
+    t2->start();
+    p<exception> e1 = t1->join();
+    p<exception> e2 = t2->join();
+    assert (e1 == NULL);
+    assert (e2 != NULL);
+    assert (strcmp (e2->what(), "Oops, something went wrong") == 0);
+}
+
+#endif // UNITTEST

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Thread_hpp_
+#define Ppr_Thread_hpp_
+
+#ifdef unix
+#include <pthread.h>
+#else
+#include <windows.h>
+#endif
+
+#include <stdexcept>
+#include <assert.h>
+#include "ppr/util/ifr/p"
+
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace thread
+    {
+      using namespace std;
+      using namespace ifr;
+
+
+/**
+*/
+struct IThread : Interface
+{
+    /** Creates a system thread and starts it in a joinable mode.
+        @exception runtime_error is thrown if the system could
+        not start the thread.
+    */
+    virtual void start() throw (runtime_error) = 0;
+
+    /** Wait til the thread exits. This is when the run()
+        method has returned or has threwn an exception.
+        If an exception was threwn in the run() method,
+        join() will return the threwn exception. Otherwise
+        (if run() returned normally), join() will
+        return NULL.
+    */
+    virtual p<exception> join() = 0;
+};
+
+/** 
+ *
+ */
+class Thread : public IThread
+{
+private:
+#ifdef unix
+    pthread_t   threadHandle ;
+#else
+    HANDLE      threadHandle ;
+#endif
+    /// true if thread is started.
+    bool started;
+    /// true if thread is joined
+    bool joined;
+    /// Exception threwn by run().
+    p<exception> threwnException;
+public:
+    /** Construct.
+    */
+    Thread() ;
+    /** Destruct.
+    */
+    virtual ~Thread() ;
+
+    /** Creates a system thread and starts it in a joinable mode.
+        @exception runtime_error is thrown if the system could
+        not start the thread.
+    */
+    virtual void start() throw (runtime_error);
+
+    /** Wait til the thread exits. This is when the run()
+        method has returned or has threwn an exception.
+        If an exception was threwn in the run() method,
+        join() will return the threwn exception. Otherwise
+        (if run() returned normally), join() will
+        return NULL.
+    */
+    virtual p<exception> join() ;
+public:
+    /** Halts execution of the calling thread for a specified no of millisec.
+        
+        Note that this method is a static method that applies to the
+        calling thread and not to the thread object.
+    */
+    static void sleep(int millisecs) ;
+protected:
+    /** Derive from Thread and implement this method. This method will be
+        called by the thread that is created by start().
+        
+        If an exception is threwn, the exception instance will be returned
+        by join(). If the same exception instance (and not a copy of it)
+        should be returned by join(), the implementation must throw
+        a pointer to heap where the exception resides like this:
+            throw p<exception> (new MyException());
+    */
+    virtual void run () throw (p<exception>) = 0;
+
+private:
+    // Internal thread handling
+#ifdef unix
+    static void* internal_thread_function (void* param);
+#else
+    static unsigned long WINAPI internal_thread_function (void* param);
+#endif
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Thread_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Endian.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Endian.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Endian.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Endian.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Endian_hpp_
+#define Ppr_Endian_hpp_
+
+#ifdef unix
+#include <netinet/in.h>
+#else
+#include <Winsock2.h>
+#endif
+#include "ppr/util/ifr/endian"
+
+// Use these if the compiler does not support _intXX
+#ifdef NEEDS_INT_DEFINED
+#define _int16 short
+#define _int32 int
+#define _int64 long long
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace util
+    {
+
+// Macros and helpers for endian conversion
+#ifdef IFR_IS_BIG_ENDIAN
+inline unsigned int       htoni   (unsigned int i)        { return i; }
+inline unsigned long long htonll  (unsigned long long ll) { return ll; }
+inline float              htonf   (float f)               { return f; }
+inline double             htond   (double d)              { return d; }
+inline unsigned int       ntohi   (unsigned int i)        { return i; }
+inline unsigned long long ntohll  (unsigned long long ll) { return ll; }
+inline float              ntohf   (float f)               { return f; }
+inline double             ntohd   (double d)              { return d; }
+#else // !IFR_IS_BIG_ENDIAN
+
+inline unsigned int htoni (unsigned int i) {
+  return
+    ( i << 24 ) & 0xFF000000 |
+	( i << 8  ) & 0x00FF0000 |
+	( i >> 8  ) & 0x0000FF00 |
+	( i >> 24 ) & 0x000000FF;
+}
+
+inline unsigned long long htonll (unsigned long long ll) {
+  return
+    ( ll << 56 ) & 0xFF00000000000000ULL |
+	( ll << 40 ) & 0x00FF000000000000ULL |
+	( ll << 24 ) & 0x0000FF0000000000ULL |
+	( ll << 8  ) & 0x000000FF00000000ULL |
+    ( ll >> 8  ) & 0x00000000FF000000ULL |
+	( ll >> 24 ) & 0x0000000000FF0000ULL |
+	( ll >> 40 ) & 0x000000000000FF00ULL |
+	( ll >> 56 ) & 0x00000000000000FFULL;
+}
+inline float htonf (float f) {
+  unsigned int i = htoni( *(unsigned int *)&f ) ;
+  return *(float *)&i ;
+}
+inline double htond (double d) {
+  unsigned long long ll = htonll( *(unsigned long long *)&d ) ;
+  return *(double *)&ll ;
+}
+inline unsigned int       ntohi   (unsigned int i)        { return htoni (i); }
+inline unsigned long long ntohll  (unsigned long long ll) { return htonll (ll); }
+inline float              ntohf   (float f)               { return htonf (f); }
+inline double             ntohd   (double d)              { return htond (d); }
+
+#endif // IFR_IS_BIG_ENDIAN
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Endian_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ppr/util/Guid.hpp"
+
+using namespace apache::ppr::util;
+
+Guid::Guid()
+{
+    // no-op
+}
+
+/*
+ * Creates a new UUID string.
+ */
+unsigned char* Guid::getGuid()
+{
+    unsigned char* buffer = new unsigned char[16] ;
+
+#if defined(WIN32) || defined(__CYGWIN__)
+    GUID guid = GUID_NULL ;
+
+	// Create GUID
+    CoCreateGuid(&guid) ;
+    if( guid == GUID_NULL )
+    {
+        // TODO: exception
+        //cerr << "Failed to create an UUID" << endl ;
+        return NULL ;
+    }
+	// Store GUID in internal buffer
+    memcpy(buffer, &guid, 16) ;
+
+#else
+    uuid_t uuid ;
+
+	// Create UUID
+    uuid_generate(uuid) ;
+
+	// Store UUID in internal buffer
+	memcpy(buffer, uuid, 16) ;
+#endif
+
+    return buffer ;
+}
+
+/*
+ *
+ */
+p<string> Guid::getGuidString()
+{
+    unsigned char* buffer = NULL ;
+    char*          result = NULL ;
+    p<string>      guidStr ;
+
+    buffer = getGuid() ;
+    result = new char[40] ;
+
+    // Format into a string
+    sprintf(result, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+           buffer[0],  buffer[1],  buffer[2],  buffer[3],
+           buffer[4],  buffer[5],  buffer[6],  buffer[7],
+           buffer[8],  buffer[9],  buffer[10], buffer[11],
+           buffer[12], buffer[13], buffer[14], buffer[15]) ;
+
+    guidStr = new string(result) ;
+
+    // Clean up
+    delete result ;
+    delete buffer ;
+
+    return guidStr ;
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Guid_hpp_
+#define Ppr_Guid_hpp_
+
+#include <string>
+#include <ppr/util/ifr/p>
+
+#ifdef unix
+#include <sys/param.h>
+#endif
+#include <stdio.h>
+#include <assert.h>
+#if defined(WIN32) || defined(__CYGWIN__)
+#include <objbase.h>
+#else
+#include <uuid/uuid.h>
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace util
+    {
+      using namespace std;
+      using namespace ifr;
+
+/*
+ * Helper class that generates global unique identifiers.
+ */
+class Guid
+{
+private:
+    Guid() ; // This class shall never be instanciated.
+
+public:
+    static unsigned char* getGuid() ;
+    static p<string> getGuidString() ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Guid_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ppr/util/Hex.hpp"
+
+using namespace apache::ppr::util;
+
+/*
+ *
+ */
+Hex::Hex()
+{
+    // no-op
+}
+
+/*
+ *
+ */
+Hex::~Hex()
+{
+    // no-op
+}
+
+/*
+ * Converts a byte array into a hex string.
+ */
+p<string> Hex::toString(array<char> buffer)
+{
+    array<char> result ((buffer.size() * 2) + 1);
+    p<string> hexStr ;
+
+    // Format into a string
+    for( int i = 0 ; i < (int)buffer.size() ; i++ )
+        sprintf(&result[i*2], "%02x", (unsigned char) buffer[i]) ;
+
+    hexStr = new string(result.c_array(), result.size() - 1) ;
+
+    return hexStr ;
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Hex_hpp_
+#define Ppr_Hex_hpp_
+
+#include <string>
+#include <ppr/util/ifr/array>
+#include <ppr/util/ifr/p>
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace util
+    {
+      using namespace std;
+      using namespace ifr;
+
+/*
+ * Helper class with conversion routines.
+ */
+class Hex
+{
+private:
+    Hex() ;
+
+public:
+    ~Hex() ;
+
+    static p<string> toString(array<char> buffer) ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Hex_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,380 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ppr/util/MapItemHolder.hpp"
+
+using namespace apache::ppr::util;
+
+#if defined (_MSC_VER) // Microsoft Visual Studio compiler
+#include <windows.h> // Defines LONG_PTR which is a long type with same size as a void*
+#else
+typedef long LONG_PTR; // Assume sizeof(long) == sizeof(void*)
+#endif
+
+
+// Constructors -----------------------------------------------------
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder()
+{
+    this->value = NULL ;
+    this->type  = MapItemHolder::UNDEFINED ;
+    this->flags = 0 ;
+}
+
+MapItemHolder::MapItemHolder(const MapItemHolder& other) :
+    type (other.type),
+    flags (other.flags)
+{
+    if (flags & BIT_DESTRUCT) {
+        // value is a ptr
+        if ((flags & BIT_RELEASE_P_REFCOUNTED) == BIT_RELEASE_P_REFCOUNTED) {
+            // value is a refcounted ptr
+            this->value = other.value;
+            if (value) addref (reinterpret_cast<refcounted*> (value));
+        } else {
+            // value is a standard ptr - handle specificly for each type:
+            switch (type) {
+              case DOUBLE:
+                this->value = new double (other.getDouble());
+                break;
+              case LONG:
+                this->value = new long long (other.getLong());
+                break;
+              default:
+                assert (false); // Unknown type that requires heap allocation...
+            }
+        }
+    } else {
+        this->value = other.value;
+    }
+}
+
+MapItemHolder&
+MapItemHolder::operator = (const MapItemHolder& other)
+{
+    // Destruct us:
+    this->~MapItemHolder();
+
+    // Constuct us identical to how our copy constructor does:
+    this->type = other.type;
+    this->flags = other.flags;
+
+    if (flags & BIT_DESTRUCT) {
+        // value is a ptr
+        if ((flags & BIT_RELEASE_P_REFCOUNTED) == BIT_RELEASE_P_REFCOUNTED) {
+            // value is a refcounted ptr
+            this->value = other.value;
+            if (value) addref (reinterpret_cast<refcounted*> (value));
+        } else {
+            // value is a standard ptr - handle specificly for each type:
+            switch (type) {
+              case DOUBLE:
+                this->value = new double (other.getDouble());
+                break;
+              case LONG:
+                this->value = new long long (other.getLong());
+                break;
+              default:
+                assert (false); // Unknown type that requires heap allocation...
+            }
+        }
+    } else {
+        this->value = other.value;
+    }
+    return *this;
+}
+
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(bool value)
+{
+    this->value = (value ? (void*) 1 : NULL);
+    this->type  = MapItemHolder::BOOLEAN ;
+    this->flags = 0 ;
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(char value)
+{
+    this->value = (void*) (LONG_PTR) value;
+    this->type  = MapItemHolder::BYTE ;
+    this->flags = 0 ;
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(array<char> value)
+{
+    this->value = static_cast<refcounted*> (getptr (array_help::get_array (value)));
+    if (value != NULL) addref(value) ;
+    this->type  = MapItemHolder::BYTEARRAY ;
+    this->flags = 
+        MapItemHolder::BIT_RELEASE_P_REFCOUNTED; // Tells destructor to release value
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(double value)
+{
+    this->value = new double(value) ;
+    this->type  = MapItemHolder::DOUBLE ;
+    this->flags = 
+        MapItemHolder::BIT_DESTRUCT; // Tells destructor to delete value
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(float value)
+{
+    this->value = (void*) (LONG_PTR) value;
+    this->type  = MapItemHolder::FLOAT ;
+    this->flags = 0 ;
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(int value)
+{
+    this->value = (void*) (LONG_PTR) value;
+    this->type  = MapItemHolder::INTEGER ;
+    this->flags = 0 ;
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(long long value)
+{
+    this->value = new long long(value) ;
+    this->type  = MapItemHolder::LONG ;
+    this->flags = 
+        MapItemHolder::BIT_DESTRUCT; // Tells destructor to delete value
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(short value)
+{
+    this->value = (void*) (LONG_PTR) value;
+    this->type  = MapItemHolder::SHORT ;
+    this->flags = 0 ;
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(p<string> value)
+{
+    this->value = p_help::get_rc (value);
+    if (value != NULL) addref(value) ;
+    this->type  = MapItemHolder::STRING ;
+    this->flags = 
+        MapItemHolder::BIT_RELEASE_P_REFCOUNTED; // Tells destructor to release value
+}
+
+/*
+ * 
+ */
+MapItemHolder::MapItemHolder(const char* value)
+{
+    p<string> val = new string (value);
+    this->value = p_help::get_rc (val);
+    addref(val) ;
+    this->type  = MapItemHolder::STRING ;
+    this->flags = 
+        MapItemHolder::BIT_RELEASE_P_REFCOUNTED; // Tells destructor to release value
+}
+
+/*
+ * 
+ */
+MapItemHolder::~MapItemHolder()
+{
+    if (flags & BIT_DESTRUCT) {
+        // value must be destructed or released
+        if ((flags & BIT_RELEASE_P_REFCOUNTED) == BIT_RELEASE_P_REFCOUNTED) {
+            // value is a p<refcounted> - release it
+            if (value) release (reinterpret_cast<refcounted*> (value));
+        } else {
+            // value is a primitive type allocated with new() - delete it.
+            delete (int*) value ;
+        }
+    }
+}
+
+
+// Attribute methods ------------------------------------------------
+
+/*
+ * 
+ */
+int MapItemHolder::getType() const 
+{
+    return type ;
+}
+
+/*
+ * 
+ */
+bool MapItemHolder::getBoolean() const throw (ConversionException)
+{
+    if( type == BOOLEAN )
+        return ((LONG_PTR) value ? true : false);
+    else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a boolean") ;
+}
+
+/*
+ * 
+ */
+char MapItemHolder::getByte() const throw (ConversionException)
+{
+    if( type == BYTE )
+        return (char) (LONG_PTR) value;
+    else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a byte") ;
+}
+
+/*
+ * 
+ */
+array<char> MapItemHolder::getBytes() const throw (ConversionException)
+{
+    if( type == BYTEARRAY ) {
+        array<char> retval;
+        array_help::get_array (retval) = smartify (
+            static_cast<RCArray<char>*> (
+                reinterpret_cast<refcounted*> (value)));
+        if (retval != NULL) addref (retval);
+        return retval;
+    }
+    else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a byte array") ;
+}
+
+/*
+ * 
+ */
+double MapItemHolder::getDouble() const throw (ConversionException)
+{
+    if( type == DOUBLE ) {
+        return *(reinterpret_cast<double*> (value)) ;
+    } else if ( type == FLOAT ) {
+        return (double) (float) (LONG_PTR) value;
+    } else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a double") ;
+}
+
+/*
+ * 
+ */
+float MapItemHolder::getFloat() const throw (ConversionException)
+{
+    if( type == FLOAT )
+        return (float) (LONG_PTR) value;
+    else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a float") ;
+}
+
+/*
+ * 
+ */
+int MapItemHolder::getInt() const throw (ConversionException)
+{
+    if( type & (INTEGER | SHORT | BYTE)) {
+        return (int) (LONG_PTR) value;
+    }
+    else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to an integer") ;
+}
+
+/*
+ * 
+ */
+long long MapItemHolder::getLong() const throw (ConversionException)
+{
+    if( type & (INTEGER | SHORT | BYTE)) {
+        return (long long) (LONG_PTR) value;
+    } else if ( type == LONG ) {
+        return *(reinterpret_cast<long long*> (value)) ;
+    } else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a long") ;
+}
+
+/*
+ * 
+ */
+short MapItemHolder::getShort() const throw (ConversionException)
+{
+    if( type & (SHORT | BYTE)) {
+        return (short) (LONG_PTR) value;
+    } else
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a short") ;
+}
+
+/*
+ * 
+ */
+p<string> MapItemHolder::getString() const throw (ConversionException)
+{
+    p<string> retval ;
+    char buffer[80] ;
+
+    if (type == STRING) {
+        p_help::set_rc (retval, value);
+        p_help::set_obj (retval, static_cast<void_refcounter<string>*>(value)->obj_);
+        if (retval != NULL) addref (retval);
+        return retval;
+    } else if (type == BOOLEAN) {
+        sprintf(buffer, "%s", ( getBoolean() ? "true" : "false" ) ) ;
+        retval = new string(buffer) ;
+        return retval ;
+    } else if (type & (BYTE | SHORT | INTEGER)) {
+        sprintf(buffer, "%d", getInt() ) ;
+        retval = new string(buffer) ;
+        return retval ;
+    } else if (type == LONG) {
+#ifdef unix
+        sprintf(buffer, "%lld", getLong() ) ;
+#else
+        sprintf(buffer, "%I64d", getLong() ) ;
+#endif
+        retval = new string(buffer) ;
+        return retval ;
+    } else if (type == FLOAT) {
+        sprintf(buffer, "%f", getFloat() ) ;
+        retval = new string(buffer) ;
+        return retval ;
+    } else if (type == DOUBLE) {
+        sprintf(buffer, "%lf", getDouble() ) ;
+        retval = new string(buffer) ;
+        return retval ;
+    } else {
+        throw ConversionException(__FILE__, __LINE__, "Cannot convert map item value to a string") ;
+    }
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_MapItemHolder_hpp_
+#define Ppr_MapItemHolder_hpp_
+
+#include <string>
+#include <map>
+#include "ppr/ConversionException.hpp"
+#include "ppr/util/ifr/array"
+#include "ppr/util/ifr/p"
+
+// Turn off warning message for ignored exception specification
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace util
+    {
+      using namespace apache::ppr;
+      using namespace std;
+      using namespace ifr;
+
+/*
+ * 
+ */
+class MapItemHolder
+{
+private:
+    void* value ;
+    int   type,
+          flags ;
+
+    const static int BIT_DESTRUCT             = 0x01000000;
+    const static int BIT_RELEASE_P_REFCOUNTED = BIT_DESTRUCT | 0x02000000;
+    //const static int BIT_RELEASE_P_VOID       = BIT_DESTRUCT | 0x04000000;
+
+public:
+    const static int UNDEFINED = 0x00000000 ;
+    const static int BOOLEAN   = 0x00000001 ;
+    const static int BYTE      = 0x00000002 ;
+    const static int BYTEARRAY = 0x00000004 ;
+    const static int DOUBLE    = 0x00000008 ;
+    const static int FLOAT     = 0x00000010 ;
+    const static int INTEGER   = 0x00000020 ;
+    const static int LONG      = 0x00000040 ;
+    const static int SHORT     = 0x00000080 ;
+    const static int STRING    = 0x00000100 ;
+
+public:
+    MapItemHolder() ;
+    MapItemHolder(const MapItemHolder& other) ;
+    MapItemHolder& operator = (const MapItemHolder& other) ;
+    MapItemHolder(bool value) ;
+    MapItemHolder(char value) ;
+    MapItemHolder(array<char> value) ;
+    MapItemHolder(double value) ;
+    MapItemHolder(float value) ;
+    MapItemHolder(int value) ;
+    MapItemHolder(long long value) ;
+    MapItemHolder(short value) ;
+    MapItemHolder(p<string> value) ;
+    MapItemHolder(const char* value) ;
+    ~MapItemHolder() ;
+
+    int getType() const ;
+    bool getBoolean() const throw (ConversionException) ;
+    char getByte() const throw (ConversionException) ;
+    array<char> getBytes() const throw (ConversionException) ;
+    double getDouble() const throw (ConversionException) ;
+    float getFloat() const throw (ConversionException) ;
+    int getInt() const throw (ConversionException) ;
+    long long getLong() const throw (ConversionException) ;
+    short getShort() const throw (ConversionException) ;
+    p<string> getString() const throw (ConversionException) ;
+} ;
+
+typedef map<string, MapItemHolder> PropertyMap ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_MapItemHolder_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ppr/util/Time.hpp"
+
+using namespace apache::ppr::util;
+
+/*
+ *
+ */
+Time::Time()
+{
+    // no-op
+}
+
+/*
+ *
+ */
+Time::~Time()
+{
+    // no-op
+}
+
+/*
+ * Returns number of milliseconds since 1 Jan 1970 (UTC).
+ */
+long long Time::getCurrentTimeMillis()
+{
+    long long millis ;
+
+#ifdef unix
+    struct timeval tv ;
+    struct timezone tz ;
+
+    gettimeofday(&tv, &tz) ;
+
+    millis  = tv.tv_sec ;
+    millis += tv.tv_usec / 1000 ;
+#else
+    __time64_t ltime ;
+    struct __timeb64 tstruct ;
+
+    _time64( &ltime ) ;
+    _ftime64( &tstruct ) ;
+
+    millis  = ltime * 1000 ;
+    millis += tstruct.millitm ;
+#endif
+    return  millis ;
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef Ppr_Time_hpp_
+#define Ppr_Time_hpp_
+
+#ifdef unix
+#include <sys/time.h>
+#else
+#include <time.h>
+#include <sys/timeb.h>
+#endif
+
+namespace apache
+{
+  namespace ppr
+  {
+    namespace util
+    {
+
+/*
+ * Helper class with time functions.
+ */
+class Time
+{
+private:
+    Time() ;
+
+public:
+    ~Time() ;
+
+    static long long getCurrentTimeMillis() ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*Ppr_Time_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/array
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/array?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/array (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/array Thu Apr 27 14:59:28 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005-2006, David Fahlander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. Neither the name of slurk.org nor the names
+ * of its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef IFR_V1_ARRAY_
+#define IFR_V1_ARRAY_
+
+#include "v1/array.hpp"
+#include "v1/namespace.hpp"
+
+#endif // IFR_V1_ARRAY_

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/endian
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/endian?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/endian (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/endian Thu Apr 27 14:59:28 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2005-2006, David Fahlander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. Neither the name of slurk.org nor the names
+ * of its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "v1/endian.hpp"

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/p
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/p?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/p (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/ifr/p Thu Apr 27 14:59:28 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005-2006, David Fahlander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. Neither the name of slurk.org nor the names
+ * of its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef IFR_V1_P_
+#define IFR_V1_P_
+
+#include "v1/p.hpp"
+#include "v1/namespace.hpp"
+
+#endif // IFR_V1_P_



Mime
View raw message