|
activemq-cpp-3.4.0
|
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_COMMANDS_ACTIVEMQDESTINATION_H_ 00019 #define _ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_ 00020 00021 // Turn off warning message for ignored exception specification 00022 #ifdef _MSC_VER 00023 #pragma warning( disable : 4290 ) 00024 #endif 00025 00026 #include <activemq/util/Config.h> 00027 #include <activemq/commands/BaseDataStructure.h> 00028 #include <activemq/util/ActiveMQProperties.h> 00029 #include <cms/Destination.h> 00030 #include <decaf/lang/Pointer.h> 00031 00032 #include <vector> 00033 #include <string> 00034 #include <map> 00035 00036 namespace activemq{ 00037 namespace commands{ 00038 00039 using decaf::lang::Pointer; 00040 00041 class AMQCPP_API ActiveMQDestination : public BaseDataStructure { 00042 protected: 00043 00044 struct DestinationFilter{ 00045 static const std::string ANY_CHILD; 00046 static const std::string ANY_DESCENDENT; 00047 }; 00048 00052 static const std::string ADVISORY_PREFIX; 00053 00057 static const std::string CONSUMER_ADVISORY_PREFIX; 00058 00062 static const std::string PRODUCER_ADVISORY_PREFIX; 00063 00067 static const std::string CONNECTION_ADVISORY_PREFIX; 00068 00072 static const std::string DEFAULT_ORDERED_TARGET; 00073 00074 static const std::string TEMP_PREFIX; 00075 static const std::string TEMP_POSTFIX; 00076 static const std::string COMPOSITE_SEPARATOR; 00077 00078 static const std::string QUEUE_QUALIFIED_PREFIX; 00079 static const std::string TOPIC_QUALIFIED_PREFIX; 00080 static const std::string TEMP_QUEUE_QUALIFED_PREFIX; 00081 static const std::string TEMP_TOPIC_QUALIFED_PREFIX; 00082 00083 // Cached transient data 00084 bool exclusive; 00085 bool ordered; 00086 bool advisory; 00087 std::string orderedTarget; 00088 00089 std::string physicalName; 00090 util::ActiveMQProperties options; 00091 00092 public: 00093 00094 const static unsigned char ID_ACTIVEMQDESTINATION = 0; 00095 00096 private: 00097 00098 ActiveMQDestination( const ActiveMQDestination& ); 00099 ActiveMQDestination& operator= ( const ActiveMQDestination& ); 00100 00101 public: 00102 00103 ActiveMQDestination(); 00104 00105 ActiveMQDestination( const std::string& physicalName ); 00106 00107 virtual ~ActiveMQDestination() throw(); 00108 00109 virtual ActiveMQDestination* cloneDataStructure() const { 00110 return NULL; 00111 } 00112 00113 virtual void copyDataStructure( const DataStructure* src ); 00114 00115 virtual bool equals( const DataStructure* value ) const; 00116 00117 virtual unsigned char getDataStructureType() const; 00118 00119 virtual std::string toString() const; 00120 00125 virtual const std::string& getPhysicalName() const { 00126 return this->physicalName; 00127 } 00128 virtual std::string& getPhysicalName() { 00129 return this->physicalName; 00130 } 00131 00136 virtual void setPhysicalName( const std::string& physicalName ); 00137 00141 virtual bool isAdvisory() const { 00142 return advisory; 00143 } 00144 00148 virtual void setAdvisory( bool advisory ){ 00149 this->advisory = advisory; 00150 } 00151 00155 virtual bool isConsumerAdvisory() const { 00156 return isAdvisory() && 00157 physicalName.find(CONSUMER_ADVISORY_PREFIX) == 0; 00158 } 00159 00163 virtual bool isProducerAdvisory() const { 00164 return isAdvisory() && 00165 physicalName.find(PRODUCER_ADVISORY_PREFIX) == 0; 00166 } 00167 00171 virtual bool isConnectionAdvisory() const { 00172 return isAdvisory() && 00173 physicalName.find(CONNECTION_ADVISORY_PREFIX) == 0; 00174 } 00175 00179 virtual bool isExclusive() const { 00180 return exclusive; 00181 } 00182 00186 virtual void setExclusive( bool exclusive ) { 00187 this->exclusive = exclusive; 00188 } 00189 00193 virtual bool isOrdered() const { 00194 return ordered; 00195 } 00196 00200 virtual void setOrdered( bool ordered ) { 00201 this->ordered = ordered; 00202 } 00203 00207 virtual std::string getOrderedTarget() const { 00208 return orderedTarget; 00209 } 00210 00214 virtual void setOrderedTarget( const std::string& orderedTarget) { 00215 this->orderedTarget = orderedTarget; 00216 } 00217 00218 public: // Statics 00219 00226 static std::string createTemporaryName( 00227 const std::string& clientId ) { 00228 00229 return TEMP_PREFIX + clientId + TEMP_POSTFIX; 00230 } 00231 00238 static std::string getClientId( const ActiveMQDestination* destination ); 00239 00248 static Pointer<ActiveMQDestination> createDestination( int type, const std::string& name ); 00249 00250 public: 00251 00256 virtual cms::Destination::DestinationType getDestinationType() const = 0; 00257 00262 virtual bool isTemporary() const { 00263 return getDestinationType() == cms::Destination::TEMPORARY_TOPIC || 00264 getDestinationType() == cms::Destination::TEMPORARY_QUEUE; 00265 } 00266 00271 virtual bool isTopic() const { 00272 return getDestinationType() == cms::Destination::TOPIC || 00273 getDestinationType() == cms::Destination::TEMPORARY_TOPIC; 00274 } 00275 00280 virtual bool isQueue() const { 00281 return !isTopic(); 00282 } 00283 00292 virtual bool isComposite() const { 00293 return physicalName.find_first_of( COMPOSITE_SEPARATOR ) > 0; 00294 } 00295 00299 virtual bool isWildcard() const { 00300 return physicalName.find_first_of( DestinationFilter::ANY_CHILD ) != std::string::npos || 00301 physicalName.find_first_of( DestinationFilter::ANY_DESCENDENT ) != std::string::npos; 00302 } 00303 00307 const activemq::util::ActiveMQProperties& getOptions() const { 00308 return options; 00309 } 00310 00315 virtual const cms::Destination* getCMSDestination() const { 00316 return NULL; 00317 } 00318 00319 }; 00320 00321 }} 00322 00323 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_*/