LibreOffice Module comphelper (master)
1
|
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... | |
ServiceDecl & | operator= (const ServiceDecl &)=delete |
template<typename ImplClassT > | |
ServiceDecl (ImplClassT const &implClass, char const *pImplName, char const *pSupportedServiceNames) | |
void * | getFactory (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 |
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.
|
delete |
Ctor for multiple supported service names.
implClass | implementation class description |
pImplName | implementation name |
pSupportedServiceNames | supported service names |
cDelim | delimiter for supported service names |
|
inline |
Definition at line 108 of file servicedecl.hxx.
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 |
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 |
Definition at line 111 of file servicedecl.cxx.
References comphelper::containerToSequence(), and nIndex.
|
delete |
bool comphelper::service_decl::ServiceDecl::supportsService | ( | OUString const & | name | ) | const |
Definition at line 127 of file servicedecl.cxx.
References nIndex.
|
friend |
Definition at line 128 of file servicedecl.hxx.
|
private |
Definition at line 131 of file servicedecl.hxx.
|
private |
Definition at line 132 of file servicedecl.hxx.
|
private |
Definition at line 133 of file servicedecl.hxx.