diff options
-rw-r--r-- | comphelper/inc/comphelper/componentmodule.hxx | 92 | ||||
-rw-r--r-- | comphelper/source/inc/comphelper_module.hxx | 50 | ||||
-rw-r--r-- | comphelper/source/misc/comphelper_module.cxx | 19 | ||||
-rw-r--r-- | comphelper/source/misc/comphelper_services.cxx | 7 | ||||
-rw-r--r-- | svtools/workben/unodialog/udlg_services.cxx | 7 |
5 files changed, 79 insertions, 96 deletions
diff --git a/comphelper/inc/comphelper/componentmodule.hxx b/comphelper/inc/comphelper/componentmodule.hxx index 198d6c37bb20..5893313c8497 100644 --- a/comphelper/inc/comphelper/componentmodule.hxx +++ b/comphelper/inc/comphelper/componentmodule.hxx @@ -270,98 +270,6 @@ namespace comphelper ) ); } - //========================================================================== - //= helpers - //========================================================================== - - //========================================================================== - // declaring a OModule for a component library - -#define DECLARE_COMPONENT_MODULE( ModuleClass, ClientClass ) \ - /* -------------------------------------------------------------------- */ \ - class ModuleClass : public ::comphelper::OModule \ - { \ - friend struct ModuleClass##Creator; \ - typedef ::comphelper::OModule BaseClass; \ - \ - public: \ - static ModuleClass& getInstance(); \ - \ - private: \ - ModuleClass(); \ - }; \ - \ - /* -------------------------------------------------------------------- */ \ - class ClientClass : public ::comphelper::OModuleClient \ - { \ - private: \ - typedef ::comphelper::OModuleClient BaseClass; \ - \ - public: \ - ClientClass() : BaseClass( ModuleClass::getInstance() ) \ - { \ - } \ - }; \ - \ - /* -------------------------------------------------------------------- */ \ - template < class TYPE > \ - class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE > \ - { \ - private: \ - typedef ::comphelper::OAutoRegistration< TYPE > BaseClass; \ - \ - public: \ - OAutoRegistration() : BaseClass( ModuleClass::getInstance() ) \ - { \ - } \ - }; \ - /* -------------------------------------------------------------------- */ \ - template < class TYPE > \ - class OSingletonRegistration : public ::comphelper::OSingletonRegistration< TYPE > \ - { \ - private: \ - typedef ::comphelper::OSingletonRegistration< TYPE > BaseClass; \ - \ - public: \ - OSingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ - { \ - } \ - }; - - //========================================================================== - //= implementing a OModule for a component library - -#define IMPLEMENT_COMPONENT_MODULE( ModuleClass ) \ - struct ModuleClass##Creator \ - { \ - ModuleClass m_aModuleClass; \ - }; \ - namespace \ - { \ - class the##ModuleClass##Instance : public rtl::Static<ModuleClass##Creator, the##ModuleClass##Instance> {}; \ - } \ - \ - ModuleClass::ModuleClass() \ - :BaseClass() \ - { \ - } \ - \ - ModuleClass& ModuleClass::getInstance() \ - { \ - return the##ModuleClass##Instance::get().m_aModuleClass; \ - } \ - - //========================================================================== - //= implementing the API of a component library (component_*) - -#define IMPLEMENT_COMPONENT_LIBRARY_API( module_class, initializer_function ) \ - extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( \ - const sal_Char* pImplementationName, void* pServiceManager, void* pRegistryKey ) \ - { \ - initializer_function(); \ - return module_class::getInstance().getComponentFactory( pImplementationName, pServiceManager, pRegistryKey ); \ - } - //........................................................................ } // namespace comphelper //........................................................................ diff --git a/comphelper/source/inc/comphelper_module.hxx b/comphelper/source/inc/comphelper_module.hxx index 9f8e32656715..dfa364df1983 100644 --- a/comphelper/source/inc/comphelper_module.hxx +++ b/comphelper/source/inc/comphelper_module.hxx @@ -35,7 +35,55 @@ namespace comphelper { namespace module { //........................................................................ - DECLARE_COMPONENT_MODULE( ComphelperModule, ComphelperModuleClient ) + class ComphelperModule : public ::comphelper::OModule + { + friend struct ComphelperModuleCreator; + typedef ::comphelper::OModule BaseClass; + + public: + static ComphelperModule& getInstance(); + + private: + ComphelperModule(); + }; + + /* -------------------------------------------------------------------- */ + class ComphelperModuleClient : public ::comphelper::OModuleClient + { + private: + typedef ::comphelper::OModuleClient BaseClass; + + public: + ComphelperModuleClient() : BaseClass( ComphelperModule::getInstance() ) + { + } + }; + + /* -------------------------------------------------------------------- */ + template < class TYPE > + class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE > + { + private: + typedef ::comphelper::OAutoRegistration< TYPE > BaseClass; + + public: + OAutoRegistration() : BaseClass( ComphelperModule::getInstance() ) + { + } + }; + + /* -------------------------------------------------------------------- */ + template < class TYPE > + class OSingletonRegistration : public ::comphelper::OSingletonRegistration< TYPE > + { + private: + typedef ::comphelper::OSingletonRegistration< TYPE > BaseClass; + + public: + OSingletonRegistration() : BaseClass( ComphelperModule::getInstance() ) + { + } + }; //........................................................................ } } // namespace comphelper::module diff --git a/comphelper/source/misc/comphelper_module.cxx b/comphelper/source/misc/comphelper_module.cxx index 8b9ee4221dfc..b2bdad6665cb 100644 --- a/comphelper/source/misc/comphelper_module.cxx +++ b/comphelper/source/misc/comphelper_module.cxx @@ -35,7 +35,24 @@ namespace comphelper { namespace module { //........................................................................ - IMPLEMENT_COMPONENT_MODULE( ComphelperModule ); + struct ComphelperModuleCreator + { + ComphelperModule m_aComphelperModule; + }; + namespace + { + class theComphelperModuleInstance : public rtl::Static<ComphelperModuleCreator, theComphelperModuleInstance> {}; + } + + ComphelperModule::ComphelperModule() + :BaseClass() + { + } + + ComphelperModule& ComphelperModule::getInstance() + { + return theComphelperModuleInstance::get().m_aComphelperModule; + } //........................................................................ } } // namespace comphelper::module diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx index 32d1c53aff93..ad5558fb8ee7 100644 --- a/comphelper/source/misc/comphelper_services.cxx +++ b/comphelper/source/misc/comphelper_services.cxx @@ -85,6 +85,11 @@ namespace comphelper { namespace module } } // namespace comphelper::module //........................................................................ -IMPLEMENT_COMPONENT_LIBRARY_API( ::comphelper::module::ComphelperModule, ::comphelper::module::initializeModule ) +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, void* pServiceManager, void* pRegistryKey ) +{ + ::comphelper::module::initializeModule(); + return ::comphelper::module::ComphelperModule::getInstance().getComponentFactory( pImplementationName, pServiceManager, pRegistryKey ); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/workben/unodialog/udlg_services.cxx b/svtools/workben/unodialog/udlg_services.cxx index bf9386dd7aea..cb2949791e9c 100644 --- a/svtools/workben/unodialog/udlg_services.cxx +++ b/svtools/workben/unodialog/udlg_services.cxx @@ -56,6 +56,11 @@ namespace udlg } // namespace udlg //........................................................................ -IMPLEMENT_COMPONENT_LIBRARY_API( ::udlg::UdlgModule, ::udlg::initializeModule ) +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, void* pServiceManager, void* pRegistryKey ) +{ + ::udlg::initializeModule(); + return ::udlg::UdlgModule::getInstance().getComponentFactory( pImplementationName, pServiceManager, pRegistryKey ); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |