Qpid Management Framework  0.24
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Agent.h
Go to the documentation of this file.
1 #ifndef _QmfEngineAgent_
2 #define _QmfEngineAgent_
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 
23 #include <qmf/engine/Schema.h>
24 #include <qmf/engine/ObjectId.h>
25 #include <qmf/engine/Object.h>
26 #include <qmf/engine/Event.h>
27 #include <qmf/engine/Query.h>
28 #include <qmf/engine/Value.h>
29 #include <qmf/engine/Message.h>
30 
31 namespace qmf {
32 namespace engine {
33 
40  struct AgentEvent {
41  enum EventKind {
42  GET_QUERY = 1,
44  END_SYNC = 3,
48  BIND = 7,
49  UNBIND = 8,
51  };
52 
54  uint32_t sequence; // Protocol sequence (for all kinds)
55  char* authUserId; // Authenticated user ID (for all kinds)
56  char* authToken; // Authentication token if issued (for all kinds)
57  char* name; // Name of the method/sync query
58  // (METHOD_CALL, START_SYNC, END_SYNC, DECLARE_QUEUE, BIND, UNBIND)
59  Object* object; // Object involved in method call (METHOD_CALL)
60  ObjectId* objectId; // ObjectId for method call (METHOD_CALL)
61  Query* query; // Query parameters (GET_QUERY, START_SYNC)
62  Value* arguments; // Method parameters (METHOD_CALL)
63  char* exchange; // Exchange for bind (BIND, UNBIND)
64  char* bindingKey; // Key for bind (BIND, UNBIND)
65  const SchemaObjectClass* objectClass; // (METHOD_CALL)
66  };
67 
68  class AgentImpl;
69 
73  class Agent {
74  public:
75  Agent(char* label, bool internalStore=true);
76  ~Agent();
77 
84  void setStoreDir(const char* path);
85 
92  void setTransferDir(const char* path);
93 
98  void handleRcvMessage(Message& message);
99 
105  bool getXmtMessage(Message& item) const;
106 
110  void popXmt();
111 
117  bool getEvent(AgentEvent& event) const;
118 
122  void popEvent();
123 
127  void newSession();
128 
133  void startProtocol();
134 
138  void heartbeat();
139 
147  void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments);
148 
158  void queryResponse(uint32_t sequence, Object& object, bool prop = true, bool stat = true);
159 
164  void queryComplete(uint32_t sequence);
165 
170  void registerClass(SchemaObjectClass* cls);
171 
176  void registerClass(SchemaEventClass* cls);
177 
185  const ObjectId* addObject(Object& obj, uint64_t persistId);
186  // const ObjectId* addObject(Object& obj, uint32_t persistIdLo, uint32_t persistIdHi);
187 
193  const ObjectId* allocObjectId(uint64_t persistId);
194  const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi);
195 
200  void raiseEvent(Event& event);
201 
202  private:
203  AgentImpl* impl;
204  };
205 }
206 }
207 
208 #endif
209