activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r881454 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf: lang/Pointer.h lang/Thread.h util/concurrent/Mutex.h util/concurrent/locks/ReentrantLock.h
Date Tue, 17 Nov 2009 19:35:44 GMT
Author: tabish
Date: Tue Nov 17 19:35:43 2009
New Revision: 881454

URL: http://svn.apache.org/viewvc?rev=881454&view=rev
Log:
Allow the Pointer class to operate on incomplete types.  Change the classes that have Pimpl
data to use the Pointer.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h?rev=881454&r1=881453&r2=881454&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h Tue Nov 17 19:35:43
2009
@@ -98,8 +98,15 @@
     class Pointer : public REFCOUNTER {
     private:
 
+        typedef void (*deletionFuncPtr)(T* p);
+
+    private:
+
         T* value;
 
+        // Pointer to our internal delete function, allows incompletes.
+        deletionFuncPtr onDelete;
+
     public:
 
         typedef T* PointerType;          // type returned by operator->
@@ -114,7 +121,7 @@
          * Initialized the contained pointer to NULL, using the -> operator
          * results in an exception unless reset to contain a real value.
          */
-        Pointer() : REFCOUNTER(), value( NULL ) {}
+        Pointer() : REFCOUNTER(), value( NULL ), onDelete( onDeleteFunc ) {}
 
         /**
          * Explicit Constructor, creates a Pointer that contains value with a
@@ -122,21 +129,23 @@
          *
          * @param value - instance of the type we are containing here.
          */
-        explicit Pointer( const PointerType value ) : REFCOUNTER(), value( value ) {
+        explicit Pointer( const PointerType value ) : REFCOUNTER(), value( value ), onDelete(
onDeleteFunc ) {
         }
 
         /**
          * Copy constructor. Copies the value contained in the pointer to the new
          * instance and increments the reference counter.
          */
-        Pointer( const Pointer& value ) throw() : REFCOUNTER( value ), value( value.value
) {}
+        Pointer( const Pointer& value ) throw() :
+            REFCOUNTER( value ), value( value.value ), onDelete( onDeleteFunc ) {}
 
         /**
          * Copy constructor. Copies the value contained in the pointer to the new
          * instance and increments the reference counter.
          */
         template< typename T1, typename R1 >
-        Pointer( const Pointer<T1, R1>& value ) throw() : REFCOUNTER( value ),
value( value.get() ) {}
+        Pointer( const Pointer<T1, R1>& value ) throw() :
+            REFCOUNTER( value ), value( value.get() ), onDelete( onDeleteFunc ) {}
 
         /**
          * Static Cast constructor. Copies the value contained in the pointer to the new
@@ -147,7 +156,7 @@
          */
         template< typename T1, typename R1 >
         Pointer( const Pointer<T1, R1>& value, const STATIC_CAST_TOKEN& ) throw()
:
-            REFCOUNTER( value ), value( static_cast<T*>( value.get() ) ) {
+            REFCOUNTER( value ), value( static_cast<T*>( value.get() ) ), onDelete(
onDeleteFunc ) {
         }
 
         /**
@@ -162,7 +171,7 @@
         template< typename T1, typename R1 >
         Pointer( const Pointer<T1, R1>& value, const DYNAMIC_CAST_TOKEN& )
             throw( decaf::lang::exceptions::ClassCastException ) :
-                REFCOUNTER( value ), value( dynamic_cast<T*>( value.get() ) ) {
+                REFCOUNTER( value ), value( dynamic_cast<T*>( value.get() ) ), onDelete(
onDeleteFunc ) {
 
             if( this->value == NULL ) {
                 // Remove the reference we took in the Reference Counter's ctor since we
@@ -177,7 +186,7 @@
 
         virtual ~Pointer() throw() {
             if( REFCOUNTER::release() == true ) {
-                delete this->value;
+                onDelete( this->value );
             }
         }
 
@@ -340,6 +349,14 @@
         Pointer<T1, CounterType> staticCast() const {
             return Pointer<T1, CounterType>( *this, STATIC_CAST_TOKEN() );
         }
+
+    private:
+
+        // Internal Static deletion function.
+        static void onDeleteFunc(T* value) {
+            delete value;
+        }
+
     };
 
     ////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h?rev=881454&r1=881453&r2=881454&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h Tue Nov 17 19:35:43
2009
@@ -23,8 +23,8 @@
 #include <decaf/lang/exceptions/RuntimeException.h>
 #include <decaf/lang/Exception.h>
 #include <decaf/lang/Runnable.h>
+#include <decaf/lang/Pointer.h>
 #include <decaf/util/Config.h>
-#include <memory>
 
 namespace decaf{
 namespace util{
@@ -70,7 +70,7 @@
         /**
          * The internal data necessary to manage a Thread instance.
          */
-        std::auto_ptr<ThreadProperties> properties;
+        decaf::lang::Pointer<ThreadProperties> properties;
 
     public:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h?rev=881454&r1=881453&r2=881454&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h Tue Nov
17 19:35:43 2009
@@ -20,11 +20,10 @@
 
 #include <decaf/util/concurrent/Synchronizable.h>
 #include <decaf/util/concurrent/Concurrent.h>
+#include <decaf/lang/Pointer.h>
 #include <decaf/lang/Thread.h>
 #include <decaf/util/Config.h>
 
-#include <memory>
-
 namespace decaf{
 namespace util{
 namespace concurrent{
@@ -41,7 +40,7 @@
     class DECAF_API Mutex : public Synchronizable {
     private:
 
-        std::auto_ptr<MutexProperties> properties;
+        decaf::lang::Pointer<MutexProperties> properties;
 
     private:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h?rev=881454&r1=881453&r2=881454&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h
Tue Nov 17 19:35:43 2009
@@ -21,8 +21,7 @@
 #include <decaf/util/Config.h>
 
 #include <decaf/util/concurrent/locks/Lock.h>
-
-#include <memory>
+#include <decaf/lang/Pointer.h>
 
 namespace decaf {
 namespace util {
@@ -81,7 +80,7 @@
     class DECAF_API ReentrantLock : public Lock {
     private:
 
-        std::auto_ptr<LockHandle> handle;
+        decaf::lang::Pointer<LockHandle> handle;
 
     public:
 



Mime
View raw message