qmf/engine/Console.h Source File

Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

qmf/engine/Console.h
Go to the documentation of this file.

    00001 #ifndef _QmfEngineConsole_
    00002 #define _QmfEngineConsole_
    00003
    00004 /*
    00005  * Licensed to the Apache Software Foundation (ASF) under one
    00006  * or more contributor license agreements.  See the NOTICE file
    00007  * distributed with this work for additional information
    00008  * regarding copyright ownership.  The ASF licenses this file
    00009  * to you under the Apache License, Version 2.0 (the
    00010  * "License"); you may not use this file except in compliance
    00011  * with the License.  You may obtain a copy of the License at
    00012  *
    00013  *   http://www.apache.org/licenses/LICENSE-2.0
    00014  *
    00015  * Unless required by applicable law or agreed to in writing,
    00016  * software distributed under the License is distributed on an
    00017  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    00018  * KIND, either express or implied.  See the License for the
    00019  * specific language governing permissions and limitations
    00020  * under the License.
    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;          // (AGENT_[ADDED|DELETED|HEARTBEAT])
    00096         char*           name;           // (NEW_PACKAGE)
    00097         const SchemaClassKey* classKey; // (NEW_CLASS)
    00098         Object*         object;         // (OBJECT_UPDATE)
    00099         void*           context;        // (OBJECT_UPDATE)
    00100         Event*          event;          // (EVENT_RECEIVED)
    00101         uint64_t        timestamp;      // (AGENT_HEARTBEAT)
    00102         QueryResponse*  queryResponse;  // (QUERY_COMPLETE)
    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;           // ([DECLARE|DELETE]_QUEUE, [UN]BIND)
    00125         char*           exchange;       // ([UN]BIND)
    00126         char*           bindingKey;     // ([UN]BIND)
    00127         void*           context;        // (QUERY_COMPLETE, METHOD_RESPONSE)
    00128         QueryResponse*  queryResponse;  // (QUERY_COMPLETE)
    00129         MethodResponse* methodResponse; // (METHOD_RESPONSE)
    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     // TODO - move this to a public header
    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         void startSync(const Query& query, void* context, SyncQuery& sync);
    00225         void touchSync(SyncQuery& sync);
    00226         void endSync(SyncQuery& sync);
    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