activemq-cpp-3.4.0

src/main/activemq/core/ActiveMQConstants.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2006 The Apache Software Foundation or its licensors, as
00003  * applicable.
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * 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 #ifndef ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_
00018 #define ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_
00019 
00020 #include <string>
00021 #include <map>
00022 #include <activemq/util/Config.h>
00023 
00024 namespace activemq{
00025 namespace core{
00026 
00032     class AMQCPP_API ActiveMQConstants{
00033     public:
00034 
00035         // Flags to indicate Transaction States.
00036         enum TransactionState {
00037             TRANSACTION_STATE_BEGIN = 0,
00038             TRANSACTION_STATE_PREPARE = 1,
00039             TRANSACTION_STATE_COMMITONEPHASE = 2,
00040             TRANSACTION_STATE_COMMITTWOPHASE = 3,
00041             TRANSACTION_STATE_ROLLBACK = 4,
00042             TRANSACTION_STATE_RECOVER = 5,
00043             TRANSACTION_STATE_FORGET = 6,
00044             TRANSACTION_STATE_END = 7
00045         };
00046 
00047         // Flags to be applied when sending the Destination Info Command.
00048         enum DestinationActions {
00049             DESTINATION_ADD_OPERATION = 0,
00050             DESTINATION_REMOVE_OPERATION = 1
00051         };
00052 
00053         // Represents the Acknowledgement types that are supported for the
00054         // Message Ack Command.
00055         enum AckType {
00056             ACK_TYPE_DELIVERED   = 0,  // Message delivered but not consumed
00057             ACK_TYPE_POISON      = 1,  // Message could not be processed due to
00058                                        // poison pill but discard anyway
00059             ACK_TYPE_CONSUMED    = 2,  // Message consumed, discard
00060             ACK_TYPE_REDELIVERED = 3,  // Message has been re-delivered.
00061             ACK_TYPE_INDIVIDUAL  = 4   // Acks a single message at a time.
00062         };
00063 
00068         enum DestinationOption{
00069             CONSUMER_PREFECTCHSIZE,
00070             CUNSUMER_MAXPENDINGMSGLIMIT,
00071             CONSUMER_NOLOCAL,
00072             CONSUMER_DISPATCHASYNC,
00073             CONSUMER_RETROACTIVE,
00074             CONSUMER_SELECTOR,
00075             CONSUMER_EXCLUSIVE,
00076             CONSUMER_PRIORITY,
00077             NUM_OPTIONS
00078         };
00079 
00084         enum URIParam
00085         {
00086             CONNECTION_SENDTIMEOUT,
00087             CONNECTION_PRODUCERWINDOWSIZE,
00088             CONNECTION_CLOSETIMEOUT,
00089             CONNECTION_ALWAYSSYNCSEND,
00090             CONNECTION_USEASYNCSEND,
00091             CONNECTION_USECOMPRESSION,
00092             CONNECTION_DISPATCHASYNC,
00093             PARAM_USERNAME,
00094             PARAM_PASSWORD,
00095             PARAM_CLIENTID,
00096             NUM_PARAMS
00097         };
00098 
00099         static const std::string& toString( const DestinationOption option ){
00100             return StaticInitializer::destOptions[option];
00101         }
00102 
00103         static DestinationOption toDestinationOption( const std::string& option ){
00104             std::map< std::string, DestinationOption >::iterator iter =
00105                 StaticInitializer::destOptionMap.find( option );
00106 
00107             if( iter == StaticInitializer::destOptionMap.end() ){
00108                 return NUM_OPTIONS;
00109             }
00110 
00111             return iter->second;
00112         }
00113 
00114         static const std::string& toString( const URIParam option ){
00115             return StaticInitializer::uriParams[option];
00116         }
00117 
00118         static URIParam toURIOption( const std::string& option ){
00119             std::map< std::string, URIParam >::iterator iter =
00120                 StaticInitializer::uriParamsMap.find( option );
00121 
00122             if( iter == StaticInitializer::uriParamsMap.end() ){
00123                 return NUM_PARAMS;
00124             }
00125 
00126             return iter->second;
00127         }
00128 
00129         class StaticInitializer{
00130         public:
00131             StaticInitializer();
00132             virtual ~StaticInitializer(){}
00133 
00134             static std::string destOptions[NUM_OPTIONS];
00135             static std::string uriParams[NUM_PARAMS];
00136             static std::map<std::string, DestinationOption> destOptionMap;
00137             static std::map<std::string, URIParam> uriParamsMap;
00138         };
00139 
00140     private:
00141 
00142         static StaticInitializer staticInits;
00143 
00144     };
00145 
00146 }}
00147 
00148 #endif /*ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_*/