Development/Cpp/Helper/ServiceDecl

From Apache OpenOffice Wiki
< Development‎ | Cpp‎ | Helper
Revision as of 10:32, 30 November 2007 by Thorsten (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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


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]

  1. include <comphelper/servicedecl.hxx>

class Foo : public SomeUNOInterface {...}; class Bar : public SomeOtherUNOInterface {...};

namespace sdecl = comphelper::service_decl;

  1. if defined (__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
sdecl::class_<SomeUNOInterface> serviceImpl;
const sdecl::ServiceDecl serviceDecl1(
    serviceImpl,
  1. else
const sdecl::ServiceDecl serviceDecl2(
    sdecl::class_<SomeUNOInterface>(),
  1. endif
    "com.sun.star.comp.stuff.MyImplName1",
    "com.sun.star.stuff.MyServiceName1" );
  1. if defined (__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
sdecl::class_<SomeOtherUNOInterface> serviceImpl;
const sdecl::ServiceDecl serviceDecl2(
    serviceImpl,
  1. else
const sdecl::ServiceDecl serviceDecl2(
    sdecl::class_<SomeOtherUNOInterface>(),
  1. endif
    "com.sun.star.comp.stuff.MyImplName2",
    "com.sun.star.stuff.MyServiceName2" );

// The C shared lib entry points COMPHELPER_SERVICEDECL_EXPORTS2(serviceDecl1,serviceDecl2)

Personal tools