Development/Cpp/Helper/ServiceDecl
From Apache OpenOffice Wiki
Class Name | Purpose | Location |
---|---|---|
ServiceDecl | is a helper class for providing the UNO component service factory boilerplate (the three exported C functions and associated code) | comphelper/servicedecl.hxx
|
Contents
Description
A ServiceDecl provides the service factory entry points for a UNO component.
Interface
Example
The following example provides two services to the UNO runtime. The ugly ifdef is courtesy gcc's old parser bug, and we'll hopefully get rid of that when the 3.3 versions are gone for good.
[cpp]
- include <comphelper/servicedecl.hxx>
class Foo : public SomeUNOInterface {...}; class Bar : public SomeOtherUNOInterface {...};
namespace sdecl = comphelper::service_decl;
- if defined (__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
sdecl::class_<SomeUNOInterface> serviceImpl; const sdecl::ServiceDecl serviceDecl1( serviceImpl,
- else
const sdecl::ServiceDecl serviceDecl2( sdecl::class_<SomeUNOInterface>(),
- endif
"com.sun.star.comp.stuff.MyImplName1", "com.sun.star.stuff.MyServiceName1" );
- if defined (__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
sdecl::class_<SomeOtherUNOInterface> serviceImpl; const sdecl::ServiceDecl serviceDecl2( serviceImpl,
- else
const sdecl::ServiceDecl serviceDecl2( sdecl::class_<SomeOtherUNOInterface>(),
- endif
"com.sun.star.comp.stuff.MyImplName2", "com.sun.star.stuff.MyServiceName2" );
// The C shared lib entry points COMPHELPER_SERVICEDECL_EXPORTS2(serviceDecl1,serviceDecl2)