LibreOffice Module comphelper (master)  1
Classes | Public Member Functions | Private Attributes | Friends | List of all members
comphelper::service_decl::ServiceDecl Class Reference

Class to declare a service implementation. More...

#include <servicedecl.hxx>

Classes

class  Factory
 

Public Member Functions

 ServiceDecl (const ServiceDecl &)=delete
 Ctor for multiple supported service names. More...
 
ServiceDecloperator= (const ServiceDecl &)=delete
 
template<typename ImplClassT >
 ServiceDecl (ImplClassT const &implClass, char const *pImplName, char const *pSupportedServiceNames)
 
voidgetFactory (char const *pImplName) const
 
css::uno::Sequence< OUString > getSupportedServiceNames () const
 
bool supportsService (OUString const &name) const
 
OUString getImplementationName () const
 

Private Attributes

detail::CreateFuncF const m_createFunc
 
char const *const m_pImplName
 
char const *const m_pServiceNames
 

Friends

class Factory
 

Detailed Description

Class to declare a service implementation.

There is no need to implement lang::XServiceInfo nor lang::XInitialization anymore. The declaration can be done in various ways, the (simplest) form is

class MyClass : public cppu::WeakImplHelper<XInterface1, XInterface2> {
public:
    MyClass( uno::Reference<uno::XComponentContext> const& xContext )
    [...]
};
[...]
namespace sdecl = comphelper::service_decl;
sdecl::ServiceDecl const myDecl(
    sdecl::class_<MyClass>(),
    "my.unique.implementation.name",
    "MyServiceSpec1;MyServiceSpec2" );

If the service demands initialization by arguments, the implementation class has to define a constructor taking both arguments and component context:

class MyClass : public cppu::WeakImplHelper<XInterface1, XInterface2> {
public:
    MyClass( uno::Sequence<uno::Any> const& args,
             uno::Reference<uno:XComponentContext> const& xContext )
    [...]
};
[...]
namespace sdecl = comphelper::service_decl;
sdecl::ServiceDecl const myDecl(
    sdecl::class_<MyClass, sdecl::with_args<true> >(),
    "my.unique.implementation.name",
    "MyServiceSpec1;MyServiceSpec2" );

Additionally, there is the possibility to process some code after creation, e.g. to add the newly created object as a listener or perform aggregation (C++-UNO only):

uno::Reference<uno::XInterface> somePostProcCode( MyClass * p );
[...]
namespace sdecl = comphelper::service_decl;
sdecl::ServiceDecl const myDecl(
    sdecl::class_<MyClass, ... >(&somePostProcCode),
    "my.unique.implementation.name",
    "MyServiceSpec1;MyServiceSpec2" );

In the latter case, somePostProcCode gets the yet unacquired "raw" pointer.

Definition at line 95 of file servicedecl.hxx.

Constructor & Destructor Documentation

comphelper::service_decl::ServiceDecl::ServiceDecl ( const ServiceDecl )
delete

Ctor for multiple supported service names.

Parameters
implClassimplementation class description
pImplNameimplementation name
pSupportedServiceNamessupported service names
cDelimdelimiter for supported service names
template<typename ImplClassT >
comphelper::service_decl::ServiceDecl::ServiceDecl ( ImplClassT const &  implClass,
char const *  pImplName,
char const *  pSupportedServiceNames 
)
inline

Definition at line 108 of file servicedecl.hxx.

Member Function Documentation

void * comphelper::service_decl::ServiceDecl::getFactory ( char const *  pImplName) const

Definition at line 101 of file servicedecl.cxx.

OUString comphelper::service_decl::ServiceDecl::getImplementationName ( ) const
Returns
implementation name

Definition at line 140 of file servicedecl.cxx.

Referenced by comphelper::service_decl::ServiceDecl::Factory::getImplementationName().

uno::Sequence< OUString > comphelper::service_decl::ServiceDecl::getSupportedServiceNames ( ) const
Returns
supported service names

Definition at line 111 of file servicedecl.cxx.

References comphelper::containerToSequence(), and nIndex.

ServiceDecl& comphelper::service_decl::ServiceDecl::operator= ( const ServiceDecl )
delete
bool comphelper::service_decl::ServiceDecl::supportsService ( OUString const &  name) const
Returns
whether name is in set of supported service names

Definition at line 127 of file servicedecl.cxx.

References nIndex.

Friends And Related Function Documentation

friend class Factory
friend

Definition at line 128 of file servicedecl.hxx.

Member Data Documentation

detail::CreateFuncF const comphelper::service_decl::ServiceDecl::m_createFunc
private

Definition at line 131 of file servicedecl.hxx.

char const* const comphelper::service_decl::ServiceDecl::m_pImplName
private

Definition at line 132 of file servicedecl.hxx.

char const* const comphelper::service_decl::ServiceDecl::m_pServiceNames
private

Definition at line 133 of file servicedecl.hxx.


The documentation for this class was generated from the following files: