Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
ManagementObject.h
Go to the documentation of this file.
1 #ifndef _ManagementObject_
2 #define _ManagementObject_
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
25 
26 #include "qpid/management/Mutex.h"
27 #include "qpid/types/Variant.h"
28 #include <map>
29 #include <vector>
30 
31 #ifdef _IN_QPID_BROKER
32 #include <boost/shared_ptr.hpp>
33 #endif
34 
35 namespace qpid {
36 namespace management {
37 
38 class Manageable;
39 class ObjectId;
40 class ManagementObject;
41 
42 
44  friend class ObjectId;
45 private:
46  uint64_t first;
47 public:
48  AgentAttachment() : first(0) {}
50  uint64_t getFirst() const { return first; }
51 };
52 
53 
54 class ObjectId {
55 protected:
57  uint64_t first;
58  uint64_t second;
59  uint64_t agentEpoch;
60  std::string v2Key;
61  std::string agentName;
62  void fromString(const std::string&);
63 public:
66  agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); }
69  QPID_COMMON_EXTERN ObjectId(std::istream&);
70  QPID_COMMON_EXTERN ObjectId(const std::string&);
71  QPID_COMMON_INLINE_EXTERN ObjectId(const std::string& agentAddress, const std::string& key,
72  uint64_t epoch=0) : agent(0), first(0), second(0),
73  agentEpoch(epoch), v2Key(key), agentName(agentAddress) {}
74 
75  // Deprecated:
76  QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object);
77  QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const;
78  QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const;
81  QPID_COMMON_EXTERN operator types::Variant::Map() const;
83  QPID_COMMON_EXTERN void encode(std::string& buffer) const;
84  QPID_COMMON_EXTERN void decode(const std::string& buffer);
85  QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const;
86  QPID_COMMON_INLINE_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; }
87  QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object);
88  QPID_COMMON_INLINE_EXTERN void setAgentName(const std::string& _name) { agentName = _name; }
89  QPID_COMMON_INLINE_EXTERN const std::string& getAgentName() const { return agentName; }
90  QPID_COMMON_INLINE_EXTERN const std::string& getV2Key() const { return v2Key; }
91  friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&);
92 };
93 
95 public:
96  static const uint8_t TYPE_U8 = 1;
97  static const uint8_t TYPE_U16 = 2;
98  static const uint8_t TYPE_U32 = 3;
99  static const uint8_t TYPE_U64 = 4;
100  static const uint8_t TYPE_SSTR = 6;
101  static const uint8_t TYPE_LSTR = 7;
102  static const uint8_t TYPE_ABSTIME = 8;
103  static const uint8_t TYPE_DELTATIME = 9;
104  static const uint8_t TYPE_REF = 10;
105  static const uint8_t TYPE_BOOL = 11;
106  static const uint8_t TYPE_FLOAT = 12;
107  static const uint8_t TYPE_DOUBLE = 13;
108  static const uint8_t TYPE_UUID = 14;
109  static const uint8_t TYPE_FTABLE = 15;
110  static const uint8_t TYPE_S8 = 16;
111  static const uint8_t TYPE_S16 = 17;
112  static const uint8_t TYPE_S32 = 18;
113  static const uint8_t TYPE_S64 = 19;
114  static const uint8_t TYPE_LIST = 21;
115 
116  static const uint8_t ACCESS_RC = 1;
117  static const uint8_t ACCESS_RW = 2;
118  static const uint8_t ACCESS_RO = 3;
119 
120  static const uint8_t DIR_I = 1;
121  static const uint8_t DIR_O = 2;
122  static const uint8_t DIR_IO = 3;
123 
124  static const uint8_t FLAG_CONFIG = 0x01;
125  static const uint8_t FLAG_INDEX = 0x02;
126  static const uint8_t FLAG_END = 0x80;
127 
128  const static uint8_t CLASS_KIND_TABLE = 1;
129  const static uint8_t CLASS_KIND_EVENT = 2;
130 
131 
132 
133 public:
134  virtual ~ManagementItem() {}
135 };
136 
138 {
139 protected:
140 
141  uint64_t createTime;
142  uint64_t destroyTime;
143  uint64_t updateTime;
145  mutable bool configChanged;
146  mutable bool instChanged;
147  bool deleted;
149  mutable Mutex accessLock;
151 
152  static int nextThreadIndex;
154 
155  QPID_COMMON_EXTERN int getThreadIndex();
156  QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const;
157  QPID_COMMON_EXTERN void readTimestamps(const std::string& buf);
158  QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const;
159 
160  public:
161 #ifdef _IN_QPID_BROKER
162  typedef boost::shared_ptr<ManagementObject> shared_ptr;
163 #endif
164 
165  QPID_COMMON_EXTERN static const uint8_t MD5_LEN = 16;
167  //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&);
168  typedef void (*writeSchemaCall_t) (std::string&);
169 
171  virtual ~ManagementObject() {}
172 
173  virtual writeSchemaCall_t getWriteSchemaCall() = 0;
174  virtual std::string getKey() const = 0;
175 
176  // Encode & Decode the property and statistics values
177  // for this object.
178  virtual void mapEncodeValues(types::Variant::Map& map,
179  bool includeProperties,
180  bool includeStatistics) = 0;
181  virtual void mapDecodeValues(const types::Variant::Map& map) = 0;
182  virtual void doMethod(std::string& methodName,
183  const types::Variant::Map& inMap,
184  types::Variant::Map& outMap,
185  const std::string& userId) = 0;
186  QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const;
187  QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf);
188 
193  virtual uint32_t writePropertiesSize() const { return 0; }
194  virtual void readProperties(const std::string&) {}
195  virtual void writeProperties(std::string&) const {}
196  virtual void writeStatistics(std::string&, bool = false) {}
197  virtual void doMethod(std::string&, const std::string&, std::string&, const std::string&) {}
198 
199  QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId);
200 
201  virtual std::string& getClassName() const = 0;
202  virtual std::string& getPackageName() const = 0;
203  virtual uint8_t* getMd5Sum() const = 0;
204 
205  void setObjectId(ObjectId oid) { objectId = oid; }
206  ObjectId getObjectId() { return objectId; }
207  inline bool getConfigChanged() { return configChanged; }
208  virtual bool getInstChanged() { return instChanged; }
209  virtual bool hasInst() { return true; }
210  inline void setForcePublish(bool f) { forcePublish = f; }
211  inline bool getForcePublish() { return forcePublish; }
212  QPID_COMMON_EXTERN void setUpdateTime();
213  QPID_COMMON_EXTERN void resourceDestroy();
214  inline bool isDeleted() { return deleted; }
215  inline void setFlags(uint32_t f) { flags = f; }
216  inline uint32_t getFlags() { return flags; }
218  for (int idx = 0; idx < MD5_LEN; idx++)
219  if (other.getMd5Sum()[idx] != getMd5Sum()[idx])
220  return false;
221  return other.getClassName() == getClassName() &&
222  other.getPackageName() == getPackageName();
223  }
224 
225  // QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); }
226  // QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); }
227  //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); }
228 
229  // Encode/Decode the entire object as a map
230  //QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map,
231  //bool includeProperties=true,
232  //bool includeStatistics=true);
233 
234  //QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map);
235 };
236 
237 #ifdef _IN_QPID_BROKER
238 typedef std::map<ObjectId, ManagementObject::shared_ptr> ManagementObjectMap;
239 typedef std::vector<ManagementObject::shared_ptr> ManagementObjectVector;
240 #endif
241 
242 }}
243 
244 
245 
246 #endif

Qpid C++ API Reference
Generated on Thu Dec 5 2013 for Qpid C++ Client API by doxygen 1.8.3.1