Type info
Title Service Declarations
Posted by [EMAIL PROTECTED]
Affected -,
Effective from cws dbo510


Summary

header file: comphelper/servicedecl.hxx:


[namespace comphelper::service_decl]
+ class ServiceDecl;
+ template <bool> struct with_args;
+ template <typename ImplT_, typename WithArgsT = with_args<false> > struct class_;
+ inline sal_Bool component_writeInfoHelper( ::com::sun::star::lang::XMultiServiceFactory *, ::com::sun::star::registry::XRegistryKey * xRegistryKey, ServiceDecl const& s0, ServiceDecl const& s1, ... );
+ inline void * component_getFactoryHelper( sal_Char const* pImplName, ::com::sun::star::lang::XMultiServiceFactory *, ::com::sun::star::registry::XRegistryKey * xRegistryKey, ServiceDecl const& s0, ServiceDecl const& s1, ... );


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

<pre>
class MyClass : cppu::WeakImplHelper2<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" );
</pre>

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

<pre>
class MyClass : cppu::WeakImplHelper2<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" );
</pre>

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):

<pre>
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" );
</pre>

In the latter case, somePostProcCode gets the *yet unacquired*
"raw" pointer.
*/
class ServiceDecl;

/** To specify whether the implementation class expects arguments
(uno::Sequence<uno::Any>).
*/
template <bool> struct with_args;

/** Defines a service implementation class.

@tpl ImplT_ service implementation class
@WithArgsT whether the implementation class ctor expects arguments
(uno::Sequence<uno::Any>,
uno::Reference<uno::XComponentContext>)
or just (uno::Reference<uno::XComponentContext>)
*/
template <typename ImplT_, typename WithArgsT = with_args<false> >
struct class_;

/** The following preprocessor repetitions generate functions like

<pre>
inline sal_Bool component_writeInfoHelper(
::com::sun::star::lang::XMultiServiceFactory *,
::com::sun::star::registry::XRegistryKey * xRegistryKey,
ServiceDecl const& s0, ServiceDecl const& s1, ... );

inline void * component_getFactoryHelper(
sal_Char const* pImplName,
::com::sun::star::lang::XMultiServiceFactory *,
::com::sun::star::registry::XRegistryKey * xRegistryKey,
ServiceDecl const& s0, ServiceDecl const& s1, ... );
</pre>

which call on the passed service declarations.

The maximum number of service declarations can be set by defining
COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS; its default is 8.
*/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to