1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.9 // 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.4 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.9 // 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.10 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chip 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.4 //
|
21 chip 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 // Author: Chip Vincent (cvincent@us.ibm.com)
33 //
34 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
35 // Mike Day, IBM (mdday@us.ibm.com)
|
36 dj.gorey 1.6 // Dan Gorey, IBM djgorey@us.ibm.com
|
37 carolann.graves 1.11 // Carol Ann Krug Graves, Hewlett-Packard Company
38 // (carolann_graves@hp.com)
|
39 chip 1.1 //
40 //%/////////////////////////////////////////////////////////////////////////////
41
42 #ifndef Pegasus_Provider_h
43 #define Pegasus_Provider_h
44
45 #include <Pegasus/Common/Config.h>
46 #include <Pegasus/Common/IPC.h>
|
47 chip 1.3
|
48 chip 1.1 #include <Pegasus/Provider/CIMOMHandle.h>
49
50 #include <Pegasus/ProviderManager2/Default/ProviderModule.h>
51 #include <Pegasus/ProviderManager2/Default/ProviderFacade.h>
52
|
53 schuur 1.7 #include <Pegasus/ProviderManager2/Default/Linkage.h>
|
54 chip 1.1
55 PEGASUS_NAMESPACE_BEGIN
56
57 // The Provider class represents the logical provider extracted from a
58 // provider module. It is wrapped in a facade to stabalize the interface
59 // and is directly tied to a module.
60
|
61 schuur 1.7 class PEGASUS_DEFPM_LINKAGE Provider : public ProviderFacade
|
62 chip 1.1 {
63 public:
64 enum Status
65 {
|
66 dj.gorey 1.6 UNINITIALIZED,
67 INITIALIZED
|
68 chip 1.1 };
69
70 public:
71 typedef ProviderFacade Base;
72
73 Provider(const String & name,
74 ProviderModule *module,
75 CIMProvider *pr);
76
77 virtual ~Provider(void);
78
79 virtual void initialize(CIMOMHandle & cimom);
80 virtual void terminate(void);
|
81 schuur 1.8 virtual Boolean tryTerminate(void);
|
82 chip 1.1
|
83 dj.gorey 1.6 Status getStatus(void);
|
84 chip 1.1 String getName(void) const;
85
86 ProviderModule *getModule(void) const;
87
88 Boolean operator == (const void *key) const;
89 Boolean operator == (const Provider & prov) const;
90
91 virtual void get_idle_timer(struct timeval *);
92 virtual void update_idle_timer(void);
93 virtual Boolean pending_operation(void);
94 virtual Boolean unload_ok(void);
95
|
96 chip 1.3 // force provider manager to keep in memory
|
97 chip 1.1 virtual void protect(void);
|
98 chip 1.3 // allow provider manager to unload when idle
|
99 chip 1.1 virtual void unprotect(void);
100
|
101 dj.gorey 1.6 void set(ProviderModule *module,
102 CIMProvider *base,
103 CIMOMHandle *cimomHandle);
104
105 void reset();
106
|
107 carolann.graves 1.11 /**
108 Increments the count of current subscriptions for this provider, and
109 determines if there were no current subscriptions before the increment.
110 If there were no current subscriptions before the increment, the first
111 subscription has been created, and the provider's enableIndications
112 method should be called.
113
114 @return True, if before the increment there were no current
115 subscriptions for this provider;
116 False, otherwise
117 */
118 Boolean testIfZeroAndIncrementSubscriptions ();
119
120 /**
121 Decrements the count of current subscriptions for this provider, and
122 determines if there are no current subscriptions after the decrement.
123 If there are no current subscriptions after the decrement, the last
124 subscription has been deleted, and the provider's disableIndications
125 method should be called.
126
127 @return True, if after the decrement there are no current subscriptions
128 carolann.graves 1.11 for this provider;
129 False, otherwise
130 */
131 Boolean decrementSubscriptionsAndTestIfZero ();
132
133 /**
134 Determines if there are current subscriptions for this provider.
135
136 @return True, if there is at least one current subscription
137 for this provider;
138 False, otherwise
139 */
140 Boolean testSubscriptions ();
141
142 /**
143 Resets the count of current subscriptions for the indication provider.
144 */
145 void resetSubscriptions ();
146
147 /**
148 Sets the provider instance for the provider.
149 carolann.graves 1.11
150 Note: the provider instance is set only for an indication provider, and
151 is set when a Create Subscription request is processed for the provider.
152
153 @param instance the Provider CIMInstance for the provider
154 */
155 void setProviderInstance (const CIMInstance & instance);
156
157 /**
158 Gets the provider instance for the provider.
159
160 Note: the provider instance is set only for an indication provider, and
161 only if a Create Subscription request has been processed for the
162 provider.
163
164 @return the Provider CIMInstance for the provider
165 */
166 CIMInstance getProviderInstance ();
167
|
168 chip 1.1 protected:
169 Status _status;
170 ProviderModule *_module;
|
171 schuur 1.5 CIMProvider *getCIMProvider();
|
172 chip 1.1 private:
173 friend class LocalProviderManager;
174 friend class ProviderManagerService;
175 friend class OpProviderHolder;
176 CIMOMHandle *_cimom_handle;
177 String _name;
178 AtomicInt _no_unload;
179 Uint32 _quantum;
|
180 dj.gorey 1.6 Mutex _statusMutex;
|
181 carolann.graves 1.11
182 /**
183 Count of current subscriptions for this provider. Access to this
184 data member is controlled by the _currentSubscriptionsLock.
185 */
186 Uint32 _currentSubscriptions;
187
188 /**
189 A mutex to control access to the _currentSubscriptions member variable.
190 Before any access (test, increment, decrement or reset) of the
191 _currentSubscriptions member variable, the _currentSubscriptionsMutex is
192 first locked.
193 */
194 Mutex _currentSubscriptionsMutex;
195
196 /**
197 The Provider CIMInstance for the provider.
198 The Provider CIMInstance is set only for indication providers, and only
199 if a Create Subscription request has been processed for the provider.
200 The Provider CIMInstance is needed in order to construct the
201 EnableIndicationsResponseHandler to send to the indication provider
202 carolann.graves 1.11 when the provider's enableIndications() method is called.
203 The Provider CIMInstance is needed in the
204 EnableIndicationsResponseHandler in order to construct the Process
205 Indication request when an indication is delivered by the provider.
206 The Provider CIMInstance is needed in the Process Indication request
207 to enable the Indication Service to determine if the provider that
208 generated the indication accepted a matching subscription.
209 */
210 CIMInstance _providerInstance;
|
211 chip 1.1 };
212
213
214 //
215 // Used to encapsulate the incrementing/decrementing of the _current_operations
216 // for a Provider so it won't be unloaded during operations.
217 //
218
219 class OpProviderHolder
220 {
221 private:
222 Provider* _provider;
223
224 public:
225 OpProviderHolder(): _provider( NULL )
226 {
227 }
228 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
229 {
230 SetProvider( p._provider );
231 }
232 chip 1.1 OpProviderHolder( Provider* p ): _provider( NULL )
233 {
234 SetProvider( p );
235 }
236 ~OpProviderHolder()
237 {
238 UnSetProvider();
239 }
240
241 Provider& GetProvider()
242 {
243 return(*_provider);
|
244 schuur 1.5 }
245
246 CIMProvider* GetCIMProvider()
247 {
248 return _provider->getCIMProvider();
|
249 chip 1.1 }
250
251 OpProviderHolder& operator=( const OpProviderHolder& x )
252 {
253 if(this == &x)
254 return(*this);
255 SetProvider( x._provider );
|
256 chip 1.2
257 return(*this);
|
258 chip 1.1 }
259
260 void SetProvider( Provider* p )
261 {
262 UnSetProvider();
263 if(p)
264 {
265 _provider = p;
266 _provider->_current_operations++;
267 }
268 }
269
270 void UnSetProvider()
271 {
272 if(_provider)
273 {
274 _provider->_current_operations--;
275 _provider = NULL;
276 }
277 }
278 };
279 chip 1.1
280 PEGASUS_NAMESPACE_END
281
282 #endif
|