Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PluginServiceV1.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 2013-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
15 
17 #include <string>
18 #include <typeinfo>
19 #include <utility>
20 
21 #define _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, factory ) \
22  _PS_V1_INTERNAL_DECLARE_FACTORY( type, id, factory, __LINE__ )
23 
24 #define _PS_V1_DECLARE_FACTORY( type, factory ) \
25  _PS_V1_DECLARE_FACTORY_WITH_ID( type, ::Gaudi::PluginService::v1::Details::demangle<type>(), factory )
26 
27 #define _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory ) \
28  _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, id, factory, __LINE__ )
29 
30 #define _PS_V1_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory ) \
31  _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, \
32  ::Gaudi::PluginService::v1::Details::demangle<type>(), factory )
33 
34 #define _PS_V1_DECLARE_COMPONENT( type ) _PS_V1_DECLARE_FACTORY( type, type::Factory )
35 
36 #define _PS_V1_DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, type::Factory )
37 
38 #if !GAUDI_PLUGIN_SERVICE_USE_V2
39 # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, factory )
40 # define DECLARE_FACTORY( type, factory ) _PS_V1_DECLARE_FACTORY( type, factory )
41 # define DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory ) \
42  _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory )
43 # define DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory ) \
44  _PS_V1_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory )
45 # define DECLARE_COMPONENT( type ) _PS_V1_DECLARE_COMPONENT( type )
46 # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V1_DECLARE_COMPONENT_WITH_ID( type, id )
47 #endif
48 
49 namespace Gaudi {
50  namespace PluginService {
53  template <typename R, typename... Args>
54  class Factory {
55  public:
56  typedef R ReturnType;
57  typedef R ( *FuncType )( Args&&... );
58 
59  static ReturnType create( const std::string& id, Args... args ) {
60  const FuncType c = Details::getCreator<FuncType>( id );
61  return c ? ( *c )( std::forward<Args>( args )... ) : 0;
62  }
63 
64  template <typename T>
65  static ReturnType create( const T& id, Args... args ) {
66  std::ostringstream o;
67  o << id;
68  return create( o.str(), std::forward<Args>( args )... );
69  }
70  };
71 
72  class GAUDIPS_EXPORT Exception : public std::exception {
73  public:
74  Exception( std::string msg );
75  ~Exception() throw() override;
76  const char* what() const throw() override;
77 
78  private:
79  std::string m_msg;
80  };
81  }
82  } // namespace PluginService
83 } // namespace Gaudi
PluginServiceDetailsV1.h
Gaudi::PluginService::v1::Factory::create
static ReturnType create(const std::string &id, Args... args)
Definition: PluginServiceV1.h:59
GaudiPartProp.tests.v1
v1
Definition: tests.py:39
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
gaudirun.c
c
Definition: gaudirun.py:525
GaudiPartProp.tests.id
id
Definition: tests.py:111
Gaudi::PluginService::v1::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginServiceV1.h:54
GAUDIPS_EXPORT
#define GAUDIPS_EXPORT
Definition: PluginServiceCommon.h:31
Gaudi::PluginService::v1::Factory::ReturnType
R ReturnType
Definition: PluginServiceV1.h:56
Gaudi::PluginService::v1::Exception
Definition: PluginServiceV1.h:72
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
GAUDI_PLUGIN_SERVICE_V1_INLINE
#define GAUDI_PLUGIN_SERVICE_V1_INLINE
Definition: PluginServiceCommon.h:18
gaudirun.args
args
Definition: gaudirun.py:336
Gaudi::PluginService::v1::Exception::m_msg
std::string m_msg
Definition: PluginServiceV1.h:79
Gaudi::PluginService::v1::Factory::FuncType
R(* FuncType)(Args &&...)
Definition: PluginServiceV1.h:57
Gaudi::PluginService::v1::Factory::create
static ReturnType create(const T &id, Args... args)
Definition: PluginServiceV1.h:65