Go to the documentation of this file.00001 #ifndef _QmfEngineAgent_
00002 #define _QmfEngineAgent_
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #include <qmf/engine/Schema.h>
00024 #include <qmf/engine/ObjectId.h>
00025 #include <qmf/engine/Object.h>
00026 #include <qmf/engine/Event.h>
00027 #include <qmf/engine/Query.h>
00028 #include <qmf/engine/Value.h>
00029 #include <qmf/engine/Message.h>
00030 
00031 namespace qmf {
00032 namespace engine {
00033 
00040     struct AgentEvent {
00041         enum EventKind {
00042             GET_QUERY      = 1,
00043             START_SYNC     = 2,
00044             END_SYNC       = 3,
00045             METHOD_CALL    = 4,
00046             DECLARE_QUEUE  = 5,
00047             DELETE_QUEUE   = 6,
00048             BIND           = 7,
00049             UNBIND         = 8,
00050             SETUP_COMPLETE = 9
00051         };
00052 
00053         EventKind    kind;
00054         uint32_t     sequence;    
00055         char*        authUserId;  
00056         char*        authToken;   
00057         char*        name;        
00058                                   
00059         Object*      object;      
00060         ObjectId*    objectId;    
00061         Query*       query;       
00062         Value*       arguments;   
00063         char*        exchange;    
00064         char*        bindingKey;  
00065         const SchemaObjectClass* objectClass; 
00066     };
00067 
00068     class AgentImpl;
00069 
00073     class Agent {
00074     public:
00075         Agent(char* label, bool internalStore=true);
00076         ~Agent();
00077 
00084         void setStoreDir(const char* path);
00085 
00092         void setTransferDir(const char* path);
00093 
00098         void handleRcvMessage(Message& message);
00099 
00105         bool getXmtMessage(Message& item) const;
00106 
00110         void popXmt();
00111 
00117         bool getEvent(AgentEvent& event) const;
00118 
00122         void popEvent();
00123 
00127         void newSession();
00128 
00133         void startProtocol();
00134 
00138         void heartbeat();
00139 
00147         void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments);
00148 
00158         void queryResponse(uint32_t sequence, Object& object, bool prop = true, bool stat = true);
00159 
00164         void queryComplete(uint32_t sequence);
00165 
00170         void registerClass(SchemaObjectClass* cls);
00171 
00176         void registerClass(SchemaEventClass* cls);
00177 
00185         const ObjectId* addObject(Object& obj, uint64_t persistId);
00186         
00187 
00193         const ObjectId* allocObjectId(uint64_t persistId);
00194         const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi);
00195 
00200         void raiseEvent(Event& event);
00201 
00202     private:
00203         AgentImpl* impl;
00204     };
00205 }
00206 }
00207 
00208 #endif
00209