OW_CppProviderIFC.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 OW_CPPPROVIDERIFC_HPP_
00036 #define OW_CPPPROVIDERIFC_HPP_
00037 #include "OW_config.h"
00038 #include "OW_ProviderIFCBaseIFC.hpp"
00039 #include "OW_Map.hpp"
00040 #include "OW_SharedLibrary.hpp"
00041 #include "OW_CppProviderBaseIFC.hpp"
00042 #include "OW_MutexLock.hpp"
00043 
00044 // The classes and functions defined in this file are not meant for general
00045 // use, they are internal implementation details.  They may change at any time.
00046 
00047 namespace OW_NAMESPACE
00048 {
00049 
00054 class OW_CPPPROVIFC_API CppProviderIFC : public ProviderIFCBaseIFC
00055 {
00056 public:
00057    static const char* const CREATIONFUNC;
00058    CppProviderIFC();
00059    ~CppProviderIFC();
00060 
00061    // Making this public so other code can re-use it.
00062    static CppProviderBaseIFCRef loadProvider(const String& libName, LoggerRef logger);
00063 
00064 protected:
00065    virtual const char* getName() const { return "c++"; }
00070    virtual void doInit(const ProviderEnvironmentIFCRef& env,
00071       InstanceProviderInfoArray& i,
00072       SecondaryInstanceProviderInfoArray& si,
00073 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00074       AssociatorProviderInfoArray& a,
00075 #endif
00076       MethodProviderInfoArray& m,
00077       IndicationProviderInfoArray& ind);
00078    virtual InstanceProviderIFCRef doGetInstanceProvider(
00079       const ProviderEnvironmentIFCRef& env,
00080       const char* provIdString);
00081    virtual SecondaryInstanceProviderIFCRef doGetSecondaryInstanceProvider(
00082       const ProviderEnvironmentIFCRef& env,
00083       const char* provIdString);
00084    virtual MethodProviderIFCRef doGetMethodProvider(
00085       const ProviderEnvironmentIFCRef& env,
00086       const char* provIdString);
00087 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00088    virtual AssociatorProviderIFCRef doGetAssociatorProvider(
00089       const ProviderEnvironmentIFCRef& env,
00090       const char* provIdString);
00091 #endif
00092    virtual IndicationProviderIFCRef doGetIndicationProvider(
00093       const ProviderEnvironmentIFCRef& env,
00094       const char* provIdString);
00095    virtual IndicationExportProviderIFCRefArray doGetIndicationExportProviders(
00096       const ProviderEnvironmentIFCRef& env
00097       );
00098    virtual PolledProviderIFCRefArray doGetPolledProviders(
00099       const ProviderEnvironmentIFCRef& env
00100       );
00101    virtual void doUnloadProviders(const ProviderEnvironmentIFCRef& env);
00102    virtual void doShuttingDown(const ProviderEnvironmentIFCRef& env);
00103 private:
00104    // To prevent a potential deadlock situation, we can't call initialize() while m_guard is locked.
00105    // However, that presents a race condition for initializing providers, so each CppProviderBaseIFCRef
00106    // has an associated condition to address that. The details are handled by this class.
00107    class CppProviderInitializationHelper;
00108    typedef IntrusiveReference<CppProviderInitializationHelper> CppProviderInitializationHelperRef;
00109 
00110    typedef Map<String, CppProviderInitializationHelperRef> ProviderMap;
00111    typedef Map<String, IndicationProviderIFCRef> IndicationProviderMap;
00112    typedef Array<CppProviderBaseIFCRef> LoadedProviderArray;
00113    enum StoreProviderFlag
00114    {
00115       dontStoreProvider,
00116       storeProvider
00117    };
00118    enum InitializeProviderFlag
00119    {
00120       dontInitializeProvider,
00121       initializeProvider
00122    };
00123    // REQUIRE: (initP == initializeProvider && storeP == storeProvider) || (initP == dontInitializeProvider && storeP == dontStoreProvider)
00124    // i.e. if you initialize a provider, you must also store it.  If you don't initialize it, you can't store it.
00125    CppProviderBaseIFCRef getProvider(const ProviderEnvironmentIFCRef& env,
00126       const char* provIdString, StoreProviderFlag = storeProvider,
00127       InitializeProviderFlag = initializeProvider);
00128    void loadProviders(const ProviderEnvironmentIFCRef& env,
00129       InstanceProviderInfoArray& i,
00130       SecondaryInstanceProviderInfoArray& si,
00131 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00132       AssociatorProviderInfoArray& a,
00133 #endif
00134       MethodProviderInfoArray& m,
00135       IndicationProviderInfoArray& ind);
00136    ProviderMap m_provs;
00137    IndicationProviderMap m_indicationProviders;
00138    Mutex m_guard;
00139    LoadedProviderArray m_noUnloadProviders;
00140    bool m_loadDone;
00141 };
00142 typedef SharedLibraryReference< IntrusiveReference<CppProviderIFC> > CppProviderIFCRef;
00143 
00144 } // end namespace OW_NAMESPACE
00145 
00146 #endif

Generated on Thu Feb 9 08:47:58 2006 for openwbem by  doxygen 1.4.6