The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
49namespace 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 ) {
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
#define GAUDIPS_EXPORT
#define GAUDI_PLUGIN_SERVICE_V1_INLINE
const char * what() const override
Class wrapping the signature for a factory with any number of arguments.
static ReturnType create(const T &id, Args... args)
static ReturnType create(const std::string &id, Args... args)
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Function used to load a specific factory function.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1