diff options
author | Kurt Zenker <kz@openoffice.org> | 2006-11-08 11:01:16 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2006-11-08 11:01:16 +0000 |
commit | d2e50e0b0e676a0039c976df1fe4db7b915a64cb (patch) | |
tree | 8f7efd9b9b5ca5ce4eebae2a6b9994cf9fd0e3c4 | |
parent | f1c1e969477c4b5c5d54ce9cd8f3116b42a2ec4b (diff) |
INTEGRATION: CWS basmgr01 (1.3.46); FILE MERGED
2006/09/28 20:02:55 fs 1.3.46.1: more convenience for using this module
-rw-r--r-- | comphelper/inc/comphelper/componentmodule.hxx | 115 |
1 files changed, 110 insertions, 5 deletions
diff --git a/comphelper/inc/comphelper/componentmodule.hxx b/comphelper/inc/comphelper/componentmodule.hxx index 0437bf0c4f51..3765bdd4eab5 100644 --- a/comphelper/inc/comphelper/componentmodule.hxx +++ b/comphelper/inc/comphelper/componentmodule.hxx @@ -4,9 +4,9 @@ * * $RCSfile: componentmodule.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2006-06-19 22:42:24 $ + * last change: $Author: kz $ $Date: 2006-11-08 12:01:16 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -146,9 +146,12 @@ namespace comphelper void registerImplementation( const ComponentDescription& _rComp ); /** write the registration information of all known components - <p>writes the registration information of all components which are currently registered into the - specified registry.<p/> - <p>Usually used from within component_writeInfo.<p/> + + Writes the registration information of all components which are currently registered into the + specified registry. + + Usually used from within component_writeInfo. + @param_rxServiceManager the service manager @param _rRootKey @@ -160,6 +163,10 @@ namespace comphelper const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager, const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey >& _rRootKey); + /** version of writeComponentInfos which directly takes the arguments you got in your component_writeInfo call + */ + sal_Bool writeComponentInfos( void* pServiceManager, void* pRegistryKey ); + /** creates a Factory for the component with the given implementation name. <p>Usually used from within component_getFactory.<p/> @param _rxServiceManager @@ -174,6 +181,12 @@ namespace comphelper const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager ); + /** version of getComponentFactory which directly takes the arguments you got in your component_getFactory call + */ + void* getComponentFactory( + const sal_Char* _pImplementationName, void* _pServiceManager, void* _pRegistryKey + ); + public: class ClientAccess { friend class OModuleClient; private: ClientAccess() { } }; /// register a client for the module @@ -248,6 +261,98 @@ namespace comphelper ); } + //========================================================================== + //= helpers + //========================================================================== + + //========================================================================== + // declaring a OModule for a component library + +#define DECLARE_COMPONENT_MODULE( ModuleClass, ClientClass ) \ + /* -------------------------------------------------------------------- */ \ + class ModuleClass : public ::comphelper::OModule \ + { \ + friend struct CreateModuleClass; \ + 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() ) \ + { \ + } \ + }; + + //========================================================================== + //= implementing a OModule for a component library + +#define IMPLEMENT_COMPONENT_MODULE( ModuleClass ) \ + struct CreateModuleClass \ + { \ + ModuleClass* operator()() \ + { \ + static ModuleClass* pModule = new ModuleClass; \ + return pModule; \ + } \ + }; \ + \ + ModuleClass::ModuleClass() \ + :BaseClass() \ + { \ + } \ + \ + ModuleClass& ModuleClass::getInstance() \ + { \ + return *rtl_Instance< ModuleClass, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >:: \ + create( CreateModuleClass(), ::osl::GetGlobalMutex() ); \ + } \ + + //========================================================================== + //= implementing the API of a component library (component_*) + +#define IMPLEMENT_COMPONENT_LIBRARY_API( module_class, initializer_function ) \ + extern "C" void SAL_CALL component_getImplementationEnvironment( \ + const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) \ + { \ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; \ + } \ + extern "C" sal_Bool SAL_CALL component_writeInfo( \ + void* pServiceManager, void* pRegistryKey ) \ + { \ + initializer_function(); \ + return module_class::getInstance().writeComponentInfos( pServiceManager, pRegistryKey ); \ + } \ + extern "C" 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 //........................................................................ |