1*9877b273SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9877b273SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9877b273SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9877b273SAndrew Rist * distributed with this work for additional information 6*9877b273SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9877b273SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9877b273SAndrew Rist * "License"); you may not use this file except in compliance 9*9877b273SAndrew Rist * with the License. You may obtain a copy of the License at 10*9877b273SAndrew Rist * 11*9877b273SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9877b273SAndrew Rist * 13*9877b273SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9877b273SAndrew Rist * software distributed under the License is distributed on an 15*9877b273SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9877b273SAndrew Rist * KIND, either express or implied. See the License for the 17*9877b273SAndrew Rist * specific language governing permissions and limitations 18*9877b273SAndrew Rist * under the License. 19*9877b273SAndrew Rist * 20*9877b273SAndrew Rist *************************************************************/ 21*9877b273SAndrew Rist 22*9877b273SAndrew Rist 23cdf0e10cSrcweir #ifndef COMPHELPER_INC_COMPHELPER_COMPONENTMODULE_HXX 24cdf0e10cSrcweir #define COMPHELPER_INC_COMPHELPER_COMPONENTMODULE_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <comphelper/comphelperdllapi.h> 27cdf0e10cSrcweir #include <comphelper/legacysingletonfactory.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir /** === begin UNO includes === **/ 30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 32cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 33cdf0e10cSrcweir /** === end UNO includes === **/ 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <osl/mutex.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <rtl/string.hxx> 40cdf0e10cSrcweir #include <rtl/instance.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir //........................................................................ 43cdf0e10cSrcweir namespace comphelper 44cdf0e10cSrcweir { 45cdf0e10cSrcweir //........................................................................ 46cdf0e10cSrcweir 47cdf0e10cSrcweir /** factory factory declaration 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > (SAL_CALL *FactoryInstantiation) 50cdf0e10cSrcweir ( 51cdf0e10cSrcweir ::cppu::ComponentFactoryFunc _pFactoryFunc, 52cdf0e10cSrcweir ::rtl::OUString const& _rComponentName, 53cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > const & _rServiceNames, 54cdf0e10cSrcweir rtl_ModuleCount* _pModuleCounter 55cdf0e10cSrcweir ) SAL_THROW(()); 56cdf0e10cSrcweir 57cdf0e10cSrcweir //========================================================================= 58cdf0e10cSrcweir //= ComponentDescription 59cdf0e10cSrcweir //========================================================================= 60cdf0e10cSrcweir struct COMPHELPER_DLLPUBLIC ComponentDescription 61cdf0e10cSrcweir { 62cdf0e10cSrcweir /// the implementation name of the component 63cdf0e10cSrcweir ::rtl::OUString sImplementationName; 64cdf0e10cSrcweir /// the services supported by the component implementation 65cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupportedServices; 66cdf0e10cSrcweir /** the name under which the component implementation should be registered as singleton, 67cdf0e10cSrcweir or empty if the component does not implement a singleton. 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir ::rtl::OUString sSingletonName; 70cdf0e10cSrcweir /// the function to create an instance of the component 71cdf0e10cSrcweir ::cppu::ComponentFactoryFunc pComponentCreationFunc; 72cdf0e10cSrcweir /// the function to create a factory for the component (usually <code>::cppu::createSingleComponentFactory</code>) 73cdf0e10cSrcweir FactoryInstantiation pFactoryCreationFunc; 74cdf0e10cSrcweir ComponentDescriptioncomphelper::ComponentDescription75cdf0e10cSrcweir ComponentDescription() 76cdf0e10cSrcweir :sImplementationName() 77cdf0e10cSrcweir ,aSupportedServices() 78cdf0e10cSrcweir ,sSingletonName() 79cdf0e10cSrcweir ,pComponentCreationFunc( NULL ) 80cdf0e10cSrcweir ,pFactoryCreationFunc( NULL ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir } 83cdf0e10cSrcweir ComponentDescriptioncomphelper::ComponentDescription84cdf0e10cSrcweir ComponentDescription( 85cdf0e10cSrcweir const ::rtl::OUString& _rImplementationName, 86cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rSupportedServices, 87cdf0e10cSrcweir const ::rtl::OUString& _rSingletonName, 88cdf0e10cSrcweir ::cppu::ComponentFactoryFunc _pComponentCreationFunc, 89cdf0e10cSrcweir FactoryInstantiation _pFactoryCreationFunc 90cdf0e10cSrcweir ) 91cdf0e10cSrcweir :sImplementationName( _rImplementationName ) 92cdf0e10cSrcweir ,aSupportedServices( _rSupportedServices ) 93cdf0e10cSrcweir ,sSingletonName( _rSingletonName ) 94cdf0e10cSrcweir ,pComponentCreationFunc( _pComponentCreationFunc ) 95cdf0e10cSrcweir ,pFactoryCreationFunc( _pFactoryCreationFunc ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir } 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir 100cdf0e10cSrcweir //========================================================================= 101cdf0e10cSrcweir //= OModule 102cdf0e10cSrcweir //========================================================================= 103cdf0e10cSrcweir class OModuleImpl; 104cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OModule 105cdf0e10cSrcweir { 106cdf0e10cSrcweir private: 107cdf0e10cSrcweir oslInterlockedCount m_nClients; /// number of registered clients 108cdf0e10cSrcweir OModuleImpl* m_pImpl; /// impl class. lives as long as at least one client for the module is registered 109cdf0e10cSrcweir 110cdf0e10cSrcweir protected: 111cdf0e10cSrcweir mutable ::osl::Mutex m_aMutex; /// access safety 112cdf0e10cSrcweir 113cdf0e10cSrcweir public: 114cdf0e10cSrcweir OModule(); 115cdf0e10cSrcweir 116cdf0e10cSrcweir virtual ~OModule(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir /** register a component implementing a service with the given data. 119cdf0e10cSrcweir @param _rImplementationName 120cdf0e10cSrcweir the implementation name of the component 121cdf0e10cSrcweir @param _rServiceNames 122cdf0e10cSrcweir the services the component supports 123cdf0e10cSrcweir @param _pCreateFunction 124cdf0e10cSrcweir a function for creating an instance of the component 125cdf0e10cSrcweir @param _pFactoryFunction 126cdf0e10cSrcweir a function for creating a factory for that component 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir void registerImplementation( 129cdf0e10cSrcweir const ::rtl::OUString& _rImplementationName, 130cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames, 131cdf0e10cSrcweir ::cppu::ComponentFactoryFunc _pCreateFunction, 132cdf0e10cSrcweir FactoryInstantiation _pFactoryFunction = ::cppu::createSingleComponentFactory ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /** registers a component given by <type>ComponentDescription</type> 135cdf0e10cSrcweir */ 136cdf0e10cSrcweir void registerImplementation( const ComponentDescription& _rComp ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir /** creates a Factory for the component with the given implementation name. 139cdf0e10cSrcweir <p>Usually used from within component_getFactory.<p/> 140cdf0e10cSrcweir @param _rxServiceManager 141cdf0e10cSrcweir a pointer to an XMultiServiceFactory interface as got in component_getFactory 142cdf0e10cSrcweir @param _pImplementationName 143cdf0e10cSrcweir the implementation name of the component 144cdf0e10cSrcweir @return 145cdf0e10cSrcweir the XInterface access to a factory for the component 146cdf0e10cSrcweir */ 147cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getComponentFactory( 148cdf0e10cSrcweir const ::rtl::OUString& _rImplementationName, 149cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager 150cdf0e10cSrcweir ); 151cdf0e10cSrcweir 152cdf0e10cSrcweir /** version of getComponentFactory which directly takes the arguments you got in your component_getFactory call 153cdf0e10cSrcweir */ 154cdf0e10cSrcweir void* getComponentFactory( 155cdf0e10cSrcweir const sal_Char* _pImplementationName, void* _pServiceManager, void* _pRegistryKey 156cdf0e10cSrcweir ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir public: ClientAccess()159cdf0e10cSrcweir class ClientAccess { friend class OModuleClient; private: ClientAccess() { } }; 160cdf0e10cSrcweir /// register a client for the module 161cdf0e10cSrcweir void registerClient( ClientAccess ); 162cdf0e10cSrcweir /// revoke a client for the module 163cdf0e10cSrcweir void revokeClient( ClientAccess ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir protected: 166cdf0e10cSrcweir /** called when the first client has been registered 167cdf0e10cSrcweir @precond 168cdf0e10cSrcweir <member>m_aMutex</member> is locked 169cdf0e10cSrcweir */ 170cdf0e10cSrcweir virtual void onFirstClient(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir /** called when the last client has been revoked 173cdf0e10cSrcweir @precond 174cdf0e10cSrcweir <member>m_aMutex</member> is locked 175cdf0e10cSrcweir */ 176cdf0e10cSrcweir virtual void onLastClient(); 177cdf0e10cSrcweir 178cdf0e10cSrcweir private: 179cdf0e10cSrcweir OModule( const OModule& ); // never implemented 180cdf0e10cSrcweir OModule& operator=( const OModule& ); // never implemented 181cdf0e10cSrcweir }; 182cdf0e10cSrcweir 183cdf0e10cSrcweir //========================================================================= 184cdf0e10cSrcweir //= OModuleClient 185cdf0e10cSrcweir //========================================================================= 186cdf0e10cSrcweir /** base class for objects which uses any global module-specific ressources 187cdf0e10cSrcweir */ 188cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OModuleClient 189cdf0e10cSrcweir { 190cdf0e10cSrcweir protected: 191cdf0e10cSrcweir OModule& m_rModule; 192cdf0e10cSrcweir 193cdf0e10cSrcweir public: OModuleClient(OModule & _rModule)194cdf0e10cSrcweir OModuleClient( OModule& _rModule ) :m_rModule( _rModule ) { m_rModule.registerClient( OModule::ClientAccess() ); } ~OModuleClient()195cdf0e10cSrcweir ~OModuleClient() { m_rModule.revokeClient( OModule::ClientAccess() ); } 196cdf0e10cSrcweir }; 197cdf0e10cSrcweir 198cdf0e10cSrcweir //========================================================================== 199cdf0e10cSrcweir //= OAutoRegistration 200cdf0e10cSrcweir //========================================================================== 201cdf0e10cSrcweir template <class TYPE> 202cdf0e10cSrcweir class OAutoRegistration 203cdf0e10cSrcweir { 204cdf0e10cSrcweir public: 205cdf0e10cSrcweir /** automatically provides all component information to an OModule instance 206cdf0e10cSrcweir <p>Assumed that the template argument has the three methods 207cdf0e10cSrcweir <ul> 208cdf0e10cSrcweir <li><code>static ::rtl::OUString getImplementationName_static()</code><li/> 209cdf0e10cSrcweir <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static()</code><li/> 210cdf0e10cSrcweir <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 211cdf0e10cSrcweir Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code> 212cdf0e10cSrcweir </li> 213cdf0e10cSrcweir <ul/> 214cdf0e10cSrcweir the instantiation of this object will automatically register the class via <member>OModule::registerImplementation</member>. 215cdf0e10cSrcweir <p/> 216cdf0e10cSrcweir The factory creation function used is <code>::cppu::createSingleComponentFactory</code>. 217cdf0e10cSrcweir */ 218cdf0e10cSrcweir OAutoRegistration( OModule& _rModule ); 219cdf0e10cSrcweir }; 220cdf0e10cSrcweir 221cdf0e10cSrcweir template <class TYPE> OAutoRegistration(OModule & _rModule)222cdf0e10cSrcweir OAutoRegistration<TYPE>::OAutoRegistration( OModule& _rModule ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir _rModule.registerImplementation( 225cdf0e10cSrcweir TYPE::getImplementationName_static(), 226cdf0e10cSrcweir TYPE::getSupportedServiceNames_static(), 227cdf0e10cSrcweir TYPE::Create 228cdf0e10cSrcweir ); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir //========================================================================== 232cdf0e10cSrcweir //= OSingletonRegistration 233cdf0e10cSrcweir //========================================================================== 234cdf0e10cSrcweir template <class TYPE> 235cdf0e10cSrcweir class OSingletonRegistration 236cdf0e10cSrcweir { 237cdf0e10cSrcweir public: 238cdf0e10cSrcweir /** automatically provides all component information to an OModule instance, 239cdf0e10cSrcweir for a singleton component 240cdf0e10cSrcweir 241cdf0e10cSrcweir <p>Assumed that the template argument has the three methods 242cdf0e10cSrcweir <ul> 243cdf0e10cSrcweir <li><code>static ::rtl::OUString getImplementationName_static()</code><li/> 244cdf0e10cSrcweir <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static()</code><li/> 245cdf0e10cSrcweir <li><code>static ::rtl::OUString getSingletonName_static()</code></li> 246cdf0e10cSrcweir <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 247cdf0e10cSrcweir Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code> 248cdf0e10cSrcweir </li> 249cdf0e10cSrcweir <ul/> 250cdf0e10cSrcweir the instantiation of this object will automatically register the class via <member>OModule::registerImplementation</member>. 251cdf0e10cSrcweir </p> 252cdf0e10cSrcweir */ 253cdf0e10cSrcweir OSingletonRegistration( OModule& _rModule ); 254cdf0e10cSrcweir }; 255cdf0e10cSrcweir 256cdf0e10cSrcweir template <class TYPE> 257cdf0e10cSrcweir //-------------------------------------------------------------------------- OSingletonRegistration(OModule & _rModule)258cdf0e10cSrcweir OSingletonRegistration<TYPE>::OSingletonRegistration( OModule& _rModule ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir _rModule.registerImplementation( ComponentDescription( 261cdf0e10cSrcweir TYPE::getImplementationName_static(), 262cdf0e10cSrcweir TYPE::getSupportedServiceNames_static(), 263cdf0e10cSrcweir TYPE::getSingletonName_static(), 264cdf0e10cSrcweir &TYPE::Create, 265cdf0e10cSrcweir &::cppu::createSingleComponentFactory 266cdf0e10cSrcweir ) ); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir //========================================================================== 270cdf0e10cSrcweir //= OLegacySingletonRegistration 271cdf0e10cSrcweir //========================================================================== 272cdf0e10cSrcweir template <class TYPE> 273cdf0e10cSrcweir class OLegacySingletonRegistration 274cdf0e10cSrcweir { 275cdf0e10cSrcweir public: 276cdf0e10cSrcweir OLegacySingletonRegistration( OModule& _rModule ); 277cdf0e10cSrcweir }; 278cdf0e10cSrcweir 279cdf0e10cSrcweir //-------------------------------------------------------------------------- 280cdf0e10cSrcweir template <class TYPE> OLegacySingletonRegistration(OModule & _rModule)281cdf0e10cSrcweir OLegacySingletonRegistration<TYPE>::OLegacySingletonRegistration( OModule& _rModule ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir _rModule.registerImplementation( ComponentDescription( 284cdf0e10cSrcweir TYPE::getImplementationName_static(), 285cdf0e10cSrcweir TYPE::getSupportedServiceNames_static(), 286cdf0e10cSrcweir ::rtl::OUString(), 287cdf0e10cSrcweir &TYPE::Create, 288cdf0e10cSrcweir &::comphelper::createLegacySingletonFactory 289cdf0e10cSrcweir ) ); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir //========================================================================== 293cdf0e10cSrcweir //= helpers 294cdf0e10cSrcweir //========================================================================== 295cdf0e10cSrcweir 296cdf0e10cSrcweir //========================================================================== 297cdf0e10cSrcweir // declaring a OModule for a component library 298cdf0e10cSrcweir 299cdf0e10cSrcweir #define DECLARE_COMPONENT_MODULE( ModuleClass, ClientClass ) \ 300cdf0e10cSrcweir /* -------------------------------------------------------------------- */ \ 301cdf0e10cSrcweir class ModuleClass : public ::comphelper::OModule \ 302cdf0e10cSrcweir { \ 303cdf0e10cSrcweir friend struct CreateModuleClass; \ 304cdf0e10cSrcweir typedef ::comphelper::OModule BaseClass; \ 305cdf0e10cSrcweir \ 306cdf0e10cSrcweir public: \ 307cdf0e10cSrcweir static ModuleClass& getInstance(); \ 308cdf0e10cSrcweir \ 309cdf0e10cSrcweir private: \ 310cdf0e10cSrcweir ModuleClass(); \ 311cdf0e10cSrcweir }; \ 312cdf0e10cSrcweir \ 313cdf0e10cSrcweir /* -------------------------------------------------------------------- */ \ 314cdf0e10cSrcweir class ClientClass : public ::comphelper::OModuleClient \ 315cdf0e10cSrcweir { \ 316cdf0e10cSrcweir private: \ 317cdf0e10cSrcweir typedef ::comphelper::OModuleClient BaseClass; \ 318cdf0e10cSrcweir \ 319cdf0e10cSrcweir public: \ 320cdf0e10cSrcweir ClientClass() : BaseClass( ModuleClass::getInstance() ) \ 321cdf0e10cSrcweir { \ 322cdf0e10cSrcweir } \ 323cdf0e10cSrcweir }; \ 324cdf0e10cSrcweir \ 325cdf0e10cSrcweir /* -------------------------------------------------------------------- */ \ 326cdf0e10cSrcweir template < class TYPE > \ 327cdf0e10cSrcweir class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE > \ 328cdf0e10cSrcweir { \ 329cdf0e10cSrcweir private: \ 330cdf0e10cSrcweir typedef ::comphelper::OAutoRegistration< TYPE > BaseClass; \ 331cdf0e10cSrcweir \ 332cdf0e10cSrcweir public: \ 333cdf0e10cSrcweir OAutoRegistration() : BaseClass( ModuleClass::getInstance() ) \ 334cdf0e10cSrcweir { \ 335cdf0e10cSrcweir } \ 336cdf0e10cSrcweir }; \ 337cdf0e10cSrcweir /* -------------------------------------------------------------------- */ \ 338cdf0e10cSrcweir template < class TYPE > \ 339cdf0e10cSrcweir class OSingletonRegistration : public ::comphelper::OSingletonRegistration< TYPE > \ 340cdf0e10cSrcweir { \ 341cdf0e10cSrcweir private: \ 342cdf0e10cSrcweir typedef ::comphelper::OSingletonRegistration< TYPE > BaseClass; \ 343cdf0e10cSrcweir \ 344cdf0e10cSrcweir public: \ 345cdf0e10cSrcweir OSingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ 346cdf0e10cSrcweir { \ 347cdf0e10cSrcweir } \ 348cdf0e10cSrcweir }; \ 349cdf0e10cSrcweir /* -------------------------------------------------------------------- */ \ 350cdf0e10cSrcweir template < class TYPE > \ 351cdf0e10cSrcweir class OLegacySingletonRegistration : public ::comphelper::OLegacySingletonRegistration< TYPE > \ 352cdf0e10cSrcweir { \ 353cdf0e10cSrcweir private: \ 354cdf0e10cSrcweir typedef ::comphelper::OLegacySingletonRegistration< TYPE > BaseClass; \ 355cdf0e10cSrcweir \ 356cdf0e10cSrcweir public: \ 357cdf0e10cSrcweir OLegacySingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ 358cdf0e10cSrcweir { \ 359cdf0e10cSrcweir } \ 360cdf0e10cSrcweir }; \ 361cdf0e10cSrcweir 362cdf0e10cSrcweir //========================================================================== 363cdf0e10cSrcweir //= implementing a OModule for a component library 364cdf0e10cSrcweir 365cdf0e10cSrcweir #define IMPLEMENT_COMPONENT_MODULE( ModuleClass ) \ 366cdf0e10cSrcweir struct CreateModuleClass \ 367cdf0e10cSrcweir { \ 368cdf0e10cSrcweir ModuleClass* operator()() \ 369cdf0e10cSrcweir { \ 370cdf0e10cSrcweir static ModuleClass* pModule = new ModuleClass; \ 371cdf0e10cSrcweir return pModule; \ 372cdf0e10cSrcweir } \ 373cdf0e10cSrcweir }; \ 374cdf0e10cSrcweir \ 375cdf0e10cSrcweir ModuleClass::ModuleClass() \ 376cdf0e10cSrcweir :BaseClass() \ 377cdf0e10cSrcweir { \ 378cdf0e10cSrcweir } \ 379cdf0e10cSrcweir \ 380cdf0e10cSrcweir ModuleClass& ModuleClass::getInstance() \ 381cdf0e10cSrcweir { \ 382cdf0e10cSrcweir return *rtl_Instance< ModuleClass, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >:: \ 383cdf0e10cSrcweir create( CreateModuleClass(), ::osl::GetGlobalMutex() ); \ 384cdf0e10cSrcweir } \ 385cdf0e10cSrcweir 386cdf0e10cSrcweir //========================================================================== 387cdf0e10cSrcweir //= implementing the API of a component library (component_*) 388cdf0e10cSrcweir 389cdf0e10cSrcweir #define IMPLEMENT_COMPONENT_LIBRARY_API( module_class, initializer_function ) \ 390cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL \ 391cdf0e10cSrcweir component_getImplementationEnvironment( \ 392cdf0e10cSrcweir const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) \ 393cdf0e10cSrcweir { \ 394cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; \ 395cdf0e10cSrcweir } \ 396cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( \ 397cdf0e10cSrcweir const sal_Char* pImplementationName, void* pServiceManager, void* pRegistryKey ) \ 398cdf0e10cSrcweir { \ 399cdf0e10cSrcweir initializer_function(); \ 400cdf0e10cSrcweir return module_class::getInstance().getComponentFactory( pImplementationName, pServiceManager, pRegistryKey ); \ 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir //........................................................................ 404cdf0e10cSrcweir } // namespace comphelper 405cdf0e10cSrcweir //........................................................................ 406cdf0e10cSrcweir 407cdf0e10cSrcweir #endif // COMPHELPER_INC_COMPHELPER_COMPONENTMODULE_HXX 408cdf0e10cSrcweir 409