activemq-cpp-3.4.0

src/main/activemq/commands/ActiveMQBytesMessage.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_ACTIVEMQBYTESMESSAGE_H_
00019 #define _ACTIVEMQ_COMMANDS_ACTIVEMQBYTESMESSAGE_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/ActiveMQMessageTemplate.h>
00028 #include <decaf/io/ByteArrayOutputStream.h>
00029 #include <decaf/io/DataInputStream.h>
00030 #include <decaf/io/DataOutputStream.h>
00031 #include <cms/BytesMessage.h>
00032 #include <vector>
00033 #include <string>
00034 #include <memory>
00035 
00036 namespace activemq{
00037 namespace commands{
00038 
00039     class AMQCPP_API ActiveMQBytesMessage :
00040         public ActiveMQMessageTemplate< cms::BytesMessage > {
00041     private:
00042 
00047         decaf::io::ByteArrayOutputStream* bytesOut;
00048 
00052         mutable std::auto_ptr<decaf::io::DataInputStream> dataIn;
00053 
00057         std::auto_ptr<decaf::io::DataOutputStream> dataOut;
00058 
00062         mutable int length;
00063 
00064     public:
00065 
00066         const static unsigned char ID_ACTIVEMQBYTESMESSAGE = 24;
00067 
00068     private:
00069 
00070         ActiveMQBytesMessage( const ActiveMQBytesMessage& );
00071         ActiveMQBytesMessage& operator= ( const ActiveMQBytesMessage& );
00072 
00073     public:
00074 
00075         ActiveMQBytesMessage();
00076 
00077         virtual ~ActiveMQBytesMessage() throw();
00078 
00079         virtual unsigned char getDataStructureType() const;
00080 
00081         virtual ActiveMQBytesMessage* cloneDataStructure() const;
00082 
00083         virtual void copyDataStructure( const DataStructure* src );
00084 
00085         virtual std::string toString() const;
00086 
00087         virtual bool equals( const DataStructure* value ) const;
00088 
00089     public:   // CMS Message
00090 
00091         virtual cms::BytesMessage* clone() const {
00092             return dynamic_cast<cms::BytesMessage*>( this->cloneDataStructure() );
00093         }
00094 
00095         virtual void clearBody();
00096 
00097         virtual void onSend();
00098 
00099     public:   // CMS BytesMessage
00100 
00101         virtual void setBodyBytes( const unsigned char* buffer, int numBytes );
00102 
00103         virtual unsigned char* getBodyBytes() const;
00104 
00105         virtual int getBodyLength() const;
00106 
00107         virtual void reset();
00108 
00109         virtual bool readBoolean() const;
00110 
00111         virtual void writeBoolean( bool value );
00112 
00113         virtual unsigned char readByte() const;
00114 
00115         virtual void writeByte( unsigned char value );
00116 
00117         virtual int readBytes( std::vector<unsigned char>& value ) const;
00118 
00119         virtual void writeBytes( const std::vector<unsigned char>& value );
00120 
00121         virtual int readBytes( unsigned char* buffer, int length ) const;
00122 
00123         virtual void writeBytes( const unsigned char* value, int offset, int length );
00124 
00125         virtual char readChar() const;
00126 
00127         virtual void writeChar( char value );
00128 
00129         virtual float readFloat() const;
00130 
00131         virtual void writeFloat( float value );
00132 
00133         virtual double readDouble() const;
00134 
00135         virtual void writeDouble( double value );
00136 
00137         virtual short readShort() const;
00138 
00139         virtual void writeShort( short value );
00140 
00141         virtual unsigned short readUnsignedShort() const;
00142 
00143         virtual void writeUnsignedShort( unsigned short value );
00144 
00145         virtual int readInt() const;
00146 
00147         virtual void writeInt( int value );
00148 
00149         virtual long long readLong() const;
00150 
00151         virtual void writeLong( long long value );
00152 
00153         virtual std::string readString() const;
00154 
00155         virtual void writeString( const std::string& value );
00156 
00157         virtual std::string readUTF() const;
00158 
00159         virtual void writeUTF( const std::string& value );
00160 
00161     private:
00162 
00163         void storeContent();
00164 
00165         void initializeReading() const;
00166 
00167         void initializeWriting();
00168 
00169     };
00170 
00171 }}
00172 
00173 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQBYTESMESSAGE_H_*/