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 <boost/shared_ptr.hpp>
29 #include <map>
30 #include <vector>
31 
32 namespace qpid {
33 namespace management {
34 
35 class Manageable;
36 class ObjectId;
37 class ManagementObject;
38 
39 
41  friend class ObjectId;
42 private:
43  uint64_t first;
44 public:
45  AgentAttachment() : first(0) {}
47  uint64_t getFirst() const { return first; }
48 };
49 
50 
51 class ObjectId {
52 protected:
54  uint64_t first;
55  uint64_t second;
56  uint64_t agentEpoch;
57  std::string v2Key;
58  std::string agentName;
59  void fromString(const std::string&);
60 public:
63  agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); }
66  QPID_COMMON_EXTERN ObjectId(std::istream&);
67  QPID_COMMON_EXTERN ObjectId(const std::string&);
68  QPID_COMMON_INLINE_EXTERN ObjectId(const std::string& agentAddress, const std::string& key,
69  uint64_t epoch=0) : agent(0), first(0), second(0),
70  agentEpoch(epoch), v2Key(key), agentName(agentAddress) {}
71 
72  // Deprecated:
73  QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object);
74  QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const;
75  QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const;
78  QPID_COMMON_EXTERN operator types::Variant::Map() const;
80  QPID_COMMON_EXTERN void encode(std::string& buffer) const;
81  QPID_COMMON_EXTERN void decode(const std::string& buffer);
82  QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const;
83  QPID_COMMON_INLINE_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; }
84  QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object);
85  QPID_COMMON_INLINE_EXTERN void setAgentName(const std::string& _name) { agentName = _name; }
86  QPID_COMMON_INLINE_EXTERN const std::string& getAgentName() const { return agentName; }
87  QPID_COMMON_INLINE_EXTERN const std::string& getV2Key() const { return v2Key; }
88  friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&);
89 };
90 
92 public:
93  static const uint8_t TYPE_U8 = 1;
94  static const uint8_t TYPE_U16 = 2;
95  static const uint8_t TYPE_U32 = 3;
96  static const uint8_t TYPE_U64 = 4;
97  static const uint8_t TYPE_SSTR = 6;
98  static const uint8_t TYPE_LSTR = 7;
99  static const uint8_t TYPE_ABSTIME = 8;
100  static const uint8_t TYPE_DELTATIME = 9;
101  static const uint8_t TYPE_REF = 10;
102  static const uint8_t TYPE_BOOL = 11;
103  static const uint8_t TYPE_FLOAT = 12;
104  static const uint8_t TYPE_DOUBLE = 13;
105  static const uint8_t TYPE_UUID = 14;
106  static const uint8_t TYPE_FTABLE = 15;
107  static const uint8_t TYPE_S8 = 16;
108  static const uint8_t TYPE_S16 = 17;
109  static const uint8_t TYPE_S32 = 18;
110  static const uint8_t TYPE_S64 = 19;
111  static const uint8_t TYPE_LIST = 21;
112 
113  static const uint8_t ACCESS_RC = 1;
114  static const uint8_t ACCESS_RW = 2;
115  static const uint8_t ACCESS_RO = 3;
116 
117  static const uint8_t DIR_I = 1;
118  static const uint8_t DIR_O = 2;
119  static const uint8_t DIR_IO = 3;
120 
121  static const uint8_t FLAG_CONFIG = 0x01;
122  static const uint8_t FLAG_INDEX = 0x02;
123  static const uint8_t FLAG_END = 0x80;
124 
125  const static uint8_t CLASS_KIND_TABLE = 1;
126  const static uint8_t CLASS_KIND_EVENT = 2;
127 
128 
129 
130 public:
131  virtual ~ManagementItem() {}
132 };
133 
135 {
136 protected:
137 
138  uint64_t createTime;
139  uint64_t destroyTime;
140  uint64_t updateTime;
142  mutable bool configChanged;
143  mutable bool instChanged;
144  bool deleted;
146  mutable Mutex accessLock;
148 
149  static int nextThreadIndex;
151 
152  QPID_COMMON_EXTERN int getThreadIndex();
153  QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const;
154  QPID_COMMON_EXTERN void readTimestamps(const std::string& buf);
155  QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const;
156 
157  public:
158  typedef boost::shared_ptr<ManagementObject> shared_ptr;
159 
160  QPID_COMMON_EXTERN static const uint8_t MD5_LEN = 16;
162  //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&);
163  typedef void (*writeSchemaCall_t) (std::string&);
164 
166  virtual ~ManagementObject() {}
167 
168  virtual writeSchemaCall_t getWriteSchemaCall() = 0;
169  virtual std::string getKey() const = 0;
170 
171  // Encode & Decode the property and statistics values
172  // for this object.
173  virtual void mapEncodeValues(types::Variant::Map& map,
174  bool includeProperties,
175  bool includeStatistics) = 0;
176  virtual void mapDecodeValues(const types::Variant::Map& map) = 0;
177  virtual void doMethod(std::string& methodName,
178  const types::Variant::Map& inMap,
179  types::Variant::Map& outMap,
180  const std::string& userId) = 0;
181  QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const;
182  QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf);
183 
188  virtual uint32_t writePropertiesSize() const { return 0; }
189  virtual void readProperties(const std::string&) {}
190  virtual void writeProperties(std::string&) const {}
191  virtual void writeStatistics(std::string&, bool = false) {}
192  virtual void doMethod(std::string&, const std::string&, std::string&, const std::string&) {}
193 
194  QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId);
195 
196  virtual std::string& getClassName() const = 0;
197  virtual std::string& getPackageName() const = 0;
198  virtual uint8_t* getMd5Sum() const = 0;
199 
200  void setObjectId(ObjectId oid) { objectId = oid; }
201  ObjectId getObjectId() { return objectId; }
202  inline bool getConfigChanged() { return configChanged; }
203  virtual bool getInstChanged() { return instChanged; }
204  virtual bool hasInst() { return true; }
205  inline void setForcePublish(bool f) { forcePublish = f; }
206  inline bool getForcePublish() { return forcePublish; }
207  QPID_COMMON_EXTERN void setUpdateTime();
208  QPID_COMMON_EXTERN void resourceDestroy();
209  inline bool isDeleted() { return deleted; }
210  inline void setFlags(uint32_t f) { flags = f; }
211  inline uint32_t getFlags() { return flags; }
213  for (int idx = 0; idx < MD5_LEN; idx++)
214  if (other.getMd5Sum()[idx] != getMd5Sum()[idx])
215  return false;
216  return other.getClassName() == getClassName() &&
217  other.getPackageName() == getPackageName();
218  }
219 
220  // QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); }
221  // QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); }
222  //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); }
223 
224  // Encode/Decode the entire object as a map
225  //QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map,
226  //bool includeProperties=true,
227  //bool includeStatistics=true);
228 
229  //QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map);
230 };
231 
232 typedef std::map<ObjectId, ManagementObject::shared_ptr> ManagementObjectMap;
233 typedef std::vector<ManagementObject::shared_ptr> ManagementObjectVector;
234 
235 }}
236 
237 
238 
239 #endif

Qpid C++ API Reference
Generated on Thu Feb 14 2013 for Qpid C++ Client API by doxygen 1.8.3