activemq-cpp-3.6.0
ActiveMQConstants.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Apache Software Foundation or its licensors, as
3  * applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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 #ifndef _ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_
18 #define _ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_
19 
20 #include <string>
21 #include <map>
22 #include <activemq/util/Config.h>
23 
24 namespace activemq{
25 namespace core{
26 
33  public:
34 
35  // Flags to indicate Transaction States.
37  TRANSACTION_STATE_BEGIN = 0,
38  TRANSACTION_STATE_PREPARE = 1,
39  TRANSACTION_STATE_COMMITONEPHASE = 2,
40  TRANSACTION_STATE_COMMITTWOPHASE = 3,
41  TRANSACTION_STATE_ROLLBACK = 4,
42  TRANSACTION_STATE_RECOVER = 5,
43  TRANSACTION_STATE_FORGET = 6,
44  TRANSACTION_STATE_END = 7
45  };
46 
47  // Flags to be applied when sending the Destination Info Command.
49  DESTINATION_ADD_OPERATION = 0,
50  DESTINATION_REMOVE_OPERATION = 1
51  };
52 
53  // Represents the Acknowledgement types that are supported for the
54  // Message Ack Command.
55  enum AckType {
56  ACK_TYPE_DELIVERED = 0, // Message delivered but not consumed
57  ACK_TYPE_POISON = 1, // Message could not be processed due to
58  // poison pill but discard anyway
59  ACK_TYPE_CONSUMED = 2, // Message consumed, discard
60  ACK_TYPE_REDELIVERED = 3, // Message has been re-delivered.
61  ACK_TYPE_INDIVIDUAL = 4 // Acks a single message at a time.
62  };
63 
77  NUM_OPTIONS
78  };
79 
84  enum URIParam
85  {
96  NUM_PARAMS
97  };
98 
99  static const std::string& toString(const DestinationOption option) {
100  return StaticInitializer::destOptions[option];
101  }
102 
103  static DestinationOption toDestinationOption(const std::string& option) {
104  std::map<std::string, DestinationOption>::iterator iter = StaticInitializer::destOptionMap.find(option);
105 
106  if (iter == StaticInitializer::destOptionMap.end()) {
107  return NUM_OPTIONS;
108  }
109 
110  return iter->second;
111  }
112 
113  static const std::string& toString(const URIParam option) {
114  return StaticInitializer::uriParams[option];
115  }
116 
117  static URIParam toURIOption(const std::string& option) {
118  std::map<std::string, URIParam>::iterator iter = StaticInitializer::uriParamsMap.find(option);
119 
120  if (iter == StaticInitializer::uriParamsMap.end()) {
121  return NUM_PARAMS;
122  }
123 
124  return iter->second;
125  }
126 
128  public:
130  virtual ~StaticInitializer() {}
131 
132  static std::string destOptions[NUM_OPTIONS];
133  static std::string uriParams[NUM_PARAMS];
134  static std::map<std::string, DestinationOption> destOptionMap;
135  static std::map<std::string, URIParam> uriParamsMap;
136  };
137 
138  private:
139 
140  static StaticInitializer staticInits;
141 
142  };
143 
144 }}
145 
146 #endif /*_ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_*/