(file) Return to Provider.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Default

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2