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 mike 1.14.2.1 #include <Pegasus/Common/Mutex.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 virtual void get_idle_timer(struct timeval *);
89 virtual void update_idle_timer(void);
90 virtual Boolean pending_operation(void);
91 virtual Boolean unload_ok(void);
92
|
93 chip 1.3 // force provider manager to keep in memory
|
94 chip 1.1 virtual void protect(void);
|
95 chip 1.3 // allow provider manager to unload when idle
|
96 chip 1.1 virtual void unprotect(void);
97
|
98 dj.gorey 1.6 void set(ProviderModule *module,
99 CIMProvider *base,
100 CIMOMHandle *cimomHandle);
101
102 void reset();
103
|
104 carolann.graves 1.11 /**
105 Increments the count of current subscriptions for this provider, and
106 determines if there were no current subscriptions before the increment.
107 If there were no current subscriptions before the increment, the first
108 subscription has been created, and the provider's enableIndications
109 method should be called.
110
111 @return True, if before the increment there were no current
112 subscriptions for this provider;
113 False, otherwise
114 */
115 Boolean testIfZeroAndIncrementSubscriptions ();
116
117 /**
118 Decrements the count of current subscriptions for this provider, and
119 determines if there are no current subscriptions after the decrement.
120 If there are no current subscriptions after the decrement, the last
121 subscription has been deleted, and the provider's disableIndications
122 method should be called.
123
124 @return True, if after the decrement there are no current subscriptions
125 carolann.graves 1.11 for this provider;
126 False, otherwise
127 */
128 Boolean decrementSubscriptionsAndTestIfZero ();
129
130 /**
131 Determines if there are current subscriptions for this provider.
132
133 @return True, if there is at least one current subscription
134 for this provider;
135 False, otherwise
136 */
137 Boolean testSubscriptions ();
138
139 /**
140 Resets the count of current subscriptions for the indication provider.
141 */
142 void resetSubscriptions ();
143
144 /**
145 Sets the provider instance for the provider.
146 carolann.graves 1.11
147 Note: the provider instance is set only for an indication provider, and
148 is set when a Create Subscription request is processed for the provider.
149
150 @param instance the Provider CIMInstance for the provider
151 */
152 void setProviderInstance (const CIMInstance & instance);
153
154 /**
155 Gets the provider instance for the provider.
156
157 Note: the provider instance is set only for an indication provider, and
158 only if a Create Subscription request has been processed for the
159 provider.
160
161 @return the Provider CIMInstance for the provider
162 */
163 CIMInstance getProviderInstance ();
164
|
165 chip 1.1 protected:
166 Status _status;
167 ProviderModule *_module;
|
168 schuur 1.5 CIMProvider *getCIMProvider();
|
169 chip 1.1 private:
170 friend class LocalProviderManager;
171 friend class ProviderManagerService;
172 friend class OpProviderHolder;
173 CIMOMHandle *_cimom_handle;
174 String _name;
175 AtomicInt _no_unload;
176 Uint32 _quantum;
|
177 dj.gorey 1.6 Mutex _statusMutex;
|
178 carolann.graves 1.11
179 /**
180 Count of current subscriptions for this provider. Access to this
181 data member is controlled by the _currentSubscriptionsLock.
182 */
183 Uint32 _currentSubscriptions;
184
185 /**
186 A mutex to control access to the _currentSubscriptions member variable.
187 Before any access (test, increment, decrement or reset) of the
188 _currentSubscriptions member variable, the _currentSubscriptionsMutex is
189 first locked.
190 */
191 Mutex _currentSubscriptionsMutex;
192
193 /**
194 The Provider CIMInstance for the provider.
195 The Provider CIMInstance is set only for indication providers, and only
196 if a Create Subscription request has been processed for the provider.
197 The Provider CIMInstance is needed in order to construct the
198 EnableIndicationsResponseHandler to send to the indication provider
199 carolann.graves 1.11 when the provider's enableIndications() method is called.
200 The Provider CIMInstance is needed in the
201 EnableIndicationsResponseHandler in order to construct the Process
202 Indication request when an indication is delivered by the provider.
203 The Provider CIMInstance is needed in the Process Indication request
204 to enable the Indication Service to determine if the provider that
205 generated the indication accepted a matching subscription.
206 */
207 CIMInstance _providerInstance;
|
208 chip 1.1 };
209
210
211 //
212 // Used to encapsulate the incrementing/decrementing of the _current_operations
213 // for a Provider so it won't be unloaded during operations.
214 //
215
216 class OpProviderHolder
217 {
218 private:
219 Provider* _provider;
220
221 public:
222 OpProviderHolder(): _provider( NULL )
223 {
224 }
225 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
226 {
227 SetProvider( p._provider );
228 }
229 chip 1.1 OpProviderHolder( Provider* p ): _provider( NULL )
230 {
231 SetProvider( p );
232 }
233 ~OpProviderHolder()
234 {
235 UnSetProvider();
236 }
237
238 Provider& GetProvider()
239 {
240 return(*_provider);
|
241 schuur 1.5 }
242
243 CIMProvider* GetCIMProvider()
244 {
245 return _provider->getCIMProvider();
|
246 chip 1.1 }
247
248 OpProviderHolder& operator=( const OpProviderHolder& x )
249 {
250 if(this == &x)
251 return(*this);
252 SetProvider( x._provider );
|
253 chip 1.2
254 return(*this);
|
255 chip 1.1 }
256
257 void SetProvider( Provider* p )
258 {
259 UnSetProvider();
260 if(p)
261 {
262 _provider = p;
263 _provider->_current_operations++;
264 }
265 }
266
267 void UnSetProvider()
268 {
269 if(_provider)
270 {
271 _provider->_current_operations--;
272 _provider = NULL;
273 }
274 }
275 };
276 chip 1.1
277 PEGASUS_NAMESPACE_END
278
279 #endif
|