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 
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  QPID_COMMON_EXTERN static const uint8_t MD5_LEN = 16;
160  //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&);
161  typedef void (*writeSchemaCall_t) (std::string&);
162 
164  virtual ~ManagementObject() {}
165 
166  virtual writeSchemaCall_t getWriteSchemaCall() = 0;
167  virtual std::string getKey() const = 0;
168 
169  // Encode & Decode the property and statistics values
170  // for this object.
171  virtual void mapEncodeValues(types::Variant::Map& map,
172  bool includeProperties,
173  bool includeStatistics) = 0;
174  virtual void mapDecodeValues(const types::Variant::Map& map) = 0;
175  virtual void doMethod(std::string& methodName,
176  const types::Variant::Map& inMap,
177  types::Variant::Map& outMap,
178  const std::string& userId) = 0;
179  QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const;
180  QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf);
181 
186  virtual uint32_t writePropertiesSize() const { return 0; }
187  virtual void readProperties(const std::string&) {}
188  virtual void writeProperties(std::string&) const {}
189  virtual void writeStatistics(std::string&, bool = false) {}
190  virtual void doMethod(std::string&, const std::string&, std::string&, const std::string&) {}
191 
192  QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId);
193 
194  virtual std::string& getClassName() const = 0;
195  virtual std::string& getPackageName() const = 0;
196  virtual uint8_t* getMd5Sum() const = 0;
197 
198  void setObjectId(ObjectId oid) { objectId = oid; }
199  ObjectId getObjectId() { return objectId; }
200  inline bool getConfigChanged() { return configChanged; }
201  virtual bool getInstChanged() { return instChanged; }
202  virtual bool hasInst() { return true; }
203  inline void setForcePublish(bool f) { forcePublish = f; }
204  inline bool getForcePublish() { return forcePublish; }
205  QPID_COMMON_EXTERN void setUpdateTime();
206  QPID_COMMON_EXTERN void resourceDestroy();
207  inline bool isDeleted() { return deleted; }
208  inline void setFlags(uint32_t f) { flags = f; }
209  inline uint32_t getFlags() { return flags; }
211  for (int idx = 0; idx < MD5_LEN; idx++)
212  if (other.getMd5Sum()[idx] != getMd5Sum()[idx])
213  return false;
214  return other.getClassName() == getClassName() &&
215  other.getPackageName() == getPackageName();
216  }
217 
218  // QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); }
219  // QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); }
220  //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); }
221 
222  // Encode/Decode the entire object as a map
223  //QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map,
224  //bool includeProperties=true,
225  //bool includeStatistics=true);
226 
227  //QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map);
228 };
229 
230 typedef std::map<ObjectId, ManagementObject*> ManagementObjectMap;
231 typedef std::vector<ManagementObject*> ManagementObjectVector;
232 
233 }}
234 
235 
236 
237 #endif

Qpid C++ API Reference
Generated on Tue Sep 25 2012 for Qpid C++ Client API by doxygen 1.8.1.1