Go to the documentation of this file.00001 #ifndef _QmfEngineConsole_
00002 #define _QmfEngineConsole_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <qmf/engine/ResilientConnection.h>
00024 #include <qmf/engine/Schema.h>
00025 #include <qmf/engine/ObjectId.h>
00026 #include <qmf/engine/Object.h>
00027 #include <qmf/engine/Event.h>
00028 #include <qmf/engine/Query.h>
00029 #include <qmf/engine/Value.h>
00030 #include <qmf/engine/Message.h>
00031
00032 namespace qmf {
00033 namespace engine {
00034
00035 class Console;
00036 class ConsoleImpl;
00037 class BrokerProxyImpl;
00038 class AgentProxy;
00039 struct AgentProxyImpl;
00040 struct MethodResponseImpl;
00041 struct QueryResponseImpl;
00042 struct QueryContext;
00043
00047 class MethodResponse {
00048 public:
00049 MethodResponse(const MethodResponse& from);
00050 ~MethodResponse();
00051 uint32_t getStatus() const;
00052 const Value* getException() const;
00053 const Value* getArgs() const;
00054
00055 private:
00056 friend struct MethodResponseImpl;
00057 friend class ConsoleImpl;
00058 MethodResponse(MethodResponseImpl* impl);
00059 MethodResponseImpl* impl;
00060 };
00061
00065 class QueryResponse {
00066 public:
00067 ~QueryResponse();
00068 uint32_t getStatus() const;
00069 const Value* getException() const;
00070 uint32_t getObjectCount() const;
00071 const Object* getObject(uint32_t idx) const;
00072
00073 private:
00074 friend struct QueryResponseImpl;
00075 friend struct QueryContext;
00076 QueryResponse(QueryResponseImpl* impl);
00077 QueryResponseImpl *impl;
00078 };
00079
00083 struct ConsoleEvent {
00084 enum EventKind {
00085 AGENT_ADDED = 1,
00086 AGENT_DELETED = 2,
00087 NEW_PACKAGE = 3,
00088 NEW_CLASS = 4,
00089 OBJECT_UPDATE = 5,
00090 EVENT_RECEIVED = 7,
00091 AGENT_HEARTBEAT = 8
00092 };
00093
00094 EventKind kind;
00095 AgentProxy* agent;
00096 char* name;
00097 const SchemaClassKey* classKey;
00098 Object* object;
00099 void* context;
00100 Event* event;
00101 uint64_t timestamp;
00102 QueryResponse* queryResponse;
00103 bool hasProps;
00104 bool hasStats;
00105 };
00106
00110 struct BrokerEvent {
00111 enum EventKind {
00112 BROKER_INFO = 10,
00113 DECLARE_QUEUE = 11,
00114 DELETE_QUEUE = 12,
00115 BIND = 13,
00116 UNBIND = 14,
00117 SETUP_COMPLETE = 15,
00118 STABLE = 16,
00119 QUERY_COMPLETE = 17,
00120 METHOD_RESPONSE = 18
00121 };
00122
00123 EventKind kind;
00124 char* name;
00125 char* exchange;
00126 char* bindingKey;
00127 void* context;
00128 QueryResponse* queryResponse;
00129 MethodResponse* methodResponse;
00130 };
00131
00135 class AgentProxy {
00136 public:
00137 AgentProxy(const AgentProxy& from);
00138 ~AgentProxy();
00139 const char* getLabel() const;
00140 uint32_t getBrokerBank() const;
00141 uint32_t getAgentBank() const;
00142
00143 private:
00144 friend struct StaticContext;
00145 friend struct QueryContext;
00146 friend struct AgentProxyImpl;
00147 friend class BrokerProxyImpl;
00148 AgentProxy(AgentProxyImpl* impl);
00149 AgentProxyImpl* impl;
00150 };
00151
00155 class BrokerProxy {
00156 public:
00157 BrokerProxy(Console& console);
00158 ~BrokerProxy();
00159
00160 void sessionOpened(SessionHandle& sh);
00161 void sessionClosed();
00162 void startProtocol();
00163
00164 void handleRcvMessage(Message& message);
00165 bool getXmtMessage(Message& item) const;
00166 void popXmt();
00167
00168 bool getEvent(BrokerEvent& event) const;
00169 void popEvent();
00170
00171 uint32_t agentCount() const;
00172 const AgentProxy* getAgent(uint32_t idx) const;
00173 void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0);
00174
00175 private:
00176 friend class ConsoleImpl;
00177 friend struct StaticContext;
00178 BrokerProxyImpl* impl;
00179 };
00180
00181
00182 struct ConsoleSettings {
00183 bool rcvObjects;
00184 bool rcvEvents;
00185 bool rcvHeartbeats;
00186 bool userBindings;
00187
00188 ConsoleSettings() :
00189 rcvObjects(true),
00190 rcvEvents(true),
00191 rcvHeartbeats(true),
00192 userBindings(false) {}
00193 };
00194
00195 class Console {
00196 public:
00197 Console(const ConsoleSettings& settings = ConsoleSettings());
00198 ~Console();
00199
00200 bool getEvent(ConsoleEvent& event) const;
00201 void popEvent();
00202
00203 void addConnection(BrokerProxy& broker, void* context);
00204 void delConnection(BrokerProxy& broker);
00205
00206 uint32_t packageCount() const;
00207 const char* getPackageName(uint32_t idx) const;
00208
00209 uint32_t classCount(const char* packageName) const;
00210 const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const;
00211
00212 ClassKind getClassKind(const SchemaClassKey* key) const;
00213 const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const;
00214 const SchemaEventClass* getEventClass(const SchemaClassKey* key) const;
00215
00216 void bindPackage(const char* packageName);
00217 void bindClass(const SchemaClassKey* key);
00218 void bindClass(const char* packageName, const char* className);
00219
00220 void bindEvent(const SchemaClassKey *key);
00221 void bindEvent(const char* packageName, const char* eventName);
00222
00223
00224
00225
00226
00227
00228
00229 private:
00230 friend class BrokerProxyImpl;
00231 friend struct AgentProxyImpl;
00232 friend struct StaticContext;
00233 ConsoleImpl* impl;
00234 };
00235 }
00236 }
00237
00238 #endif
00239