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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2