activemq-cpp-3.3.0

src/main/activemq/commands/ActiveMQStreamMessage.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _ACTIVEMQ_COMMANDS_ACTIVEMQSTREAMMESSAGE_H_
00019 #define _ACTIVEMQ_COMMANDS_ACTIVEMQSTREAMMESSAGE_H_
00020 
00021 // Turn off warning message for ignored exception specification
00022 #ifdef _MSC_VER
00023 #pragma warning( disable : 4290 )
00024 #endif
00025 
00026 #include <activemq/util/Config.h>
00027 #include <activemq/commands/ActiveMQMessage.h>
00028 #include <activemq/commands/ActiveMQMessageTemplate.h>
00029 #include <cms/StreamMessage.h>
00030 #include <cms/MessageNotWriteableException.h>
00031 #include <cms/MessageNotReadableException.h>
00032 #include <cms/MessageFormatException.h>
00033 #include <cms/MessageEOFException.h>
00034 #include <decaf/lang/exceptions/NullPointerException.h>
00035 #include <decaf/io/DataInputStream.h>
00036 #include <decaf/io/DataOutputStream.h>
00037 #include <decaf/io/ByteArrayOutputStream.h>
00038 #include <string>
00039 #include <memory>
00040 
00041 namespace activemq{
00042 namespace commands{
00043 
00044     class AMQCPP_API ActiveMQStreamMessage :
00045         public ActiveMQMessageTemplate< cms::StreamMessage > {
00046     private:
00047 
00048         decaf::io::ByteArrayOutputStream* bytesOut;
00049         mutable std::auto_ptr<decaf::io::DataInputStream> dataIn;
00050         mutable std::auto_ptr<decaf::io::DataOutputStream> dataOut;
00051 
00052         mutable int remainingBytes;
00053 
00054     public:
00055 
00056         const static unsigned char ID_ACTIVEMQSTREAMMESSAGE = 27;
00057 
00058     private:
00059 
00060         ActiveMQStreamMessage( const ActiveMQStreamMessage& );
00061         ActiveMQStreamMessage& operator= ( const ActiveMQStreamMessage& );
00062 
00063     public:
00064 
00065         ActiveMQStreamMessage();
00066         virtual ~ActiveMQStreamMessage() throw();
00067 
00068         virtual unsigned char getDataStructureType() const;
00069 
00070         virtual ActiveMQStreamMessage* cloneDataStructure() const;
00071 
00072         virtual void copyDataStructure( const DataStructure* src );
00073 
00074         virtual std::string toString() const;
00075 
00076         virtual bool equals( const DataStructure* value ) const;
00077 
00078         virtual void onSend();
00079 
00080     public:   // CMS Message
00081 
00082         virtual cms::StreamMessage* clone() const {
00083             return dynamic_cast<cms::StreamMessage*>( this->cloneDataStructure() );
00084         }
00085 
00086         virtual void clearBody();
00087 
00088     public: // CMS Stream Message
00089 
00090         virtual void reset();
00091 
00092         virtual bool readBoolean() const;
00093 
00094         virtual void writeBoolean( bool value );
00095 
00096         virtual unsigned char readByte() const;
00097 
00098         virtual void writeByte( unsigned char value );
00099 
00100         virtual int readBytes( std::vector<unsigned char>& value ) const;
00101 
00102         virtual void writeBytes( const std::vector<unsigned char>& value );
00103 
00104         virtual int readBytes( unsigned char* buffer, int length ) const;
00105 
00106         virtual void writeBytes( const unsigned char* value, int offset, int length );
00107 
00108         virtual char readChar() const;
00109 
00110         virtual void writeChar( char value );
00111 
00112         virtual float readFloat() const;
00113 
00114         virtual void writeFloat( float value );
00115 
00116         virtual double readDouble() const;
00117 
00118         virtual void writeDouble( double value );
00119 
00120         virtual short readShort() const;
00121 
00122         virtual void writeShort( short value );
00123 
00124         virtual unsigned short readUnsignedShort() const;
00125 
00126         virtual void writeUnsignedShort( unsigned short value );
00127 
00128         virtual int readInt() const;
00129 
00130         virtual void writeInt( int value );
00131 
00132         virtual long long readLong() const;
00133 
00134         virtual void writeLong( long long value );
00135 
00136         virtual std::string readString() const;
00137 
00138         virtual void writeString( const std::string& value );
00139 
00140     private:
00141 
00142         void storeContent();
00143 
00144         void initializeReading() const;
00145 
00146         void initializeWriting();
00147 
00148     };
00149 
00150 }}
00151 
00152 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQSTREAMMESSAGE_H_*/