activemq-cpp-3.6.0
ActiveMQDestination.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_ACTIVEMQDESTINATION_H_
19 #define _ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_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/Destination.h>
30 #include <decaf/lang/Pointer.h>
31 #include <decaf/lang/Comparable.h>
32 #include <decaf/util/ArrayList.h>
33 
34 #include <vector>
35 #include <string>
36 #include <map>
37 
38 namespace activemq{
39 namespace commands{
40 
42 
44  public decaf::lang::Comparable<ActiveMQDestination> {
45  protected:
46 
48  static const std::string ANY_CHILD;
49  static const std::string ANY_DESCENDENT;
50  };
51 
55  static const std::string DEFAULT_ORDERED_TARGET;
56 
57  static const std::string TEMP_PREFIX;
58  static const std::string TEMP_POSTFIX;
59  static const std::string COMPOSITE_SEPARATOR;
60 
61  static const std::string QUEUE_QUALIFIED_PREFIX;
62  static const std::string TOPIC_QUALIFIED_PREFIX;
63  static const std::string TEMP_QUEUE_QUALIFED_PREFIX;
64  static const std::string TEMP_TOPIC_QUALIFED_PREFIX;
65 
66  // Cached transient data
67  bool exclusive;
68  bool ordered;
69  bool advisory;
71  std::string orderedTarget;
72 
73  std::string physicalName;
75 
76  public:
77 
78  const static unsigned char ID_ACTIVEMQDESTINATION = 0;
79 
81 
82  private:
83 
85  ActiveMQDestination& operator=(const ActiveMQDestination&);
86 
87  public:
88 
90 
91  ActiveMQDestination(const std::string& physicalName);
92 
93  virtual ~ActiveMQDestination() throw();
94 
95  virtual ActiveMQDestination* cloneDataStructure() const {
96  return NULL;
97  }
98 
99  virtual void copyDataStructure(const DataStructure* src);
100 
101  virtual bool equals(const DataStructure* value) const;
102 
103  virtual unsigned char getDataStructureType() const;
104 
105  virtual std::string toString() const;
106 
107  public:
108 
113  virtual std::string getPhysicalName() const {
114  return this->physicalName;
115  }
116 
121  virtual void setPhysicalName(const std::string& physicalName);
122 
126  virtual bool isAdvisory() const {
127  return advisory;
128  }
129 
133  virtual void setAdvisory(bool advisory) {
134  this->advisory = advisory;
135  }
136 
137 // /**
138 // * @return true if this is a destination for Consumer advisories
139 // */
140 // virtual bool isConsumerAdvisory() const {
141 // return isAdvisory() && physicalName.find(CONSUMER_ADVISORY_PREFIX) == 0;
142 // }
143 //
144 // /**
145 // * @return true if this is a destination for Producer advisories
146 // */
147 // virtual bool isProducerAdvisory() const {
148 // return isAdvisory() && physicalName.find(PRODUCER_ADVISORY_PREFIX) == 0;
149 // }
150 //
151 // /**
152 // * @return true if this is a destination for Connection advisories
153 // */
154 // virtual bool isConnectionAdvisory() const {
155 // return isAdvisory() && physicalName.find(CONNECTION_ADVISORY_PREFIX) == 0;
156 // }
157 
161  virtual bool isExclusive() const {
162  return exclusive;
163  }
164 
168  virtual void setExclusive( bool exclusive ) {
169  this->exclusive = exclusive;
170  }
171 
175  virtual bool isOrdered() const {
176  return ordered;
177  }
178 
182  virtual void setOrdered(bool ordered) {
183  this->ordered = ordered;
184  }
185 
189  virtual std::string getOrderedTarget() const {
190  return orderedTarget;
191  }
192 
196  virtual void setOrderedTarget(const std::string& orderedTarget) {
197  this->orderedTarget = orderedTarget;
198  }
199 
204  virtual cms::Destination::DestinationType getDestinationType() const = 0;
205 
212  std::string getDestinationTypeAsString() const;
213 
218  virtual bool isTemporary() const {
219  return getDestinationType() == cms::Destination::TEMPORARY_TOPIC ||
220  getDestinationType() == cms::Destination::TEMPORARY_QUEUE;
221  }
222 
227  virtual bool isTopic() const {
228  return getDestinationType() == cms::Destination::TOPIC ||
229  getDestinationType() == cms::Destination::TEMPORARY_TOPIC;
230  }
231 
236  virtual bool isQueue() const {
237  return !isTopic();
238  }
239 
248  virtual bool isComposite() const {
249  return physicalName.find_first_of(COMPOSITE_SEPARATOR) != std::string::npos;
250  }
251 
257  decaf::util::ArrayList< Pointer<ActiveMQDestination> > getCompositeDestinations() const;
258 
262  virtual bool isWildcard() const {
263  return physicalName.find_first_of(DestinationFilter::ANY_CHILD) != std::string::npos||
264  physicalName.find_first_of(DestinationFilter::ANY_DESCENDENT) != std::string::npos;
265  }
266 
271  return options;
272  }
273 
278  virtual const cms::Destination* getCMSDestination() const {
279  return NULL;
280  }
281 
291  Pointer<ActiveMQDestination> createDestination(const std::string& name) const {
292  return ActiveMQDestination::createDestination(getDestinationType(), name);
293  }
294 
295  virtual int compareTo(const ActiveMQDestination& value) const;
296 
297  virtual bool equals(const ActiveMQDestination& value) const;
298 
299  virtual bool operator==(const ActiveMQDestination& value) const;
300 
301  virtual bool operator<(const ActiveMQDestination& value) const;
302 
303  public: // Statics
304 
311  static std::string createTemporaryName(const std::string& clientId) {
312  return TEMP_PREFIX + clientId + TEMP_POSTFIX;
313  }
314 
321  static std::string getClientId(const ActiveMQDestination* destination);
322 
331  static Pointer<ActiveMQDestination> createDestination(int type, const std::string& name);
332 
333  };
334 
335 }}
336 
337 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_*/