activemq-cpp-3.6.0
ActiveMQStreamMessage.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_ACTIVEMQSTREAMMESSAGE_H_
19 #define _ACTIVEMQ_COMMANDS_ACTIVEMQSTREAMMESSAGE_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>
29 #include <cms/StreamMessage.h>
37 #include <string>
38 #include <memory>
39 
40 namespace activemq {
41 namespace commands {
42 
43  class ActiveMQStreamMessageImpl;
44 
45  class AMQCPP_API ActiveMQStreamMessage: public ActiveMQMessageTemplate<cms::StreamMessage> {
46  private:
47 
48  ActiveMQStreamMessageImpl* impl;
49 
50  mutable std::auto_ptr<decaf::io::DataInputStream> dataIn;
51  mutable std::auto_ptr<decaf::io::DataOutputStream> dataOut;
52 
53  public:
54 
55  const static unsigned char ID_ACTIVEMQSTREAMMESSAGE = 27;
56 
57  private:
58 
61 
62  public:
63 
65  virtual ~ActiveMQStreamMessage() throw ();
66 
67  virtual unsigned char getDataStructureType() const;
68 
69  virtual ActiveMQStreamMessage* cloneDataStructure() const;
70 
71  virtual void copyDataStructure(const DataStructure* src);
72 
73  virtual std::string toString() const;
74 
75  virtual bool equals(const DataStructure* value) const;
76 
77  virtual void onSend();
78 
79  public: // CMS Message
80 
81  virtual cms::StreamMessage* clone() const {
82  ActiveMQStreamMessage* clone = this->cloneDataStructure();
83  clone->setReadOnlyBody(false);
84  clone->setReadOnlyProperties(false);
85  return dynamic_cast<cms::StreamMessage*>(clone);
86  }
87 
88  virtual void clearBody();
89 
90  public: // CMS Stream Message
91 
92  virtual ValueType getNextValueType() const;
93 
94  virtual void reset();
95 
96  virtual bool readBoolean() const;
97 
98  virtual void writeBoolean(bool value);
99 
100  virtual unsigned char readByte() const;
101 
102  virtual void writeByte(unsigned char value);
103 
104  virtual int readBytes(std::vector<unsigned char>& value) const;
105 
106  virtual void writeBytes(const std::vector<unsigned char>& value);
107 
108  virtual int readBytes(unsigned char* buffer, int length) const;
109 
110  virtual void writeBytes(const unsigned char* value, int offset, int length);
111 
112  virtual char readChar() const;
113 
114  virtual void writeChar(char value);
115 
116  virtual float readFloat() const;
117 
118  virtual void writeFloat(float value);
119 
120  virtual double readDouble() const;
121 
122  virtual void writeDouble(double value);
123 
124  virtual short readShort() const;
125 
126  virtual void writeShort(short value);
127 
128  virtual unsigned short readUnsignedShort() const;
129 
130  virtual void writeUnsignedShort(unsigned short value);
131 
132  virtual int readInt() const;
133 
134  virtual void writeInt(int value);
135 
136  virtual long long readLong() const;
137 
138  virtual void writeLong(long long value);
139 
140  virtual std::string readString() const;
141 
142  virtual void writeString(const std::string& value);
143 
144  private:
145 
146  void storeContent();
147 
148  void initializeReading() const;
149 
150  void initializeWriting();
151 
152  };
153 
154 }}
155 
156 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQSTREAMMESSAGE_H_*/