You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/01/25 20:25:04 UTC

svn commit: r499930 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/util/Map.h main/activemq/util/PrimitiveMap.cpp main/activemq/util/PrimitiveMap.h test/activemq/util/PrimitiveMapTest.cpp test/activemq/util/PrimitiveMapTest.h

Author: tabish
Date: Thu Jan 25 11:25:03 2007
New Revision: 499930

URL: http://svn.apache.org/viewvc?view=rev&rev=499930
Log:
http://issues.apache.org/activemq/browse/AMQCPP-30

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h?view=diff&rev=499930&r1=499929&r2=499930
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h Thu Jan 25 11:25:03 2007
@@ -58,6 +58,14 @@
     	virtual ~Map(){};
         
         /**
+         * Comparison, equality is dependant on the method of determining
+         * if the element are equal.
+         * @param source - Map to compare to this one.
+         * @returns true if the Map passed is equal in value to this one.
+         */
+        virtual bool equals( const Map& source ) const;
+        
+        /**
          * Copies the content of the source map into this map.  Erases
          * all existing data in this map.
          * @param source The source object to copy from.
@@ -191,7 +199,13 @@
             mutex.notifyAll();
         }
     };
-    
+
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>    
+    bool Map<K,V>::equals( const Map& source ) const {
+        return this->valueMap == source.valueMap;        
+    }    
+
     ////////////////////////////////////////////////////////////////////////////
     template <typename K, typename V>    
     void Map<K,V>::copy( const Map<K,V>& source ) {

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp?view=diff&rev=499930&r1=499929&r2=499930
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp Thu Jan 25 11:25:03 2007
@@ -27,13 +27,30 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+PrimitiveMap::PrimitiveMap( const PrimitiveMap& src ) {
+    this->valueNodeMap = src.valueNodeMap;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 PrimitiveMap::~PrimitiveMap()
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::clear()
-{
+bool PrimitiveMap::equals( const PrimitiveMap& src ) const {
+
+    return this->valueNodeMap.equals( src.valueNodeMap );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::copy( const PrimitiveMap& src ) {
+
+    return this->valueNodeMap.copy( src.valueNodeMap );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::clear() {
+    
     valueNodeMap.clear();
 }
 

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h?view=diff&rev=499930&r1=499929&r2=499930
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h Thu Jan 25 11:25:03 2007
@@ -162,6 +162,9 @@
                 if( valueType == STRING_TYPE && value.stringValue != NULL ){
                     delete value.stringValue;
                 }
+                if( valueType == BYTE_ARRAY_TYPE && value.byteArrayValue != NULL ){
+                    delete value.byteArrayValue;
+                }
                 valueType = NULL_TYPE;  
                 memset( &value, 0, sizeof(value) );
             }
@@ -338,6 +341,26 @@
     
     	PrimitiveMap();
     	virtual ~PrimitiveMap();
+        
+        /**
+         * Copy Constructor
+         * @param map - the PrimitiveMap to copy
+         */
+        PrimitiveMap( const PrimitiveMap& src );
+        
+        /**
+         * Compares this PrimitiveMap to another
+         * @param source - Map to compare to
+         * @return true if the maps are equeal
+         */
+        bool equals( const PrimitiveMap& source ) const;
+                
+        /**
+         * Comparison Operator
+         * @param src - Map to compare to this one.
+         * @returns true if Maps are equal.
+         */
+        void copy( const PrimitiveMap& src );
         
         /**
          * Removes all keys and values from all maps.

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp?view=diff&rev=499930&r1=499929&r2=499930
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp Thu Jan 25 11:25:03 2007
@@ -195,6 +195,21 @@
     CPPUNIT_ASSERT( pmap.size() == 2 );
 }
 
+void PrimitiveMapTest::testCopy(){
+
+    PrimitiveMap pmap;
+    pmap.setInt("int", 5 );
+    pmap.setFloat( "float", 5.5f );
+    pmap.setInt("int2", 6 );
+
+    PrimitiveMap copy;
+    copy.copy( pmap );
+    CPPUNIT_ASSERT( pmap.equals( copy ) );
+
+    PrimitiveMap copy1( pmap );
+    CPPUNIT_ASSERT( pmap.equals( copy1 ) );
+}
+
 void PrimitiveMapTest::testClear(){
     
     PrimitiveMap pmap;

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.h?view=diff&rev=499930&r1=499929&r2=499930
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.h Thu Jan 25 11:25:03 2007
@@ -34,6 +34,7 @@
         CPPUNIT_TEST( testRemove );
         CPPUNIT_TEST( testCount );
         CPPUNIT_TEST( testClear );
+        CPPUNIT_TEST( testCopy );
         CPPUNIT_TEST( testContains );
         CPPUNIT_TEST( testGetKeys );
         CPPUNIT_TEST_SUITE_END();
@@ -47,6 +48,7 @@
         void testSetGet();
         void testRemove();
         void testCount();
+        void testCopy();
         void testClear();
         void testContains();
         void testGetKeys();