DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
capi_pluginservice.cpp
Go to the documentation of this file.
1 #include "capi_pluginservice.h"
2 
3 #define GAUDI_PLUGIN_SERVICE_V2
5 
6 #include <algorithm>
7 #include <vector>
8 
9 #include <iostream>
10 
11 using namespace Gaudi::PluginService::v2::Details;
12 
14  static Registry& cxxreg = Registry::instance();
15  return {&cxxreg};
16 }
17 
19  const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
20  return int( fmap.size() );
21 }
22 
24  const Registry* reg = static_cast<const Registry*>( self.registry );
25  const auto& factories = reg->factories();
26  if ( n >= static_cast<int>( factories.size() ) ) return {self, nullptr};
27  return {self, next( begin( factories ), n )->first.c_str()};
28 }
29 
31  Registry& reg = Registry::instance();
32  return reg.getInfo( self.id ).library.c_str();
33 }
34 
36  Registry& reg = Registry::instance();
37  static std::string cache;
38  cache = demangle( reg.getInfo( self.id ).factory.type() );
39  return cache.c_str();
40 }
41 
43  Registry& reg = Registry::instance();
44  static std::string cache;
45  cache = reg.getInfo( self.id ).getprop( "ClassName" );
46  return cache.c_str();
47 }
48 
50  Registry& reg = Registry::instance();
51  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
52  return int( fi.properties.size() );
53 }
54 
56  cgaudi_property_t cprop{self.registry, self.id, nullptr};
57  Registry& reg = Registry::instance();
58  const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
59  if ( n < static_cast<int>( fi.properties.size() ) ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
60  return cprop;
61 }
62 
63 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
64 
66  Registry& reg = Registry::instance();
67  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
68  auto prop = fi.properties.find( self.key );
69  return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
70 }
cgaudi_pluginsvc_t
Definition: capi_pluginservice.h:38
cgaudi_property_get_key
const char * cgaudi_property_get_key(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:63
Gaudi::PluginService::v2::Details::demangle
std::string demangle(const std::string &id)
Definition: PluginServiceV2.cpp:101
cgaudi_pluginsvc_instance
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
Definition: capi_pluginservice.cpp:13
capi_pluginservice.h
cgaudi_pluginsvc_get_factory_size
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
Definition: capi_pluginservice.cpp:18
cgaudi_property_get_value
const char * cgaudi_property_get_value(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:65
cgaudi_factory_get_property_at
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
Definition: capi_pluginservice.cpp:55
PluginService.h
cgaudi_factory_t
Definition: capi_pluginservice.h:42
Gaudi::PluginService::v2::Details
Definition: PluginServiceV2.cpp:100
cgaudi_property_t
Definition: capi_pluginservice.h:47
cgaudi_pluginsvc_get_factory_at
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
Definition: capi_pluginservice.cpp:23
cgaudi_factory_get_classname
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:42
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
cgaudi_factory_get_property_size
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:49
cgaudi_factory_get_library
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:30
cgaudi_factory_get_type
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:35
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:48