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 2006/11/19 16:08:33 UTC
svn commit: r476836 - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire:
OpenWireFormat.cpp commands/BaseDataStructure.h commands/DataStructure.h
marshal/MarshalAware.h
Author: tabish
Date: Sun Nov 19 07:08:32 2006
New Revision: 476836
URL: http://svn.apache.org/viewvc?view=rev&rev=476836
Log:
Code Submit for planned Openwire Support
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireFormat.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/DataStructure.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/MarshalAware.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireFormat.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireFormat.cpp?view=diff&rev=476836&r1=476835&r2=476836
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireFormat.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireFormat.cpp Sun Nov 19 07:08:32 2006
@@ -296,29 +296,34 @@
return 0;
}
-// if (o.IsMarshallAware())
-// {
-// MarshallAware ma = (MarshallAware) o;
-// byte[] sequence = ma.GetMarshalledForm(this);
-// bs.WriteBoolean(sequence != null);
-// if (sequence != null)
-// {
-// return 1 + sequence.Length;
-// }
-// }
-//
-// byte type = o.GetDataStructureType();
-// if (type == 0) {
-// throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
-// }
-// BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
-// if (dsm == null)
-// throw new IOException("Unknown data type: " + type);
-// //Console.WriteLine("Marshalling type: " + type + " with structure: " + o);
-// return 1 + dsm.TightMarshal1(this, o, bs);
-
- return 0;
+ if( object->isMarshallAware() ) {
+
+ std::vector<unsigned char> sequence =
+ object->getMarshalledForm(this);
+ bs->writeBoolean( !sequence.empty() );
+ if( !sequence.empty() ) {
+ return 1 + sequence.size();
+ }
+ }
+
+ unsigned char type = object->getDataStructureType();
+ if( type == 0 ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "No valid data structure type for object of this type");
+ }
+
+ DataStreamMarshaller* dsm =
+ dynamic_cast< DataStreamMarshaller* >( dataMarshallers[type & 0xFF] );
+
+ if( dsm == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ ( string( "OpenWireFormat::marshal - Unknown data type: " ) +
+ Integer::toString( type ) ).c_str() );
+ }
+ return 1 + dsm->tightMarshal1( this, object, bs );
}
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, IOException )
@@ -344,7 +349,7 @@
if( o->isMarshallAware() && bs->readBoolean() ) {
MarshalAware* ma = dynamic_cast< MarshalAware* >( o );
- vector<unsigned char> sequence = ma->GetMarshalledForm( this );
+ vector<unsigned char> sequence = ma->getMarshalledForm( this );
ds->write( &sequence[0], sequence.size() );
} else {
@@ -377,7 +382,7 @@
if( bs->readBoolean() ) {
- byte dataType = dis->readByte();
+ const unsigned char dataType = dis->readByte();
DataStreamMarshaller* dsm =
dynamic_cast< DataStreamMarshaller* >(
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h?view=diff&rev=476836&r1=476835&r2=476836
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h Sun Nov 19 07:08:32 2006
@@ -68,6 +68,25 @@
*/
virtual void afterUnmarshall( OpenWireFormat* wireFormat ) {}
+ /**
+ * Called to set the data to this object that will contain the objects
+ * marshalled form.
+ * @param wireFormat - the wireformat object to control unmarshaling
+ * @param data - vector of object binary data
+ */
+ virtual void setMarshalledForm( OpenWireFormat* wireFormat,
+ const std::vector<char>& data ) {}
+
+ /**
+ * Called to get the data to this object that will contain the objects
+ * marshalled form.
+ * @param wireFormat - the wireformat object to control unmarshaling
+ * @return buffer that holds the objects data.
+ */
+ virtual std::vector<unsigned char> getMarshalledForm( OpenWireFormat* wireFormat ) {
+ return std::vector<unsigned char>();
+ }
+
};
}}}}
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/DataStructure.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/DataStructure.h?view=diff&rev=476836&r1=476835&r2=476836
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/DataStructure.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/DataStructure.h Sun Nov 19 07:08:32 2006
@@ -18,12 +18,14 @@
#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_DATASTRUCTURE_H_
#define _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_DATASTRUCTURE_H_
+#include <activemq/connector/openwire/marshal/MarshalAware.h>
+
namespace activemq{
namespace connector{
namespace openwire{
namespace commands{
- class DataStructure
+ class DataStructure : public marshal::MarshalAware
{
public:
@@ -34,12 +36,6 @@
* @return The type of the data structure
*/
virtual unsigned char getDataStructureType() const = 0;
-
- /**
- * Get whether this object is aware of marshalling.
- * @returns true if aware of marshalling.
- */
- virtual bool isMarshallAware() const = 0;
/**
* Clone this obbject and return a new instance that the
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/MarshalAware.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/MarshalAware.h?view=diff&rev=476836&r1=476835&r2=476836
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/MarshalAware.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/MarshalAware.h Sun Nov 19 07:08:32 2006
@@ -19,11 +19,14 @@
#define _ACTIVEMQ_CONNECTOR_OPENWIRE_MARSHAL_MARSHALAWARE_H_
#include <vector>
-#include <activemq/connector/openwire/OpenWireFormat.h>
namespace activemq{
namespace connector{
namespace openwire{
+
+ // Forward Declare
+ class OpenWireFormat;
+
namespace marshal{
class MarshalAware
@@ -33,32 +36,42 @@
virtual ~MarshalAware() {}
/**
+ * Determine if the class implementing this interface is really
+ * wanting to be told about marshalling. Normally if you didn't
+ * want to be marshal aware you just wouldn't implement this interface
+ * but since this is C++ and we don't have true interfaces we need
+ * a flat inheritance heirarchy, so we always implement this.
+ * @returns true if this class cares about marshalling.
+ */
+ virtual bool isMarshallAware() const = 0;
+
+ /**
* Called before marshalling is started to prepare the object to be
* marshalled.
* @param wireFormat - the wireformat object to control marshaling
*/
- virtual void BeforeMarshall( OpenWireFormat* wireFormat ) = 0;
+ virtual void beforeMarshall( OpenWireFormat* wireFormat ) = 0;
/**
* Called after marshalling is started to cleanup the object being
* marshalled.
* @param wireFormat - the wireformat object to control marshaling
*/
- virtual void AfterMarshall( OpenWireFormat* wireFormat ) = 0;
+ virtual void afterMarshall( OpenWireFormat* wireFormat ) = 0;
/**
* Called before unmarshalling is started to prepare the object to be
* unmarshalled.
* @param wireFormat - the wireformat object to control unmarshaling
*/
- virtual void BeforeUnmarshall( OpenWireFormat* wireFormat ) = 0;
+ virtual void beforeUnmarshall( OpenWireFormat* wireFormat ) = 0;
/**
* Called after unmarshalling is started to cleanup the object being
* unmarshalled.
* @param wireFormat - the wireformat object to control unmarshaling
*/
- virtual void AfterUnmarshall( OpenWireFormat* wireFormat ) = 0;
+ virtual void afterUnmarshall( OpenWireFormat* wireFormat ) = 0;
/**
* Called to set the data to this object that will contain the objects
@@ -66,8 +79,8 @@
* @param wireFormat - the wireformat object to control unmarshaling
* @param data - vector of object binary data
*/
- virtual void SetMarshalledForm( OpenWireFormat* wireFormat,
- std::vector<char>& data ) = 0;
+ virtual void setMarshalledForm( OpenWireFormat* wireFormat,
+ const std::vector<char>& data ) = 0;
/**
* Called to get the data to this object that will contain the objects
@@ -75,7 +88,7 @@
* @param wireFormat - the wireformat object to control unmarshaling
* @return buffer that holds the objects data.
*/
- virtual std::vector<unsigned char> GetMarshalledForm( OpenWireFormat* wireFormat ) = 0;
+ virtual std::vector<unsigned char> getMarshalledForm( OpenWireFormat* wireFormat ) = 0;
};