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 <cppuhelper/implbase.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 
27 #include <functional>
28 #include <initializer_list>
29 
30 namespace comphelper::service_decl {
31 
32 class ServiceDecl;
33 
34 namespace detail {
35 typedef ::std::function<
36  css::uno::Reference<css::uno::XInterface> /* return */
37  (ServiceDecl const&,
38  css::uno::Sequence<css::uno::Any> const&,
39  css::uno::Reference<css::uno::XComponentContext> const&)> CreateFuncF;
40 }
41 
96 {
97 public:
105  ServiceDecl( const ServiceDecl& ) = delete;
106  ServiceDecl& operator=( const ServiceDecl& ) = delete;
107  template <typename ImplClassT>
108  ServiceDecl( ImplClassT const& implClass,
109  char const* pImplName,
110  char const* pSupportedServiceNames )
111  : m_createFunc(implClass.m_createFunc),
112  m_pImplName(pImplName),
113  m_pServiceNames(pSupportedServiceNames) {}
114 
116  void * getFactory( char const* pImplName ) const;
117 
119  css::uno::Sequence< OUString> getSupportedServiceNames() const;
120 
122  bool supportsService( OUString const& name ) const;
123 
125  OUString getImplementationName() const;
126 
127 private:
128  class Factory;
129  friend class Factory;
130 
132  char const* const m_pImplName;
133  char const* const m_pServiceNames;
134 };
135 
139 template <bool> struct with_args;
140 
142 namespace detail {
143 
144 } // namespace detail
145 
146 
148 void* component_getFactoryHelper( const char* pImplName,
149  std::initializer_list<ServiceDecl const *> args );
150 
151 } // namespace comphelper::service_decl
152 
153 
154 #endif // ! defined( INCLUDED_COMPHELPER_SERVICEDECL_HXX)
155 
156 /* 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:95
::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:39
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