File indexing completed on 2025-01-30 09:18:08
0001 #ifndef GAUDIPLUGINSERVICE_GAUDI_PLUGINSERVICEV1_H
0002 #define GAUDIPLUGINSERVICE_GAUDI_PLUGINSERVICEV1_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <Gaudi/Details/PluginServiceDetailsV1.h>
0018 #include <string>
0019 #include <typeinfo>
0020 #include <utility>
0021
0022 #define _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, factory ) \
0023 _PS_V1_INTERNAL_DECLARE_FACTORY( type, id, factory, __LINE__ )
0024
0025 #define _PS_V1_DECLARE_FACTORY( type, factory ) \
0026 _PS_V1_DECLARE_FACTORY_WITH_ID( type, ::Gaudi::PluginService::v1::Details::demangle<type>(), factory )
0027
0028 #define _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory ) \
0029 _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, id, factory, __LINE__ )
0030
0031 #define _PS_V1_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory ) \
0032 _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, \
0033 ::Gaudi::PluginService::v1::Details::demangle<type>(), factory )
0034
0035 #define _PS_V1_DECLARE_COMPONENT( type ) _PS_V1_DECLARE_FACTORY( type, type::Factory )
0036
0037 #define _PS_V1_DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, type::Factory )
0038
0039 #if !GAUDI_PLUGIN_SERVICE_USE_V2
0040 # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V1_DECLARE_FACTORY_WITH_ID( type, id, factory )
0041 # define DECLARE_FACTORY( type, factory ) _PS_V1_DECLARE_FACTORY( type, factory )
0042 # define DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory ) \
0043 _PS_V1_DECLARE_FACTORY_WITH_CREATOR_AND_ID( type, typecreator, id, factory )
0044 # define DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory ) \
0045 _PS_V1_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, factory )
0046 # define DECLARE_COMPONENT( type ) _PS_V1_DECLARE_COMPONENT( type )
0047 # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V1_DECLARE_COMPONENT_WITH_ID( type, id )
0048 #endif
0049
0050 namespace Gaudi {
0051 namespace PluginService {
0052 GAUDI_PLUGIN_SERVICE_V1_INLINE namespace v1 {
0053
0054 template <typename R, typename... Args>
0055 class Factory {
0056 public:
0057 typedef R ReturnType;
0058 typedef R ( *FuncType )( Args&&... );
0059
0060 static ReturnType create( const std::string& id, Args... args ) {
0061 const FuncType c = Details::getCreator<FuncType>( id );
0062 return c ? ( *c )( std::forward<Args>( args )... ) : 0;
0063 }
0064
0065 template <typename T>
0066 static ReturnType create( const T& id, Args... args ) {
0067 std::ostringstream o;
0068 o << id;
0069 return create( o.str(), std::forward<Args>( args )... );
0070 }
0071 };
0072
0073 class GAUDIPS_EXPORT Exception : public std::exception {
0074 public:
0075 Exception( std::string msg );
0076 ~Exception() throw() override;
0077 const char* what() const throw() override;
0078
0079 private:
0080 std::string m_msg;
0081 };
0082 }
0083 }
0084 }
0085
0086 #endif