11 #ifndef _GAUDI_PLUGIN_SERVICE_V2_H_ 
   12 #define _GAUDI_PLUGIN_SERVICE_V2_H_ 
   22 #include <string_view> 
   23 #include <type_traits> 
   27 #if __cplusplus > 201703L && __has_include( <source_location> ) 
   28 #  include <source_location> 
   29 namespace Gaudi::PluginService::Details {
 
   30   using std::source_location;
 
   32 #elif __cplusplus >= 201402L 
   33 #  include <experimental/source_location> 
   34 namespace Gaudi::PluginService::Details {
 
   35   using std::experimental::source_location;
 
   41   namespace PluginService {
 
   43       using Gaudi::PluginService::Details::source_location;
 
   51       template <
typename R, 
typename... Args>
 
   52       struct Factory<R( Args... )> {
 
   53         using Traits          = Details::Traits<R( Args... )>;
 
   62             return Details::Registry::instance().get<
FactoryType>( Details::stringify_id( 
id ) )(
 
   63                 std::forward<Args>( 
args )... );
 
   64           } 
catch ( std::bad_any_cast& ) {
 
  100       template <
typename T, 
typename F = 
typename T::Factory>
 
  105                         source_location src_loc = source_location::current() )
 
  109                         Details::Registry::Properties    
props   = {},
 
  110                         [[maybe_unused]] source_location src_loc = source_location::current() ) {
 
  111           using Details::Registry;
 
  113           if ( 
props.find( 
"ClassName" ) == 
end( 
props ) ) 
props.emplace( 
"ClassName", Details::demangle<T>() );
 
  115           std::string_view fn  = src_loc.file_name();
 
  116           auto             pos = fn.rfind( 
'/' );
 
  117           if ( pos != std::string_view::npos ) { fn.remove_prefix( pos + 1 ); }
 
  119           s << fn << 
':' << src_loc.line();
 
  120           props[
"declaration_location"] = 
s.str();
 
  124         DeclareFactory( Details::Registry::Properties 
props, source_location src_loc = source_location::current() )
 
  135 #define _PS_V2_DECLARE_COMPONENT( type )                                                                               \ 
  137     ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{};                         \ 
  140 #define _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id )                                                                   \ 
  142     ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{                           \ 
  143         ::Gaudi::PluginService::v2::Details::stringify_id( id ) };                                                     \ 
  146 #define _PS_V2_DECLARE_FACTORY( type, factory )                                                                        \ 
  148     ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{};                \ 
  151 #define _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory )                                                            \ 
  153     ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{                  \ 
  154         ::Gaudi::PluginService::v2::Details::stringify_id( id ) };                                                     \ 
  157 #if GAUDI_PLUGIN_SERVICE_USE_V2 
  158 #  define DECLARE_COMPONENT( type ) _PS_V2_DECLARE_COMPONENT( type ) 
  159 #  define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id ) 
  160 #  define DECLARE_FACTORY( type, factory ) _PS_V2_DECLARE_FACTORY( type, factory ) 
  161 #  define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory ) 
  164 #endif //_GAUDI_PLUGIN_SERVICE_H_