tdf#74608: Constructor function for SimpleLogRing singleton

Change-Id: Ia8c2f214b635114ecac4a2ceb06628a2f18b6411
Reviewed-on: https://gerrit.libreoffice.org/22020
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
yeliztaneroglu 2016-02-02 11:04:49 +02:00 committed by Stephan Bergmann
parent f84b8c0346
commit 1b6a84a5a2
5 changed files with 27 additions and 46 deletions

View File

@ -25,7 +25,6 @@
void createRegistryInfo_Map(); void createRegistryInfo_Map();
void createRegistryInfo_OInstanceLocker(); void createRegistryInfo_OInstanceLocker();
void createRegistryInfo_OPropertyBag(); void createRegistryInfo_OPropertyBag();
void createRegistryInfo_OSimpleLogRing();
void createRegistryInfo_SequenceInputStream(); void createRegistryInfo_SequenceInputStream();
void createRegistryInfo_SequenceOutputStream(); void createRegistryInfo_SequenceOutputStream();
void createRegistryInfo_UNOMemoryStream(); void createRegistryInfo_UNOMemoryStream();

View File

@ -40,7 +40,6 @@ namespace comphelper { namespace module
createRegistryInfo_UNOMemoryStream(); createRegistryInfo_UNOMemoryStream();
createRegistryInfo_OInstanceLocker(); createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map(); createRegistryInfo_Map();
createRegistryInfo_OSimpleLogRing();
} }
}; };

View File

@ -20,12 +20,11 @@
#include <com/sun/star/frame/DoubleInitializationException.hpp> #include <com/sun/star/frame/DoubleInitializationException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper_module.hxx>
#include <comphelper_services.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include "documentiologring.hxx" #include "documentiologring.hxx"
#include <rtl/ref.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
@ -46,31 +45,6 @@ OSimpleLogRing::~OSimpleLogRing()
{ {
} }
uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames_static()
{
uno::Sequence<OUString> aResult { getServiceName_static() };
return aResult;
}
OUString SAL_CALL OSimpleLogRing::getImplementationName_static()
{
return OUString( "com.sun.star.comp.logging.SimpleLogRing" );
}
OUString SAL_CALL OSimpleLogRing::getServiceName_static()
{
return OUString( "com.sun.star.logging.SimpleLogRing" );
}
uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::Create( SAL_UNUSED_PARAMETER const uno::Reference< uno::XComponentContext >& )
{
return static_cast< cppu::OWeakObject* >( new OSimpleLogRing );
}
// XSimpleLogRing // XSimpleLogRing
void SAL_CALL OSimpleLogRing::logString( const OUString& aMessage ) throw (uno::RuntimeException, std::exception) void SAL_CALL OSimpleLogRing::logString( const OUString& aMessage ) throw (uno::RuntimeException, std::exception)
@ -135,7 +109,7 @@ void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArgu
// XServiceInfo // XServiceInfo
OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException, std::exception) OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException, std::exception)
{ {
return getImplementationName_static(); return OUString("com.sun.star.comp.logging.SimpleLogRing");
} }
sal_Bool SAL_CALL OSimpleLogRing::supportsService( const OUString& aServiceName ) throw (uno::RuntimeException, std::exception) sal_Bool SAL_CALL OSimpleLogRing::supportsService( const OUString& aServiceName ) throw (uno::RuntimeException, std::exception)
@ -145,15 +119,33 @@ sal_Bool SAL_CALL OSimpleLogRing::supportsService( const OUString& aServiceName
uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException, std::exception) uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
{ {
return getSupportedServiceNames_static(); return { "com.sun.star.logging.SimpleLogRing" };
} }
} // namespace comphelper } // namespace comphelper
void createRegistryInfo_OSimpleLogRing() namespace {
struct Instance {
explicit Instance():
instance(new comphelper::OSimpleLogRing())
{}
css::uno::Reference<cppu::OWeakObject> instance;
};
struct Singleton:
public rtl::Static<Instance, Singleton>
{};
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_logging_SimpleLogRing(
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{ {
static ::comphelper::module::OAutoRegistration< ::comphelper::OSimpleLogRing > aAutoRegistration; return cppu::acquire(Singleton::get().instance.get());
static ::comphelper::module::OSingletonRegistration< ::comphelper::OSimpleLogRing > aSingletonRegistration;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -48,16 +48,6 @@ public:
OSimpleLogRing(); OSimpleLogRing();
virtual ~OSimpleLogRing(); virtual ~OSimpleLogRing();
static css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames_static();
static OUString SAL_CALL getImplementationName_static();
static OUString SAL_CALL getServiceName_static();
static css::uno::Reference< css::uno::XInterface > SAL_CALL
Create( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
// XSimpleLogRing // XSimpleLogRing
virtual void SAL_CALL logString( const OUString& aMessage ) throw (css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL logString( const OUString& aMessage ) throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< OUString > SAL_CALL getCollectedLog() throw (css::uno::RuntimeException, std::exception) override; virtual css::uno::Sequence< OUString > SAL_CALL getCollectedLog() throw (css::uno::RuntimeException, std::exception) override;

View File

@ -46,7 +46,8 @@
<implementation name="com.sun.star.comp.embed.InstanceLocker"> <implementation name="com.sun.star.comp.embed.InstanceLocker">
<service name="com.sun.star.embed.InstanceLocker"/> <service name="com.sun.star.embed.InstanceLocker"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.logging.SimpleLogRing"> <implementation name="com.sun.star.comp.logging.SimpleLogRing"
constructor="com_sun_star_comp_logging_SimpleLogRing">
<service name="com.sun.star.logging.SimpleLogRing"/> <service name="com.sun.star.logging.SimpleLogRing"/>
<singleton name="com.sun.star.logging.DocumentIOLogRing"/> <singleton name="com.sun.star.logging.DocumentIOLogRing"/>
</implementation> </implementation>