activemq-cpp-3.6.0
ActiveMQBytesMessage.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ACTIVEMQ_COMMANDS_ACTIVEMQBYTESMESSAGE_H_
19 #define _ACTIVEMQ_COMMANDS_ACTIVEMQBYTESMESSAGE_H_
20 
21 // Turn off warning message for ignored exception specification
22 #ifdef _MSC_VER
23 #pragma warning( disable : 4290 )
24 #endif
25 
26 #include <activemq/util/Config.h>
31 #include <cms/BytesMessage.h>
32 #include <vector>
33 #include <string>
34 #include <memory>
35 
36 namespace activemq{
37 namespace commands{
38 
40  public ActiveMQMessageTemplate< cms::BytesMessage > {
41  private:
42 
48 
52  mutable std::auto_ptr<decaf::io::DataInputStream> dataIn;
53 
57  std::auto_ptr<decaf::io::DataOutputStream> dataOut;
58 
62  mutable int length;
63 
64  public:
65 
66  const static unsigned char ID_ACTIVEMQBYTESMESSAGE = 24;
67 
68  private:
69 
71  ActiveMQBytesMessage& operator= ( const ActiveMQBytesMessage& );
72 
73  public:
74 
76 
77  virtual ~ActiveMQBytesMessage() throw();
78 
79  virtual unsigned char getDataStructureType() const;
80 
81  virtual ActiveMQBytesMessage* cloneDataStructure() const;
82 
83  virtual void copyDataStructure( const DataStructure* src );
84 
85  virtual std::string toString() const;
86 
87  virtual bool equals( const DataStructure* value ) const;
88 
89  public: // CMS Message
90 
91  virtual cms::BytesMessage* clone() const {
92  ActiveMQBytesMessage* clone = this->cloneDataStructure();
93  clone->setReadOnlyBody(false);
94  clone->setReadOnlyProperties(false);
95  return dynamic_cast<cms::BytesMessage*>(clone);
96  }
97 
98  virtual void clearBody();
99 
100  virtual void onSend();
101 
102  public: // CMS BytesMessage
103 
104  virtual void setBodyBytes( const unsigned char* buffer, int numBytes );
105 
106  virtual unsigned char* getBodyBytes() const;
107 
108  virtual int getBodyLength() const;
109 
110  virtual void reset();
111 
112  virtual bool readBoolean() const;
113 
114  virtual void writeBoolean( bool value );
115 
116  virtual unsigned char readByte() const;
117 
118  virtual void writeByte( unsigned char value );
119 
120  virtual int readBytes( std::vector<unsigned char>& value ) const;
121 
122  virtual void writeBytes( const std::vector<unsigned char>& value );
123 
124  virtual int readBytes( unsigned char* buffer, int length ) const;
125 
126  virtual void writeBytes( const unsigned char* value, int offset, int length );
127 
128  virtual char readChar() const;
129 
130  virtual void writeChar( char value );
131 
132  virtual float readFloat() const;
133 
134  virtual void writeFloat( float value );
135 
136  virtual double readDouble() const;
137 
138  virtual void writeDouble( double value );
139 
140  virtual short readShort() const;
141 
142  virtual void writeShort( short value );
143 
144  virtual unsigned short readUnsignedShort() const;
145 
146  virtual void writeUnsignedShort( unsigned short value );
147 
148  virtual int readInt() const;
149 
150  virtual void writeInt( int value );
151 
152  virtual long long readLong() const;
153 
154  virtual void writeLong( long long value );
155 
156  virtual std::string readString() const;
157 
158  virtual void writeString( const std::string& value );
159 
160  virtual std::string readUTF() const;
161 
162  virtual void writeUTF( const std::string& value );
163 
164  private:
165 
166  void storeContent();
167 
168  void initializeReading() const;
169 
170  void initializeWriting();
171 
172  };
173 
174 }}
175 
176 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQBYTESMESSAGE_H_*/