activemq-cpp-3.4.0

src/main/activemq/wireformat/stomp/StompWireFormat.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_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_
00019 #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_
00020 
00021 #include <activemq/util/Config.h>
00022 #include <activemq/wireformat/WireFormat.h>
00023 #include <activemq/wireformat/stomp/StompFrame.h>
00024 #include <activemq/wireformat/stomp/StompHelper.h>
00025 #include <decaf/util/concurrent/atomic/AtomicBoolean.h>
00026 #include <decaf/io/IOException.h>
00027 #include <decaf/lang/Pointer.h>
00028 
00029 namespace activemq {
00030 namespace wireformat {
00031 namespace stomp {
00032 
00033     using decaf::lang::Pointer;
00034     using activemq::commands::Command;
00035 
00036     class StompWireformatProperties;
00037 
00038     class AMQCPP_API StompWireFormat : public WireFormat {
00039     private:
00040 
00044         StompHelper helper;
00045 
00046         // Stored after we connect to use when validating that a durable subscribe
00047         // and unsubscribe are set to use the client Id.
00048         std::string clientId;
00049 
00050         // Indicates when we are in the doUnmarshal call
00051         decaf::util::concurrent::atomic::AtomicBoolean receiving;
00052 
00053         // Internal structure for holding class internal data that can change without
00054         // affecting binary compatibility.
00055         StompWireformatProperties* properties;
00056 
00057     public:
00058 
00059         StompWireFormat();
00060 
00061         virtual ~StompWireFormat();
00062 
00063     public:
00064 
00078         virtual void marshal( const Pointer<commands::Command>& command,
00079                               const activemq::transport::Transport* transport,
00080                               decaf::io::DataOutputStream* out );
00081 
00092         virtual Pointer<commands::Command> unmarshal( const activemq::transport::Transport* transport,
00093                                                       decaf::io::DataInputStream* in );
00094 
00099         virtual void setVersion( int version AMQCPP_UNUSED ) {}
00100 
00105         virtual int getVersion() const {
00106             return 1;
00107         }
00108 
00114         virtual bool inReceive() const {
00115             return this->receiving.get();
00116         }
00117 
00123         virtual bool hasNegotiator() const {
00124             return false;
00125         }
00126 
00133         virtual Pointer<transport::Transport> createNegotiator(
00134             const Pointer<transport::Transport>& transport );
00135 
00136     private:
00137 
00138         Pointer<Command> unmarshalMessage( const Pointer<StompFrame>& frame );
00139         Pointer<Command> unmarshalReceipt( const Pointer<StompFrame>& frame );
00140         Pointer<Command> unmarshalConnected( const Pointer<StompFrame>& frame );
00141         Pointer<Command> unmarshalError( const Pointer<StompFrame>& frame );
00142 
00143         Pointer<StompFrame> marshalMessage( const Pointer<Command>& command );
00144         Pointer<StompFrame> marshalAck( const Pointer<Command>& command );
00145         Pointer<StompFrame> marshalConnectionInfo( const Pointer<Command>& command );
00146         Pointer<StompFrame> marshalTransactionInfo( const Pointer<Command>& command );
00147         Pointer<StompFrame> marshalShutdownInfo( const Pointer<Command>& command );
00148         Pointer<StompFrame> marshalRemoveInfo( const Pointer<Command>& command );
00149         Pointer<StompFrame> marshalConsumerInfo( const Pointer<Command>& command );
00150         Pointer<StompFrame> marshalRemoveSubscriptionInfo( const Pointer<Command>& command );
00151 
00152     };
00153 
00154 }}}
00155 
00156 #endif /* _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ */