Qpid Management Framework  0.24
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Console.h
Go to the documentation of this file.
1 #ifndef _QmfEngineConsole_
2 #define _QmfEngineConsole_
3 
4 /*
5  * Licensed to the Apache Software Foundation (ASF) under one
6  * or more contributor license agreements. See the NOTICE file
7  * distributed with this work for additional information
8  * regarding copyright ownership. The ASF licenses this file
9  * to you under the Apache License, Version 2.0 (the
10  * "License"); you may not use this file except in compliance
11  * with the License. You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing,
16  * software distributed under the License is distributed on an
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  * KIND, either express or implied. See the License for the
19  * specific language governing permissions and limitations
20  * under the License.
21  */
22 
24 #include <qmf/engine/Schema.h>
25 #include <qmf/engine/ObjectId.h>
26 #include <qmf/engine/Object.h>
27 #include <qmf/engine/Event.h>
28 #include <qmf/engine/Query.h>
29 #include <qmf/engine/Value.h>
30 #include <qmf/engine/Message.h>
31 
32 namespace qmf {
33 namespace engine {
34 
35  class Console;
36  class ConsoleImpl;
37  class BrokerProxyImpl;
38  class AgentProxy;
39  struct AgentProxyImpl;
40  struct MethodResponseImpl;
41  struct QueryResponseImpl;
42  struct QueryContext;
43 
48  public:
49  MethodResponse(const MethodResponse& from);
51  uint32_t getStatus() const;
52  const Value* getException() const;
53  const Value* getArgs() const;
54 
55  private:
56  friend struct MethodResponseImpl;
57  friend class ConsoleImpl;
59  MethodResponseImpl* impl;
60  };
61 
65  class QueryResponse {
66  public:
68  uint32_t getStatus() const;
69  const Value* getException() const;
70  uint32_t getObjectCount() const;
71  const Object* getObject(uint32_t idx) const;
72 
73  private:
74  friend struct QueryResponseImpl;
75  friend struct QueryContext;
77  QueryResponseImpl *impl;
78  };
79 
83  struct ConsoleEvent {
84  enum EventKind {
88  NEW_CLASS = 4,
92  };
93 
95  AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT])
96  char* name; // (NEW_PACKAGE)
97  const SchemaClassKey* classKey; // (NEW_CLASS)
98  Object* object; // (OBJECT_UPDATE)
99  void* context; // (OBJECT_UPDATE)
100  Event* event; // (EVENT_RECEIVED)
101  uint64_t timestamp; // (AGENT_HEARTBEAT)
102  QueryResponse* queryResponse; // (QUERY_COMPLETE)
103  bool hasProps;
104  bool hasStats;
105  };
106 
110  struct BrokerEvent {
111  enum EventKind {
115  BIND = 13,
116  UNBIND = 14,
118  STABLE = 16,
121  };
122 
124  char* name; // ([DECLARE|DELETE]_QUEUE, [UN]BIND)
125  char* exchange; // ([UN]BIND)
126  char* bindingKey; // ([UN]BIND)
127  void* context; // (QUERY_COMPLETE, METHOD_RESPONSE)
128  QueryResponse* queryResponse; // (QUERY_COMPLETE)
129  MethodResponse* methodResponse; // (METHOD_RESPONSE)
130  };
131 
135  class AgentProxy {
136  public:
137  AgentProxy(const AgentProxy& from);
138  ~AgentProxy();
139  const char* getLabel() const;
140  uint32_t getBrokerBank() const;
141  uint32_t getAgentBank() const;
142 
143  private:
144  friend struct StaticContext;
145  friend struct QueryContext;
146  friend struct AgentProxyImpl;
147  friend class BrokerProxyImpl;
148  AgentProxy(AgentProxyImpl* impl);
149  AgentProxyImpl* impl;
150  };
151 
155  class BrokerProxy {
156  public:
157  BrokerProxy(Console& console);
158  ~BrokerProxy();
159 
160  void sessionOpened(SessionHandle& sh);
161  void sessionClosed();
162  void startProtocol();
163 
164  void handleRcvMessage(Message& message);
165  bool getXmtMessage(Message& item) const;
166  void popXmt();
167 
168  bool getEvent(BrokerEvent& event) const;
169  void popEvent();
170 
171  uint32_t agentCount() const;
172  const AgentProxy* getAgent(uint32_t idx) const;
173  void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0);
174 
175  private:
176  friend class ConsoleImpl;
177  friend struct StaticContext;
178  BrokerProxyImpl* impl;
179  };
180 
181  // TODO - move this to a public header
184  bool rcvEvents;
187 
189  rcvObjects(true),
190  rcvEvents(true),
191  rcvHeartbeats(true),
192  userBindings(false) {}
193  };
194 
195  class Console {
196  public:
197  Console(const ConsoleSettings& settings = ConsoleSettings());
198  ~Console();
199 
200  bool getEvent(ConsoleEvent& event) const;
201  void popEvent();
202 
203  void addConnection(BrokerProxy& broker, void* context);
204  void delConnection(BrokerProxy& broker);
205 
206  uint32_t packageCount() const;
207  const char* getPackageName(uint32_t idx) const;
208 
209  uint32_t classCount(const char* packageName) const;
210  const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const;
211 
212  ClassKind getClassKind(const SchemaClassKey* key) const;
213  const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const;
214  const SchemaEventClass* getEventClass(const SchemaClassKey* key) const;
215 
216  void bindPackage(const char* packageName);
217  void bindClass(const SchemaClassKey* key);
218  void bindClass(const char* packageName, const char* className);
219 
220  void bindEvent(const SchemaClassKey *key);
221  void bindEvent(const char* packageName, const char* eventName);
222 
223  /*
224  void startSync(const Query& query, void* context, SyncQuery& sync);
225  void touchSync(SyncQuery& sync);
226  void endSync(SyncQuery& sync);
227  */
228 
229  private:
230  friend class BrokerProxyImpl;
231  friend struct AgentProxyImpl;
232  friend struct StaticContext;
233  ConsoleImpl* impl;
234  };
235 }
236 }
237 
238 #endif
239