11 #ifndef _GAUDI_PLUGIN_SERVICE_DETAILS_V2_H_
12 #define _GAUDI_PLUGIN_SERVICE_DETAILS_V2_H_
30 namespace PluginService {
42 template <
typename R,
typename... Args>
43 struct Traits<R( Args... )> {
60 template <
typename ID>
112 inline bool is_set()
const {
return factory.has_value(); }
113 Properties::mapped_type getprop(
const Properties::key_type&
name )
const;
120 template <
typename F>
121 F
get(
const KeyType&
id ) {
122 const FactoryInfo& info = Registry::instance().getInfo(
id,
true );
125 const auto& prop = info.properties.find(
"deprecated" );
126 if ( prop != info.properties.end() ) {
127 std::string msg =
"factory '" + info.getprop(
"ClassName" ) +
"' is deprecated" +
128 ( prop->second.empty() ?
"" : (
": " + prop->second ) );
129 if ( m_werror.find(
"deprecated" ) != m_werror.end() ) {
131 return std::any_cast<F>( std::any() );
137 #ifdef GAUDI_REFLEX_COMPONENT_ALIASES
138 if ( !info.getprop(
"ReflexName" ).empty() ) {
139 const std::string real_name = info.getprop(
"ClassName" );
140 logger().warning(
"requesting factory via old name '" +
id +
"' use '" +
141 ( real_name.
empty() ?
"<undefined>" : real_name ) +
"' instead" );
144 return std::any_cast<F>( info.factory );
148 static Registry& instance();
151 FactoryInfo&
add(
const KeyType&
id, FactoryInfo info );
154 FactoryMap::size_type erase(
const KeyType&
id );
157 const FactoryInfo& getInfo(
const KeyType&
id,
const bool load =
false )
const;
160 Registry& addProperty(
const KeyType&
id,
const KeyType& k,
const std::string&
v );
163 void setError(
const KeyType& warning );
166 void unsetError(
const KeyType& warning );
183 Registry(
const Registry& ) =
delete;
196 FactoryMap m_factories;
209 template <
typename,
typename>
210 struct DefaultFactory;
211 template <
typename T,
typename R,
typename... Args>
212 struct DefaultFactory<T, Factory<R( Args... )>> {
213 inline typename Factory<R( Args... )>::ReturnType operator()( Args...
args ) {
232 #define _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME_TOKEN( serial ) _register_##serial
233 #define _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME( serial ) \
234 _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME_TOKEN( serial )
235 #define _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME( __LINE__ )
237 #endif //_GAUDI_PLUGIN_SERVICE_DETAILS_H_