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

  1 schuur 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 CONTRgACT, 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 schuur 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            //              Adrian Schuur, schuur@de.ibm.com
 29            //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32            #ifndef Pegasus_CMPIProvider_h
 33            #define Pegasus_CMPIProvider_h
 34            
 35            #include "CMPI_Object.h"
 36            #include "CMPI_Broker.h"
 37            
 38            #include <Pegasus/Common/Config.h>
 39            #include <Pegasus/Common/IPC.h>
 40            #include <Pegasus/Provider/CIMOMHandle.h>
 41            #include <Pegasus/Provider/CIMInstanceProvider.h>
 42            #include <Pegasus/Provider/CIMAssociationProvider.h>
 43 schuur 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
 44            
 45            #include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
 46            
 47            #include <Pegasus/Server/Linkage.h>
 48            
 49            PEGASUS_NAMESPACE_BEGIN
 50            
 51            class CMPIProviderModule;
 52            class CMPIResolverModule;
 53            
 54            #define CMPI_MIType_Instance    1
 55            #define CMPI_MIType_Association 2
 56            #define CMPI_MIType_Method      4
 57            #define CMPI_MIType_Property    8
 58            #define CMPI_MIType_Indication 16
 59            
 60            
 61            typedef CMPIInstanceMI* 	(*CREATE_INST_MI)(CMPIBroker*,CMPIContext*);
 62            typedef CMPIAssociationMI* 	(*CREATE_ASSOC_MI)(CMPIBroker*,CMPIContext*);
 63            typedef CMPIMethodMI* 		(*CREATE_METH_MI)(CMPIBroker*,CMPIContext*);
 64 schuur 1.1 typedef CMPIPropertyMI* 	(*CREATE_PROP_MI)(CMPIBroker*,CMPIContext*);
 65            typedef CMPIIndicationMI* 	(*CREATE_IND_MI)(CMPIBroker*,CMPIContext*);
 66            
 67            typedef CMPIInstanceMI*    (*CREATE_GEN_INST_MI)(CMPIBroker*,CMPIContext*,const char*);
 68            typedef CMPIAssociationMI* (*CREATE_GEN_ASSOC_MI)(CMPIBroker*,CMPIContext*,const char*);
 69            typedef CMPIMethodMI* 	    (*CREATE_GEN_METH_MI)(CMPIBroker*,CMPIContext*,const char*);
 70            typedef CMPIPropertyMI*    (*CREATE_GEN_PROP_MI)(CMPIBroker*,CMPIContext*,const char*);
 71            typedef CMPIIndicationMI*  (*CREATE_GEN_IND_MI)(CMPIBroker*,CMPIContext*,const char*);
 72            
 73            struct ProviderVector {
 74               int			miTypes;
 75               int			genericMode;
 76               CMPIInstanceMI 	*instMI;
 77               CMPIAssociationMI 	*assocMI;
 78               CMPIMethodMI 	*methMI;
 79               CMPIPropertyMI 	*propMI;
 80               CMPIIndicationMI 	*indMI;
 81               CREATE_INST_MI 	createInstMI;
 82               CREATE_ASSOC_MI 	createAssocMI;
 83               CREATE_METH_MI 	createMethMI;
 84               CREATE_PROP_MI 	createPropMI;
 85 schuur 1.1    CREATE_IND_MI 	createIndMI;
 86               CREATE_GEN_INST_MI 	createGenInstMI;
 87               CREATE_GEN_ASSOC_MI 	createGenAssocMI;
 88               CREATE_GEN_METH_MI 	createGenMethMI;
 89               CREATE_GEN_PROP_MI 	createGenPropMI;
 90               CREATE_GEN_IND_MI 	createGenIndMI;
 91            };
 92            
 93            // The CMPIProvider class represents the logical provider extracted from a
 94            // provider module. It is wrapped in a facade to stabalize the interface
 95            // and is directly tied to a module.
 96            
 97            class PEGASUS_SERVER_LINKAGE CMPIProvider :
 98                                   public virtual CIMProvider
 99            {
100            public:
101            
102                enum Status
103                {
104                    UNKNOWN,
105                    INITIALIZING,
106 schuur 1.1         INITIALIZED,
107                    TERMINATING,
108                    TERMINATED
109                };
110            
111            public:
112            
113            
114                class pm_service_op_lock {
115                private:
116                   pm_service_op_lock(void);
117                public:
118                   pm_service_op_lock(CMPIProvider *provider) : _provider(provider)
119                      { _provider->protect(); }
120                   ~pm_service_op_lock(void)
121                      { _provider->unprotect(); }
122                   CMPIProvider * _provider;
123                };
124            
125             //  typedef CMPIProviderFacade Base;
126            
127 schuur 1.1     CMPIProvider(const String & name,
128                    CMPIProviderModule *module,
129                    ProviderVector *mv);
130                CMPIProvider(CMPIProvider*);
131            
132                virtual ~CMPIProvider(void);
133            
134                virtual void initialize(CIMOMHandle & cimom);
135                static void initialize(CIMOMHandle & cimom,
136                                       ProviderVector & miVector,
137            			   String & name,
138                                       CMPI_Broker & broker);
139            
140                virtual Boolean tryTerminate(void);
141                virtual void terminate(void);
142                virtual void _terminate(void);
143            
144                Status getStatus(void) const;
145                String getName(void) const;
146                void setResolver(CMPIResolverModule *rm) { _rm=rm; }
147            
148 schuur 1.1     CMPIProviderModule *getModule(void) const;
149            
150                // << Mon Oct 14 15:42:24 2002 mdd >> for use with DQueue template
151                // to allow conversion from using Array<>
152                Boolean operator == (const void *key) const;
153                Boolean operator == (const CMPIProvider & prov) const;
154            
155                virtual void get_idle_timer(struct timeval *);
156                virtual void update_idle_timer(void);
157                virtual Boolean pending_operation(void);
158                virtual Boolean unload_ok(void);
159            
160            //   force provider manager to keep in memory
161                virtual void protect(void);
162            // allow provider manager to unload when idle
163                virtual void unprotect(void);
164            
165            protected:
166                Status _status;
167                CMPIProviderModule *_module;
168                ProviderVector miVector;
169 schuur 1.1     CMPI_Broker broker;
170                Boolean noUnload;
171            
172            private:
173                friend class CMPILocalProviderManager;
174                friend class CMPIProviderManager;
175                friend class CMPI_RProviderManager;
176                friend class ProviderManagerService;
177            //    friend class OpProviderHolder;
178                CIMOMHandle *_cimom_handle;
179                String _name;
180                AtomicInt _no_unload;
181                CMPIResolverModule *_rm;
182                Uint32 _quantum;
183                AtomicInt _current_operations;
184            //};
185            
186            
187            //
188            // Used to encapsulate the incrementing/decrementing of the _current_operations
189            // for a CMPIProvider so it won't be unloaded during operations.
190 schuur 1.1 //
191            
192               class OpProviderHolder
193               {
194               private:
195                   CMPIProvider* _provider;
196            
197               public:
198                   OpProviderHolder(): _provider( NULL )
199                   {
200                   }
201                   OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
202                   {
203                       SetProvider( p._provider );
204                   }
205                   OpProviderHolder( CMPIProvider* p ): _provider( NULL )
206                   {
207                       SetProvider( p );
208                   }
209                   ~OpProviderHolder()
210                   {
211 schuur 1.1            UnSetProvider();
212                   }
213                   CMPIProvider& GetProvider()
214                   {
215                       return(*_provider);
216                   }
217            
218                   OpProviderHolder& operator=( const OpProviderHolder& x )
219                   {
220                       if(this == &x)
221                           return(*this);
222                       SetProvider( x._provider );
223            
224                       return(*this);
225                   }
226            
227                   void SetProvider( CMPIProvider* p )
228                   {
229                       UnSetProvider();
230                       if(p)
231                       {
232 schuur 1.1                _provider = p;
233                           _provider->_current_operations++;
234                       }
235                   }
236            
237                   void UnSetProvider()
238                   {
239                       if(_provider)
240                       {
241                           _provider->_current_operations--;
242                           _provider = NULL;
243                       }
244                   }
245               };
246            };
247            
248            PEGASUS_NAMESPACE_END
249            
250            #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2