activemq-cpp-3.4.0

src/main/activemq/state/TransactionState.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_STATE_TRANSACTIONSTATE_H_
00019 #define _ACTIVEMQ_STATE_TRANSACTIONSTATE_H_
00020 
00021 #include <activemq/util/Config.h>
00022 #include <activemq/commands/Command.h>
00023 #include <activemq/commands/ProducerId.h>
00024 #include <activemq/commands/TransactionId.h>
00025 
00026 #include <decaf/lang/Pointer.h>
00027 #include <decaf/util/LinkedList.h>
00028 #include <decaf/util/concurrent/atomic/AtomicBoolean.h>
00029 #include <decaf/util/concurrent/ConcurrentStlMap.h>
00030 
00031 #include <string>
00032 #include <memory>
00033 
00034 namespace activemq {
00035 namespace state {
00036 
00037     using decaf::lang::Pointer;
00038     using decaf::util::LinkedList;
00039     using decaf::util::concurrent::atomic::AtomicBoolean;
00040     using decaf::util::concurrent::ConcurrentStlMap;
00041     using namespace activemq::commands;
00042 
00043     class ProducerState;
00044 
00045     class AMQCPP_API TransactionState {
00046     private:
00047 
00048         LinkedList< Pointer<Command> > commands;
00049         Pointer<TransactionId> id;
00050         AtomicBoolean disposed;
00051         bool prepared;
00052         int preparedResult;
00053         ConcurrentStlMap< Pointer<ProducerId>, Pointer<ProducerState>,
00054                           ProducerId::COMPARATOR > producers;
00055 
00056     public:
00057 
00058         TransactionState( const Pointer<TransactionId>& id );
00059 
00060         virtual ~TransactionState();
00061 
00062         std::string toString() const;
00063 
00064         void addCommand( const Pointer<Command>& operation );
00065 
00066         void checkShutdown() const;
00067 
00068         void shutdown() {
00069             this->disposed.set( true );
00070         }
00071 
00072         const LinkedList< Pointer<Command> >& getCommands() const {
00073             return commands;
00074         }
00075 
00076         const Pointer<TransactionId>& getId() const {
00077             return id;
00078         }
00079 
00080         void setPrepared( bool prepared ) {
00081             this->prepared = prepared;
00082         }
00083 
00084         bool isPrepared() const {
00085             return this->prepared;
00086         }
00087 
00088         void setPreparedResult( int preparedResult ) {
00089             this->preparedResult = preparedResult;
00090         }
00091 
00092         int getPreparedResult() const {
00093             return this->preparedResult;
00094         }
00095 
00096         void addProducerState( const Pointer<ProducerState>& producerState );
00097 
00098         std::vector< Pointer<ProducerState> > getProducerStates();
00099 
00100     };
00101 
00102 }}
00103 
00104 #endif /*_ACTIVEMQ_STATE_TRANSACTIONSTATE_H_*/