All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PluginService.h
Go to the documentation of this file.
1 #ifndef _GAUDI_PLUGIN_SERVICE_H_
2 #define _GAUDI_PLUGIN_SERVICE_H_
3 /*****************************************************************************\
4 * (c) Copyright 2013 CERN *
5 * *
6 * This software is distributed under the terms of the GNU General Public *
7 * Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE". *
8 * *
9 * In applying this licence, CERN does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 \*****************************************************************************/
13 
16 
17 #include <string>
18 #include <typeinfo>
19 #include <utility>
21 
22 #define DECLARE_FACTORY_WITH_ID(type, id, factory) \
23  _INTERNAL_DECLARE_FACTORY(type, id, factory, __LINE__)
24 
25 #define DECLARE_FACTORY(type, factory) \
26  DECLARE_FACTORY_WITH_ID(type, \
27  ::Gaudi::PluginService::Details::demangle<type>(), factory)
28 
29 #define DECLARE_FACTORY_WITH_CREATOR_AND_ID(type, typecreator, id, factory) \
30  _INTERNAL_DECLARE_FACTORY_WITH_CREATOR(type, typecreator, id, factory, __LINE__)
31 
32 #define DECLARE_FACTORY_WITH_CREATOR(type, typecreator, factory) \
33  DECLARE_FACTORY_WITH_CREATOR_AND_ID(type, typecreator, \
34  ::Gaudi::PluginService::Details::demangle<type>(), factory)
35 
36 #define DECLARE_COMPONENT(type) \
37  DECLARE_FACTORY(type, type::Factory)
38 
39 #define DECLARE_COMPONENT_WITH_ID(type, id) \
40  DECLARE_FACTORY_WITH_ID(type, id, type::Factory)
41 
42 namespace Gaudi { namespace PluginService {
43 
44 #if !defined(__REFLEX__) || defined(ATLAS)
45  template <typename R, typename... Args>
47  class Factory {
48  public:
49  typedef R ReturnType;
50  typedef R (*FuncType)(Args&&...);
51 
52  static ReturnType create(const std::string& id, Args... args) {
53  const FuncType c = Details::getCreator<FuncType>(id);
54  return c ? (*c)(std::forward<Args>(args)...) : 0;
55  }
56 
57  template <typename T>
58  static ReturnType create(const T& id, Args... args) {
59  std::ostringstream o; o << id;
60  return create(o.str(), std::forward<Args>(args)...);
61  }
62  };
63 #endif
64 
66  public:
68  ~Exception() throw() override;
69  const char* what() const throw() override;
70  private:
72  };
73 }}
74 
75 #endif //_GAUDI_PLUGIN_SERVICE_H_
static ReturnType create(const T &id, Args...args)
Definition: PluginService.h:58
static ReturnType create(const std::string &id, Args...args)
Definition: PluginService.h:52
#define GAUDIPS_EXPORT
STL class.
STL class.
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
Helper functions to set/get the application return code.
Definition: __init__.py:1