activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r505709 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands: WireFormatInfo.cpp WireFormatInfo.h
Date Sat, 10 Feb 2007 15:47:51 GMT
Author: tabish
Date: Sat Feb 10 07:47:50 2007
New Revision: 505709

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

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp?view=diff&rev=505709&r1=505708&r2=505709
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
Sat Feb 10 07:47:50 2007
@@ -26,8 +26,21 @@
 using namespace activemq::connector::openwire::commands;
 
 ////////////////////////////////////////////////////////////////////////////////
+std::vector<char> WireFormatInfo::MAGIC;
+
+////////////////////////////////////////////////////////////////////////////////
 WireFormatInfo::WireFormatInfo()
 {
+    if( MAGIC.empty() ) {
+        MAGIC.push_back( 'A' );
+        MAGIC.push_back( 'c' );
+        MAGIC.push_back( 't' );
+        MAGIC.push_back( 'i' );
+        MAGIC.push_back( 'v' );
+        MAGIC.push_back( 'e' );
+        MAGIC.push_back( 'M' );
+        MAGIC.push_back( 'Q' );
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -54,7 +67,7 @@
     const WireFormatInfo* srcPtr = dynamic_cast<const WireFormatInfo*>( src );
 
     if( srcPtr == NULL || src == NULL ) {
-    
+
         throw exceptions::NullPointerException(
             __FILE__, __LINE__,
             "WireFormatInfo::copyDataStructure - src is NULL or invalid" );
@@ -63,5 +76,21 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char WireFormatInfo::getDataStructureType() const {
-    return WireFormatInfo::ID_WIREFORMATINFO; 
+    return WireFormatInfo::ID_WIREFORMATINFO;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool WireFormatInfo::isValid() const {
+
+    if( magic.size() != MAGIC.size() ) {
+        return false;
+    }
+
+    for( int i = 0; i < magic.size(); i++ ) {
+        if( magic[i] != MAGIC[i] ) {
+            return false;
+        }
+    }
+
+    return true;
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h?view=diff&rev=505709&r1=505708&r2=505709
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
Sat Feb 10 07:47:50 2007
@@ -34,9 +34,9 @@
         const static unsigned char ID_WIREFORMATINFO = 1;
 
     public:
-    
+
         WireFormatInfo();
-    
+
         virtual ~WireFormatInfo();
 
         /**
@@ -67,7 +67,7 @@
         bool isStackTraceEnabled() const {
             return stackTraceEnabled;
         }
-    
+
         /**
          * Sets if the stackTraceEnabled flag is on
          * @param stackTraceEnabled - ture to turn flag is on
@@ -75,7 +75,7 @@
         void setStackTraceEnabled( bool stackTraceEnabled ) {
             this->stackTraceEnabled = stackTraceEnabled;
         }
-    
+
         /**
          * Checks if the tcpNoDelayEnabled flag is on
          * @return true if the flag is on.
@@ -83,7 +83,7 @@
         bool isTcpNoDelayEnabled() const {
             return tcpNoDelayEnabled;
         }
-    
+
         /**
          * Sets if the tcpNoDelayEnabled flag is on
          * @param tcpNoDelayEnabled - ture to turn flag is on
@@ -91,7 +91,7 @@
         void setTcpNoDelayEnabled( bool tcpNoDelayEnabled ) {
             this->tcpNoDelayEnabled = tcpNoDelayEnabled;
         }
-    
+
         /**
          * Get the current Wireformat Version
          * @return int that identifies the version
@@ -99,7 +99,7 @@
         int getVersion() const {
             return version;
         }
-    
+
         /**
          * Set the current Wireformat Version
          * @param version - int that identifies the version
@@ -107,7 +107,7 @@
         void setVersion( int version ) {
             this->version = version;
         }
-    
+
         /**
          * Checks if the cacheEnabled flag is on
          * @return true if the flag is on.
@@ -115,7 +115,7 @@
         bool isCacheEnabled() const {
             return cacheEnabled;
         }
-    
+
         /**
          * Sets if the cacheEnabled flag is on
          * @param cacheEnabled - ture to turn flag is on
@@ -123,7 +123,7 @@
         void setCacheEnabled( bool cacheEnabled ) {
             this->cacheEnabled = cacheEnabled;
         }
-    
+
         /**
          * Checks if the tightEncodingEnabled flag is on
          * @return true if the flag is on.
@@ -131,7 +131,7 @@
         bool isTightEncodingEnabled() const {
             return tightEncodingEnabled;
         }
-    
+
         /**
          * Sets if the tightEncodingEnabled flag is on
          * @param tightEncodingEnabled - ture to turn flag is on
@@ -139,7 +139,7 @@
         void setTightEncodingEnabled( bool tightEncodingEnabled ) {
             this->tightEncodingEnabled = tightEncodingEnabled;
         }
-    
+
         /**
          * Checks if the sizePrefixDisabled flag is on
          * @return true if the flag is on.
@@ -147,7 +147,7 @@
         bool isSizePrefixDisabled() const {
             return sizePrefixDisabled;
         }
-    
+
         /**
          * Sets if the sizePrefixDisabled flag is on
          * @param sizePrefixDisabled - ture to turn flag is on
@@ -155,7 +155,7 @@
         void setSizePrefixDisabled( bool sizePrefixDisabled ) {
             this->sizePrefixDisabled = sizePrefixDisabled;
         }
-    
+
         /**
          * Get the current value of the maxInactivityDuration feild
          * @return the value of the maxInactivityDuration
@@ -163,7 +163,7 @@
         long getMaxInactivityDuration() const {
             return maxInactivityDuration;
         }
-    
+
         /**
          * Set the current Wireformat Version
          * @param version - int that identifies the version
@@ -171,7 +171,7 @@
         void setMaxInactivityDuration( long maxInactivityDuration ) {
             this->maxInactivityDuration = maxInactivityDuration;
         }
-        
+
         /**
          * Get the Magic field
          * @return const reference to a std::vector<char>
@@ -179,7 +179,7 @@
         const std::vector<unsigned char>& getMagic() const {
             return magic;
         }
-        
+
         /**
          * Sets the value of the magic field
          * @param magic - const std::vector<char>
@@ -195,7 +195,7 @@
         const std::vector<unsigned char>& getMarshalledProperties() const {
             return magic;
         }
-        
+
         /**
          * Sets the value of the marshalledProperties field
          * @param magic - const std::vector<char>
@@ -204,22 +204,19 @@
             this->magic = magic;
         }
 
+        /**
+         * Determines if we think this is a Valid WireFormatInfo command
+         * @returns true if its valid.
+         */
+        bool isValid() const;
+
     private:
 
         static std::vector<char> MAGIC;
-//         = new byte[] {
-//            'A'&0xFF,
-//            'c'&0xFF,
-//            't'&0xFF,
-//            'i'&0xFF,
-//            'v'&0xFF,
-//            'e'&0xFF,
-//            'M'&0xFF,
-//            'Q'&0xFF };
-        
+
         std::vector<unsigned char> magic;
         std::vector<unsigned char> marshalledProperties;
-    
+
         int version;
         bool stackTraceEnabled;
         bool tcpNoDelayEnabled;



Mime
View raw message