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