LibreOffice Module comphelper (master)  1
servicedecl.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_COMPHELPER_SERVICEDECL_HXX
20 #define INCLUDED_COMPHELPER_SERVICEDECL_HXX
21 
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 
26 #include <functional>
27 #include <initializer_list>
28 
29 namespace comphelper::service_decl {
30 
31 class ServiceDecl;
32 
33 namespace detail {
34 typedef ::std::function<
35  css::uno::Reference<css::uno::XInterface> /* return */
36  (ServiceDecl const&,
37  css::uno::Sequence<css::uno::Any> const&,
38  css::uno::Reference<css::uno::XComponentContext> const&)> CreateFuncF;
39 }
40 
95 {
96 public:
104  ServiceDecl( const ServiceDecl& ) = delete;
105  ServiceDecl& operator=( const ServiceDecl& ) = delete;
106  template <typename ImplClassT>
107  ServiceDecl( ImplClassT const& implClass,
108  char const* pImplName,
109  char const* pSupportedServiceNames )
110  : m_createFunc(implClass.m_createFunc),
111  m_pImplName(pImplName),
112  m_pServiceNames(pSupportedServiceNames) {}
113 
115  void * getFactory( char const* pImplName ) const;
116 
118  css::uno::Sequence< OUString> getSupportedServiceNames() const;
119 
121  bool supportsService( OUString const& name ) const;
122 
124  OUString getImplementationName() const;
125 
126 private:
127  class Factory;
128  friend class Factory;
129 
131  char const* const m_pImplName;
132  char const* const m_pServiceNames;
133 };
134 
138 template <bool> struct with_args;
139 
141 namespace detail {
142 
143 } // namespace detail
144 
145 
147 void* component_getFactoryHelper( const char* pImplName,
148  std::initializer_list<ServiceDecl const *> args );
149 
150 } // namespace comphelper::service_decl
151 
152 
153 #endif // ! defined( INCLUDED_COMPHELPER_SERVICEDECL_HXX)
154 
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
detail::CreateFuncF const m_createFunc
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
Class to declare a service implementation.
Definition: servicedecl.hxx:94
::std::function< css::uno::Reference< css::uno::XInterface >(ServiceDecl const &, css::uno::Sequence< css::uno::Any > const &, css::uno::Reference< css::uno::XComponentContext > const &)> CreateFuncF
Definition: servicedecl.hxx:38
To specify whether the implementation class expects arguments (uno::Sequence).
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
ServiceDecl(ImplClassT const &implClass, char const *pImplName, char const *pSupportedServiceNames)
void * component_getFactoryHelper(const char *pImplName, std::initializer_list< ServiceDecl const * > args)
#define COMPHELPER_DLLPUBLIC