OWBI1_ProviderIFC.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00035 #ifndef OWBI1_PROVIDERIFC_HPP_INCLUDE_GUARD_
00036 #define OWBI1_PROVIDERIFC_HPP_INCLUDE_GUARD_
00037 #include "OW_config.h"
00038 #include "OWBI1_config.h"
00039 #include "OWBI1_Fwd.hpp"
00040 #include "OW_ProviderIFCBaseIFC.hpp"
00041 #include "OW_Map.hpp"
00042 #include "OW_SharedLibrary.hpp"
00043 #include "OWBI1_ProviderBaseIFC.hpp"
00044 #include "OW_MutexLock.hpp"
00045 #include "OW_SharedLibraryReference.hpp"
00046 #include "OWBI1_IntrusiveReference.hpp"
00047 #include "OWBI1_Array.hpp"
00048 
00049 // The classes and functions defined in this file are not meant for general
00050 // use, they are internal implementation details.  They may change at any time.
00051 
00052 namespace OWBI1
00053 {
00054 
00055 using namespace OpenWBEM;
00056 
00057 typedef SharedLibraryReference< IntrusiveReference<BI1ProviderBaseIFC> > BI1ProviderBaseIFCRef;
00058 
00063 class OWBI1_OWBI1PROVIFC_API BI1ProviderIFC : public ProviderIFCBaseIFC
00064 {
00065 public:
00066    static const char* const CREATIONFUNC;
00067    BI1ProviderIFC();
00068    ~BI1ProviderIFC();
00069 
00070    // Making this public so other code can re-use it.
00071    static BI1ProviderBaseIFCRef loadProvider(const OpenWBEM::String& libName, OpenWBEM::LoggerRef logger);
00072 
00073 protected:
00074    virtual const char* getName() const { return "owbi1"; }
00079    virtual void doInit(const OpenWBEM::ProviderEnvironmentIFCRef& env,
00080       OpenWBEM::InstanceProviderInfoArray& i,
00081       OpenWBEM::SecondaryInstanceProviderInfoArray& si,
00082 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00083       OpenWBEM::AssociatorProviderInfoArray& a,
00084 #endif
00085       OpenWBEM::MethodProviderInfoArray& m,
00086       OpenWBEM::IndicationProviderInfoArray& ind);
00087    virtual OpenWBEM::InstanceProviderIFCRef doGetInstanceProvider(
00088       const OpenWBEM::ProviderEnvironmentIFCRef& env,
00089       const char* provIdString);
00090    virtual OpenWBEM::SecondaryInstanceProviderIFCRef doGetSecondaryInstanceProvider(
00091       const OpenWBEM::ProviderEnvironmentIFCRef& env,
00092       const char* provIdString);
00093    virtual OpenWBEM::MethodProviderIFCRef doGetMethodProvider(
00094       const OpenWBEM::ProviderEnvironmentIFCRef& env,
00095       const char* provIdString);
00096    virtual OpenWBEM::AssociatorProviderIFCRef doGetAssociatorProvider(
00097       const OpenWBEM::ProviderEnvironmentIFCRef& env,
00098       const char* provIdString);
00099    virtual OpenWBEM::IndicationProviderIFCRef doGetIndicationProvider(
00100       const OpenWBEM::ProviderEnvironmentIFCRef& env,
00101       const char* provIdString);
00102    virtual OpenWBEM::IndicationExportProviderIFCRefArray doGetIndicationExportProviders(
00103       const OpenWBEM::ProviderEnvironmentIFCRef& env
00104       );
00105    virtual OpenWBEM::PolledProviderIFCRefArray doGetPolledProviders(
00106       const OpenWBEM::ProviderEnvironmentIFCRef& env
00107       );
00108    virtual void doUnloadProviders(const OpenWBEM::ProviderEnvironmentIFCRef& env);
00109    virtual void doShuttingDown(const OpenWBEM::ProviderEnvironmentIFCRef& env);
00110 private:
00111    // To prevent a potential deadlock situation, we can't call initialize() while m_guard is locked.
00112    // However, that presents a race condition for initializing providers, so each BI1ProviderBaseIFCRef
00113    // has an associated condition to address that. The details are handled by this class.
00114    class BI1ProviderInitializationHelper;
00115    typedef OpenWBEM::IntrusiveReference<BI1ProviderInitializationHelper> BI1ProviderInitializationHelperRef;
00116 
00117    typedef Map<OpenWBEM::String, BI1ProviderInitializationHelperRef> ProviderMap;
00118    typedef Map<OpenWBEM::String, OpenWBEM::IndicationProviderIFCRef> IndicationProviderMap;
00119    
00120    enum StoreProviderFlag
00121    {
00122       dontStoreProvider,
00123       storeProvider
00124    };
00125    enum InitializeProviderFlag
00126    {
00127       dontInitializeProvider,
00128       initializeProvider
00129    };
00130    
00131    // REQUIRE: (initP == initializeProvider && storeP == storeProvider) || (initP == dontInitializeProvider && storeP == dontStoreProvider)
00132    // i.e. if you initialize a provider, you must also store it.  If you don't initialize it, you can't store it.
00133    BI1ProviderBaseIFCRef getProvider(const OpenWBEM::ProviderEnvironmentIFCRef& env,
00134       const char* provIdString, StoreProviderFlag = storeProvider,
00135       InitializeProviderFlag = initializeProvider);
00136    
00137    void loadProviders(const OpenWBEM::ProviderEnvironmentIFCRef& env,
00138       OpenWBEM::InstanceProviderInfoArray& i,
00139       OpenWBEM::SecondaryInstanceProviderInfoArray& si,
00140 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00141       OpenWBEM::AssociatorProviderInfoArray& a,
00142 #endif
00143       OpenWBEM::MethodProviderInfoArray& m,
00144       OpenWBEM::IndicationProviderInfoArray& ind);
00145    
00146    ProviderMap m_provs;
00147    IndicationProviderMap m_indicationProviders;
00148    OpenWBEM::Mutex m_guard;
00149    OpenWBEM::IndicationExportProviderIFCRefArray m_indicationExportProviders;
00150    OpenWBEM::PolledProviderIFCRefArray m_polledProviders;
00151    bool m_loadDone;
00152 };
00153 //typedef SharedLibraryReference< IntrusiveReference<BI1ProviderIFC> > CppProviderIFCRef;
00154 
00155 } // end namespace OWBI1
00156 
00157 #endif

Generated on Thu Feb 9 08:48:28 2006 for openwbem by  doxygen 1.4.6