| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
20 #include <Gaudi/Details/PluginServiceDetails.h>
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
65 class GAUDIPS_EXPORT Exception: public std::exception {
66 public:
67 Exception(std::string msg);
68 ~Exception() throw() override;
69 const char* what() const throw() override;
70 private:
71 std::string m_msg;
72 };
73 }}
74
75 #endif //_GAUDI_PLUGIN_SERVICE_H_
Gaudi::PluginService::Factory::create
static ReturnType create(const T &id, Args...args)
Definition: PluginService.h:58
Gaudi::PluginService::Factory::FuncType
R(* FuncType)(Args &&...)
Definition: PluginService.h:50
Gaudi::PluginService::Factory::create
static ReturnType create(const std::string &id, Args...args)
Definition: PluginService.h:52
Gaudi::PluginService::Factory::ReturnType
R ReturnType
Definition: PluginService.h:49
PluginServiceDetails.h
gaudirun.c
c
Definition: gaudirun.py:391
gaudirun.args
args
Definition: gaudirun.py:236
Gaudi::PluginService::Exception::m_msg
std::string m_msg
Definition: PluginService.h:71
GAUDIPS_EXPORT
#define GAUDIPS_EXPORT
Definition: PluginServiceDetails.h:37
std::string
STL class.
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
std::exception
STL class.
Gaudi::PluginService::Exception
Definition: PluginService.h:65
Gaudi::PluginService::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1