1 mday 1.1 //%////-*-c++-*-////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 mday 1.1 //
23 // Author: Mike Day (mdday@us.ibm.com) <<< Wed Mar 13 20:49:40 2002 mdd >>>
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
29 #ifndef Pegasus_Module_Controller_h
30 #define Pegasus_Module_Controller_h
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/Message.h>
34 #include <Pegasus/Common/Exception.h>
35 #include <Pegasus/Common/IPC.h>
36 #include <Pegasus/Common/Thread.h>
37 #include <Pegasus/Common/AsyncOpNode.h>
38 #include <Pegasus/Common/Cimom.h>
39 #include <Pegasus/Common/CimomMessage.h>
40 #include <Pegasus/Common/MessageQueueService.h>
41
42 PEGASUS_NAMESPACE_BEGIN
43 mday 1.1
44 class ModuleController;
45
46
|
47 mday 1.2 class PEGASUS_COMMON_LINKAGE pegasus_module
|
48 mday 1.1 {
49 public:
50
|
51 mday 1.2 pegasus_module()
|
52 mday 1.1 {
53 }
54
|
55 mday 1.2 virtual ~pegasus_module()
|
56 mday 1.1 {
57 }
58
59 Boolean operator == (const service_module *) const;
60 Boolean operator == (const String & ) const ;
61 Boolean operator == (const service_module & ) const ;
62 Boolean operator == (const void *) const;
63
64 String & get_name(void);
65
|
66 mday 1.2 // introspection interface
67 virtual Boolean query_interface(String & class_id,
68 void **object_ptr) = 0;
69 virtual Uint32 reference(void) { _reference_count++; }
70 virtual Uint32 dereference(void) { _reference_count--; }
|
71 mday 1.1
72 private:
73 virtual Boolean _rcv_msg(Message *) = 0;
74 virtual void _send_async_callback(Uint32 msg_handle, Message *msg) = 0;
75
76 virtual Boolean _shutdown(Uint32) = 0;
77 ModuleController *_controller;
78 String _name;
|
79 mday 1.2 AtomicInt _reference_count;
|
80 mday 1.1
81 friend class ModuleController;
|
82 mday 1.2 };
|
83 mday 1.1
84
85 class PEGASUS_COMMON_LINKAGE ModuleController : public MessageQueueService
86 {
87
88 public:
89 typedef MesageQueueService Base;
90
91 ModuleController(const char *name, Uint32 queueID);
92 ~ModuleController(void);
93
94
95
96 // module api
|
97 mday 1.2 ModuleController & register_module(pegasus_module *);
98 deregister_module(pegasus_module *);
99
100 Uint32 find_service(pegasus_module & handle, String & name);
101 String & find_service(pegasus_module & handle, Uint32 queue_id);
102
103 pegasus_module & get_module_reference(pegasus_module & handle, String & name);
|
104 mday 1.1
105
|
106 mday 1.2 // send a message to another service
107 Message *ModuleSendWait(pegasus_module & handle,
108 Uint32 destination_q,
|
109 mday 1.1 Message *message);
110
|
111 mday 1.2 // send a message to another module via another service
112 Message *ModuleSendWait(pegasus_module & handle,
113 Uint32 destination_q,
114 String & destination_module,
|
115 mday 1.1 Message *message);
|
116 mday 1.2
117 // send a message to another service
118 Boolean ModuleSendAsync(pegasus_module & handle,
|
119 mday 1.1 Uint32 msg_handle,
|
120 mday 1.2 Uint32 destination_q,
|
121 mday 1.1 Message *message);
122
|
123 mday 1.2 // send a message to another module via another service
124 Boolean ModuleSendAsync(pegasus_module & handle,
|
125 mday 1.1 Uint32 msg_handle,
|
126 mday 1.2 Uint32 destination_q,
127 String & destination_module,
|
128 mday 1.1 Message *message);
129
|
130 mday 1.2 Uint32 blocking_thread_exec(pegasus_module & handle,
131 PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *thread_func)(void *),
132 void *parm);
133 Uint32 async_thread_exec(pegasus_module & handle,
134 PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *thread_func)(void *),
135 void *parm);
136
137 // << Thu Mar 14 09:52:56 2002 mdd >>
138 // need to add a blocking semaphore to ThreadPool for "joinable" threads
139 // need to define a special message type for sending messages to modules
140 //
|
141 mday 1.1
142 protected:
143
144 private:
145
|
146 mday 1.2 DQueue<pegasus_module> _modules;
|
147 mday 1.1 ThreadPool _thread_pool;
|
148 mday 1.2 };
|
149 mday 1.1
150
151 PEGASUS_NAMESPACE_END
152
153
154 #endif // Pegasus_Module_Controller_h
|