| The Gaudi Framework v29r0 (ff2e7097)

- 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 <Gaudi/Details/PluginServiceDetails.h>
18 #include <string>
19 #include <typeinfo>
20 #include <utility>
21
22 #define DECLARE_FACTORY_WITH_ID( type, id, factory ) _INTERNAL_DECLARE_FACTORY( type, id, factory, __LINE__ )
23
24 #define DECLARE_FACTORY( type, factory ) \
25 DECLARE_FACTORY_WITH_ID( type, ::Gaudi::PluginService::Details::demangle<type>(), factory )
26
27 #define DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory ) \
28 _INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, id, factory, __LINE__ )
29
30 #define DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory ) \
31 DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, ::Gaudi::PluginService::Details::demangle<type>(), factory )
32
33 #define DECLARE_COMPONENT( type ) DECLARE_FACTORY( type, type::Factory )
34
35 #define DECLARE_COMPONENT_WITH_ID( type, id ) DECLARE_FACTORY_WITH_ID( type, id, type::Factory )
36
37 namespace Gaudi
38 {
39 namespace PluginService
40 {
41
42 #if !defined( __REFLEX__ ) || defined( ATLAS )
43 template <typename R, typename... Args>
45 class Factory
46 {
47 public:
48 typedef R ReturnType;
49 typedef R ( *FuncType )( Args&&... );
50
51 static ReturnType create( const std::string& id, Args... args )
52 {
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 {
60 std::ostringstream o;
61 o << id;
62 return create( o.str(), std::forward<Args>( args )... );
63 }
64 };
65 #endif
66
67 class GAUDIPS_EXPORT Exception : public std::exception
68 {
69 public:
70 Exception( std::string msg );
71 ~Exception() throw() override;
72 const char* what() const throw() override;
73
74 private:
75 std::string m_msg;
76 };
77 }
78 }
79
80 #endif //_GAUDI_PLUGIN_SERVICE_H_
Gaudi::PluginService::Factory::create
static ReturnType create(const T &id, Args...args)
Definition: PluginService.h:58
Gaudi::PluginService::Factory::create
static ReturnType create(const std::string &id, Args...args)
Definition: PluginService.h:51
Gaudi::PluginService::Factory::ReturnType
R ReturnType
Definition: PluginService.h:48
PluginServiceDetails.h
gaudirun.c
c
Definition: gaudirun.py:407
gaudirun.args
args
Definition: gaudirun.py:244
Gaudi::PluginService::Exception::m_msg
std::string m_msg
Definition: PluginService.h:75
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:67
Gaudi::PluginService::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:45
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Gaudi::PluginService::Factory::FuncType
R(* FuncType)(Args &&...)
Definition: PluginService.h:49
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1