Kaydet (Commit) 74140442 authored tarafından Matúš Kukan's avatar Matúš Kukan

Drop macros from componentmodule.hxx

üst d423fd54
...@@ -270,98 +270,6 @@ namespace comphelper ...@@ -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 } // namespace comphelper
//........................................................................ //........................................................................
......
...@@ -35,7 +35,55 @@ namespace comphelper { namespace module ...@@ -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 } } // namespace comphelper::module
......
...@@ -35,7 +35,24 @@ namespace comphelper { namespace module ...@@ -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 } } // namespace comphelper::module
......
...@@ -85,6 +85,11 @@ namespace comphelper { namespace module ...@@ -85,6 +85,11 @@ namespace comphelper { namespace module
} } // namespace comphelper::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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -56,6 +56,11 @@ namespace udlg ...@@ -56,6 +56,11 @@ namespace udlg
} // 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment