1 karl 1.4 //%2003////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.4 // 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 // IBM Corp.; EMC Corporation, The Open Group.
|
7 chip 1.1 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 karl 1.4 //
|
15 chip 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Chip Vincent (cvincent@us.ibm.com)
27 //
28 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
29 // Mike Day, IBM (mdday@us.ibm.com)
|
30 schuur 1.4.4.1 // Dan Gorey, IBM djgorey@us.ibm.com
|
31 chip 1.1 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_Provider_h
35 #define Pegasus_Provider_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/IPC.h>
|
39 chip 1.3
|
40 chip 1.1 #include <Pegasus/Provider/CIMOMHandle.h>
41
42 #include <Pegasus/ProviderManager2/Default/ProviderModule.h>
43 #include <Pegasus/ProviderManager2/Default/ProviderFacade.h>
44
45 #include <Pegasus/Server/Linkage.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 // The Provider class represents the logical provider extracted from a
50 // provider module. It is wrapped in a facade to stabalize the interface
51 // and is directly tied to a module.
52
53 class PEGASUS_SERVER_LINKAGE Provider : public ProviderFacade
54 {
55 public:
56 enum Status
57 {
|
58 schuur 1.4.4.1 UNINITIALIZED,
59 INITIALIZED
|
60 chip 1.1 };
61
62 public:
63 typedef ProviderFacade Base;
64
65 Provider(const String & name,
66 ProviderModule *module,
67 CIMProvider *pr);
68
69 virtual ~Provider(void);
70
71 virtual void initialize(CIMOMHandle & cimom);
72 virtual void terminate(void);
73
|
74 schuur 1.4.4.1 Status getStatus(void);
|
75 chip 1.1 String getName(void) const;
76
77 ProviderModule *getModule(void) const;
78
79 // << Mon Oct 14 15:42:24 2002 mdd >> for use with DQueue template
80 // to allow conversion from using Array<>
81 Boolean operator == (const void *key) const;
82 Boolean operator == (const Provider & prov) const;
83
84 virtual void get_idle_timer(struct timeval *);
85 virtual void update_idle_timer(void);
86 virtual Boolean pending_operation(void);
87 virtual Boolean unload_ok(void);
88
|
89 chip 1.3 // force provider manager to keep in memory
|
90 chip 1.1 virtual void protect(void);
|
91 chip 1.3 // allow provider manager to unload when idle
|
92 chip 1.1 virtual void unprotect(void);
93
|
94 schuur 1.4.4.1 void set(ProviderModule *module,
95 CIMProvider *base,
96 CIMOMHandle *cimomHandle);
97
98 void reset();
99
|
100 chip 1.1 protected:
101 Status _status;
102 ProviderModule *_module;
|
103 schuur 1.4.4.1 CIMProvider *getCIMProvider();
|
104 chip 1.1 private:
105 friend class LocalProviderManager;
106 friend class ProviderManagerService;
107 friend class OpProviderHolder;
108 CIMOMHandle *_cimom_handle;
109 String _name;
110 AtomicInt _no_unload;
111 Uint32 _quantum;
|
112 schuur 1.4.4.1 Mutex _statusMutex;
|
113 chip 1.1 };
114
115
116 //
117 // Used to encapsulate the incrementing/decrementing of the _current_operations
118 // for a Provider so it won't be unloaded during operations.
119 //
120
121 class OpProviderHolder
122 {
123 private:
124 Provider* _provider;
125
126 public:
127 OpProviderHolder(): _provider( NULL )
128 {
129 }
130 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
131 {
132 SetProvider( p._provider );
133 }
134 chip 1.1 OpProviderHolder( Provider* p ): _provider( NULL )
135 {
136 SetProvider( p );
137 }
138 ~OpProviderHolder()
139 {
140 UnSetProvider();
141 }
142
143 Provider& GetProvider()
144 {
145 return(*_provider);
|
146 schuur 1.4.4.1 }
147
148 CIMProvider* GetCIMProvider()
149 {
150 return _provider->getCIMProvider();
|
151 chip 1.1 }
152
153 OpProviderHolder& operator=( const OpProviderHolder& x )
154 {
155 if(this == &x)
156 return(*this);
157 SetProvider( x._provider );
|
158 chip 1.2
159 return(*this);
|
160 chip 1.1 }
161
162 void SetProvider( Provider* p )
163 {
164 UnSetProvider();
165 if(p)
166 {
167 _provider = p;
168 _provider->_current_operations++;
169 }
170 }
171
172 void UnSetProvider()
173 {
174 if(_provider)
175 {
176 _provider->_current_operations--;
177 _provider = NULL;
178 }
179 }
180 };
181 chip 1.1
182 PEGASUS_NAMESPACE_END
183
184 #endif
|