1 karl 1.44 //%2006////////////////////////////////////////////////////////////////////////
|
2 mday 1.1 //
|
3 karl 1.38 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.36 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.38 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.39 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.44 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mday 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.44 //
|
21 mday 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 kumpf 1.49 #ifndef Pegasus_ModuleController_h
35 #define Pegasus_ModuleController_h
|
36 mday 1.1
37 #include <Pegasus/Common/Config.h>
|
38 kumpf 1.49 #include <Pegasus/Common/Linkage.h>
|
39 mday 1.19 #include <Pegasus/Common/Constants.h>
|
40 kumpf 1.49 #include <Pegasus/Common/List.h>
|
41 mday 1.1 #include <Pegasus/Common/Message.h>
|
42 kumpf 1.49 #include <Pegasus/Common/MessageQueueService.h>
|
43 mday 1.1 #include <Pegasus/Common/AsyncOpNode.h>
|
44 david.dillard 1.42 #include <Pegasus/Common/AutoPtr.h>
|
45 mday 1.11
|
46 mday 1.1 PEGASUS_NAMESPACE_BEGIN
47
|
48 kumpf 1.49 class PEGASUS_COMMON_LINKAGE RegisteredModuleHandle : public Linkable
|
49 mday 1.9 {
|
50 david.dillard 1.42 public:
|
51 kumpf 1.49 RegisteredModuleHandle(
52 const String& name,
53 void* module_address,
54 Message* (*receive_message)(Message *, void *),
55 void (*async_callback)(Uint32, Message *, void *));
|
56 david.dillard 1.42
|
57 kumpf 1.49 virtual ~RegisteredModuleHandle();
|
58 david.dillard 1.42
|
59 kumpf 1.51 const String& get_name() const;
|
60 david.dillard 1.42
61 private:
62
|
63 kumpf 1.49 RegisteredModuleHandle();
64 RegisteredModuleHandle(const RegisteredModuleHandle&);
65 RegisteredModuleHandle& operator=(const RegisteredModuleHandle&);
66
67 Message* _receive_message(Message* msg);
68 void _send_async_callback(Uint32 msg_handle, Message* msg, void* parm);
69
70 String _name;
71 void* _module_address;
72 Message* (*_module_receive_message)(Message *, void *);
73 void (*_async_callback)(Uint32, Message *, void *);
|
74 david.dillard 1.42
75 friend class ModuleController;
|
76 mday 1.5 };
|
77 mday 1.4
78
|
79 mday 1.1 class PEGASUS_COMMON_LINKAGE ModuleController : public MessageQueueService
80 {
|
81 david.dillard 1.42 public:
82 typedef MessageQueueService Base;
|
83 mday 1.1
|
84 david.dillard 1.42 class callback_handle
85 {
86 public:
|
87 kumpf 1.49 callback_handle(RegisteredModuleHandle* module, void* parm)
|
88 david.dillard 1.42 : _module(module), _parm(parm)
89 {
90 }
91
92 ~callback_handle()
93 {
|
94 kumpf 1.51 if (_module->get_name() == String(PEGASUS_MODULENAME_TEMP))
|
95 david.dillard 1.42 _module.reset();
96 }
97
|
98 kumpf 1.49 AutoPtr<RegisteredModuleHandle> _module;
|
99 kumpf 1.51 void* _parm;
|
100 david.dillard 1.42 };
|
101 mday 1.11
|
102 david.dillard 1.42 public:
103 ModuleController(const char *name);
104
105 ~ModuleController();
106
107 // module api
108 // @exception AlreadyExistsException
109 // @exception IncompatibleTypesException
|
110 kumpf 1.49 static ModuleController& register_module(
111 const String & controller_name,
112 const String& module_name,
113 void* module_address,
114 Message* (*receive_message)(Message *, void *),
115 void (*async_callback)(Uint32, Message *, void *),
116 RegisteredModuleHandle** instance = 0);
|
117 david.dillard 1.42
118 // @exception Permission
|
119 kumpf 1.49 Boolean deregister_module(const String& module_name);
|
120 david.dillard 1.42
121 // @exception Permission
|
122 kumpf 1.49 Uint32 find_service(
123 const RegisteredModuleHandle& handle,
124 const String& name);
|
125 david.dillard 1.42
126 // @exception Permission
127 // @exception IPCException
|
128 kumpf 1.49 Uint32 find_module_in_service(
129 const RegisteredModuleHandle& handle,
130 const String& module_name);
|
131 david.dillard 1.42
132 // send a message to another service
133 // @exception Permission
134 // @exception IPCException
|
135 kumpf 1.49 AsyncReply* ModuleSendWait(
136 const RegisteredModuleHandle& handle,
137 Uint32 destination_q,
138 AsyncRequest* request);
|
139 david.dillard 1.42
140 // send a message to another module via another service
141 // @exception Permission
142 // @exception DeadLock
143 // @exception IPCException
|
144 kumpf 1.49 AsyncReply* ModuleSendWait(
145 const RegisteredModuleHandle& handle,
146 Uint32 destination_q,
147 const String& destination_module,
148 AsyncRequest* message);
|
149 david.dillard 1.42
150 // send an async message to another service
151 // @exception Permission
152 // @exception DeadLock
153 // @exception IPCException
|
154 kumpf 1.49 Boolean ModuleSendAsync(
155 const RegisteredModuleHandle& handle,
156 Uint32 msg_handle,
157 Uint32 destination_q,
158 AsyncRequest* message,
159 void* callback_parm);
|
160 david.dillard 1.42
161 // send an async message to another module via another service
162 // @exception Permission
163 // @exception IPCException
|
164 kumpf 1.49 Boolean ModuleSendAsync(
165 const RegisteredModuleHandle& handle,
166 Uint32 msg_handle,
167 Uint32 destination_q,
168 const String& destination_module,
169 AsyncRequest* message,
170 void* callback_parm);
|
171 david.dillard 1.42
172 // @exception Permission
173 // @exception IPCException
|
174 kumpf 1.49 Boolean ModuleSendForget(
175 const RegisteredModuleHandle& handle,
176 Uint32 destination_q,
177 AsyncRequest* message);
|
178 david.dillard 1.42
179 // @exception Permission
180 // @exception IPCException
|
181 kumpf 1.49 Boolean ModuleSendForget(
182 const RegisteredModuleHandle & handle,
183 Uint32 destination_q,
184 const String & destination_module,
185 AsyncRequest* message);
|
186 david.dillard 1.42
|
187 kumpf 1.49 Boolean verify_handle(RegisteredModuleHandle *);
|
188 david.dillard 1.42
|
189 kumpf 1.47 static ModuleController* getModuleController();
|
190 david.dillard 1.42
191 // send a message to another service
192 // @exception Permission
193 // @exception IPCException
|
194 kumpf 1.49 AsyncReply* ClientSendWait(
195 Uint32 destination_q,
196 AsyncRequest* request);
|
197 david.dillard 1.42
198 // send a message to another module via another service
199 // @exception Permission
200 // @exception Deadlock
201 // @exception IPCException
|
202 kumpf 1.49 AsyncReply* ClientSendWait(
203 Uint32 destination_q,
204 String& destination_module,
205 AsyncRequest* message);
|
206 david.dillard 1.42
207 // send an async message to another service
208 // @exception Permission
209 // @exception IPCException
|
210 kumpf 1.47 Boolean ClientSendAsync(
|
211 kumpf 1.49 Uint32 msg_handle,
212 Uint32 destination_q,
213 AsyncRequest* message,
214 void (*async_callback)(Uint32, Message *, void *),
215 void* callback_parm);
|
216 david.dillard 1.42
217 // send an async message to another module via another service
218 // @exception Permission
219 // @exception IPCException
|
220 kumpf 1.47 Boolean ClientSendAsync(
|
221 kumpf 1.49 Uint32 msg_handle,
222 Uint32 destination_q,
223 const String& destination_module,
224 AsyncRequest* message,
225 void (*async_callback)(Uint32, Message *, void *),
226 void* callback_parm);
|
227 david.dillard 1.42
228 // @exception Permission
229 // @exception IPCException
|
230 kumpf 1.47 Boolean ClientSendForget(
|
231 kumpf 1.49 Uint32 destination_q,
232 AsyncRequest* message);
|
233 david.dillard 1.42
234 // @exception Permission
235 // @exception IPCException
|
236 kumpf 1.47 Boolean ClientSendForget(
|
237 kumpf 1.49 Uint32 destination_q,
238 const String& destination_module,
239 AsyncRequest* message);
|
240 david.dillard 1.42
241 protected:
242 // ATTN-RK-P2-20010322: These methods are pure virtual in superclass
243 virtual void handleEnqueue() {}
244 virtual void handleEnqueue(Message *) {}
245 virtual void _handle_async_request(AsyncRequest *rq);
246 virtual void _handle_async_callback(AsyncOpNode *op);
247
248 private:
249 class _module_lock
250 {
251 public:
|
252 mike 1.50 _module_lock(List<RegisteredModuleHandle, Mutex> * list)
|
253 david.dillard 1.42 :_list(list)
254 {
255 _list->lock();
256 }
257
258 ~_module_lock()
259 {
260 _list->unlock();
261 }
262
263 private:
264 _module_lock();
|
265 mike 1.50 List<RegisteredModuleHandle, Mutex> * _list;
|
266 david.dillard 1.42 };
267
268
|
269 kumpf 1.51 static void _async_handleEnqueue(
270 AsyncOpNode* h,
271 MessageQueue* q,
272 void* parm);
|
273 david.dillard 1.42
|
274 mike 1.50 List<RegisteredModuleHandle, Mutex> _modules;
|
275 david.dillard 1.42 AsyncReply *_send_wait(Uint32, AsyncRequest *);
276 AsyncReply *_send_wait(Uint32, const String &, AsyncRequest *);
277
278 // @exception IPCException
279 Boolean _send_forget(Uint32, AsyncRequest *);
280
281 // @exception IPCException
282 Boolean _send_forget(Uint32, const String &, AsyncRequest *);
|
283 mday 1.2 };
|
284 mday 1.35
|
285 mday 1.1 PEGASUS_NAMESPACE_END
286
|
287 kumpf 1.49 #endif // Pegasus_ModuleController_h
|