activemq-cpp-3.8.2
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 #include <activemq/util/Config.h>
24 #include <cms/Destination.h>
25 #include <decaf/lang/Pointer.h>
26 #include <decaf/lang/Comparable.h>
27 #include <decaf/util/ArrayList.h>
28 
29 #include <vector>
30 #include <string>
31 #include <map>
32 
33 namespace activemq {
34 namespace commands {
35 
37 
39  public decaf::lang::Comparable<ActiveMQDestination> {
40  protected:
41 
43  static const std::string ANY_CHILD;
44  static const std::string ANY_DESCENDENT;
45  };
46 
50  static const std::string DEFAULT_ORDERED_TARGET;
51 
52  static const std::string TEMP_PREFIX;
53  static const std::string TEMP_POSTFIX;
54  static const std::string COMPOSITE_SEPARATOR;
55 
56  static const std::string QUEUE_QUALIFIED_PREFIX;
57  static const std::string TOPIC_QUALIFIED_PREFIX;
58  static const std::string TEMP_QUEUE_QUALIFED_PREFIX;
59  static const std::string TEMP_TOPIC_QUALIFED_PREFIX;
60 
61  // Cached transient data
62  bool exclusive;
63  bool ordered;
64  bool advisory;
66  std::string orderedTarget;
67 
68  std::string physicalName;
70  int hashCode;
71 
72  public:
73 
74  const static unsigned char ID_ACTIVEMQDESTINATION = 0;
75 
76  static const std::string TEMP_DESTINATION_NAME_PREFIX;
77 
79 
80  private:
81 
83  ActiveMQDestination& operator=(const ActiveMQDestination&);
84 
85  public:
86 
88 
89  ActiveMQDestination(const std::string& physicalName);
90 
91  virtual ~ActiveMQDestination() throw();
92 
93  virtual ActiveMQDestination* cloneDataStructure() const {
94  return NULL;
95  }
96 
97  virtual void copyDataStructure(const DataStructure* src);
98 
99  virtual bool equals(const DataStructure* value) const;
100 
101  virtual unsigned char getDataStructureType() const;
102 
103  virtual std::string toString() const;
104 
105  int getHashCode() const {
106  return this->hashCode;
107  }
108 
109  public:
110 
115  virtual std::string getPhysicalName() const {
116  return this->physicalName;
117  }
118 
123  virtual void setPhysicalName(const std::string& physicalName);
124 
128  virtual bool isAdvisory() const {
129  return advisory;
130  }
131 
135  virtual void setAdvisory(bool advisory) {
136  this->advisory = advisory;
137  }
138 
142  virtual bool isExclusive() const {
143  return exclusive;
144  }
145 
149  virtual void setExclusive( bool exclusive ) {
150  this->exclusive = exclusive;
151  }
152 
156  virtual bool isOrdered() const {
157  return ordered;
158  }
159 
163  virtual void setOrdered(bool ordered) {
164  this->ordered = ordered;
165  }
166 
170  virtual std::string getOrderedTarget() const {
171  return orderedTarget;
172  }
173 
177  virtual void setOrderedTarget(const std::string& orderedTarget) {
178  this->orderedTarget = orderedTarget;
179  }
180 
185  virtual cms::Destination::DestinationType getDestinationType() const = 0;
186 
193  std::string getDestinationTypeAsString() const;
194 
199  virtual bool isTemporary() const {
200  return getDestinationType() == cms::Destination::TEMPORARY_TOPIC ||
201  getDestinationType() == cms::Destination::TEMPORARY_QUEUE;
202  }
203 
208  virtual bool isTopic() const {
209  return getDestinationType() == cms::Destination::TOPIC ||
210  getDestinationType() == cms::Destination::TEMPORARY_TOPIC;
211  }
212 
217  virtual bool isQueue() const {
218  return !isTopic();
219  }
220 
229  virtual bool isComposite() const {
230  return physicalName.find_first_of(COMPOSITE_SEPARATOR) != std::string::npos;
231  }
232 
238  decaf::util::ArrayList< Pointer<ActiveMQDestination> > getCompositeDestinations() const;
239 
243  virtual bool isWildcard() const {
244  return physicalName.find_first_of(DestinationFilter::ANY_CHILD) != std::string::npos||
245  physicalName.find_first_of(DestinationFilter::ANY_DESCENDENT) != std::string::npos;
246  }
247 
252  return options;
253  }
254 
259  virtual const cms::Destination* getCMSDestination() const {
260  return NULL;
261  }
262 
272  Pointer<ActiveMQDestination> createDestination(const std::string& name) const {
273  return ActiveMQDestination::createDestination(getDestinationType(), name);
274  }
275 
276  virtual int compareTo(const ActiveMQDestination& value) const;
277 
278  virtual bool equals(const ActiveMQDestination& value) const;
279 
280  virtual bool operator==(const ActiveMQDestination& value) const;
281 
282  virtual bool operator<(const ActiveMQDestination& value) const;
283 
284  public: // Statics
285 
292  static std::string createTemporaryName(const std::string& clientId) {
293  return TEMP_PREFIX + clientId + TEMP_POSTFIX;
294  }
295 
302  static std::string getClientId(const ActiveMQDestination* destination);
303 
312  static Pointer<ActiveMQDestination> createDestination(int type, const std::string& name);
313 
314  };
315 
316 }}
317 
318 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_*/
int hashCode
Definition: ActiveMQDestination.h:70
static const std::string TOPIC_QUALIFIED_PREFIX
Definition: ActiveMQDestination.h:57
bool advisory
Definition: ActiveMQDestination.h:64
virtual void setAdvisory(bool advisory)
Definition: ActiveMQDestination.h:135
virtual std::string getOrderedTarget() const
Definition: ActiveMQDestination.h:170
static const std::string ANY_CHILD
Definition: ActiveMQDestination.h:43
A Destination object encapsulates a provider-specific address.
Definition: Destination.h:39
#define AMQCPP_API
Definition: Config.h:30
virtual const cms::Destination * getCMSDestination() const
Definition: ActiveMQDestination.h:259
Definition: BaseDataStructure.h:33
virtual bool isOrdered() const
Definition: ActiveMQDestination.h:156
#define NULL
Definition: Config.h:33
std::string orderedTarget
Definition: ActiveMQDestination.h:66
static const std::string TEMP_PREFIX
Definition: ActiveMQDestination.h:52
virtual bool isTopic() const
Returns true if a Topic Destination.
Definition: ActiveMQDestination.h:208
virtual bool isExclusive() const
Definition: ActiveMQDestination.h:142
virtual std::string getPhysicalName() const
Fetch this destination&#39;s physical name.
Definition: ActiveMQDestination.h:115
Definition: DataStructure.h:27
static const std::string TEMP_QUEUE_QUALIFED_PREFIX
Definition: ActiveMQDestination.h:58
static const std::string TEMP_POSTFIX
Definition: ActiveMQDestination.h:53
virtual bool isTemporary() const
Returns true if a temporary Destination.
Definition: ActiveMQDestination.h:199
decaf::util::ArrayList< Pointer< ActiveMQDestination > > compositeDestinations
Definition: ActiveMQDestination.h:65
Definition: Destination.h:43
Definition: Destination.h:46
util::ActiveMQProperties options
Definition: ActiveMQDestination.h:69
virtual bool isComposite() const
Returns true if this destination represents a collection of destinations; allowing a set of destinati...
Definition: ActiveMQDestination.h:229
virtual bool isWildcard() const
Definition: ActiveMQDestination.h:243
const activemq::util::ActiveMQProperties & getOptions() const
Definition: ActiveMQDestination.h:251
virtual void setOrderedTarget(const std::string &orderedTarget)
Definition: ActiveMQDestination.h:177
static const std::string TEMP_TOPIC_QUALIFED_PREFIX
Definition: ActiveMQDestination.h:59
static const std::string TEMP_DESTINATION_NAME_PREFIX
Definition: ActiveMQDestination.h:76
DestinationType
Definition: Destination.h:42
Definition: ArrayList.h:39
bool ordered
Definition: ActiveMQDestination.h:63
virtual void setOrdered(bool ordered)
Definition: ActiveMQDestination.h:163
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
static std::string createTemporaryName(const std::string &clientId)
Create a temporary name from the clientId.
Definition: ActiveMQDestination.h:292
static const std::string ANY_DESCENDENT
Definition: ActiveMQDestination.h:44
Pointer< ActiveMQDestination > createDestination(const std::string &name) const
Create a new Destination that&#39;s of the same type as this one but with the given destination name...
Definition: ActiveMQDestination.h:272
virtual bool isQueue() const
Returns true if a Queue Destination.
Definition: ActiveMQDestination.h:217
std::string physicalName
Definition: ActiveMQDestination.h:68
static const std::string QUEUE_QUALIFIED_PREFIX
Definition: ActiveMQDestination.h:56
static const std::string DEFAULT_ORDERED_TARGET
The default target for ordered destinations.
Definition: ActiveMQDestination.h:50
bool operator==(const ArrayPointer< T > &left, const U *right)
Definition: ArrayPointer.h:379
This implementation of Comparator is designed to allows objects in a Collection to be sorted or teste...
Definition: Pointer.h:366
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
static const std::string COMPOSITE_SEPARATOR
Definition: ActiveMQDestination.h:54
Definition: Destination.h:45
Implementation of the CMSProperties interface that delegates to a decaf::util::Properties object...
Definition: ActiveMQProperties.h:37
decaf::lang::PointerComparator< ActiveMQDestination > COMPARATOR
Definition: ActiveMQDestination.h:78
int getHashCode() const
Definition: ActiveMQDestination.h:105
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
Definition: ActiveMQDestination.h:38
virtual bool isAdvisory() const
Definition: ActiveMQDestination.h:128
bool exclusive
Definition: ActiveMQDestination.h:62
virtual void setExclusive(bool exclusive)
Definition: ActiveMQDestination.h:149