The Gaudi Framework  v30r3 (a5ef0a68)
capi_pluginservice.cpp
Go to the documentation of this file.
1 #include "capi_pluginservice.h"
2 
3 #define GAUDI_PLUGIN_SERVICE_V2
4 #include <Gaudi/PluginService.h>
5 
6 #include <algorithm>
7 #include <vector>
8 
9 #include <iostream>
10 
11 using namespace Gaudi::PluginService::v2::Details;
12 
14 {
15  static Registry& cxxreg = Registry::instance();
16  return {&cxxreg};
17 }
18 
20 {
21  const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
22  return int( fmap.size() );
23 }
24 
26 {
27  const Registry* reg = static_cast<const Registry*>( self.registry );
28  const auto& factories = reg->factories();
29  if ( n >= static_cast<int>( factories.size() ) ) return {self, nullptr};
30  return {self, next( begin( factories ), n )->first.c_str()};
31 }
32 
34 {
35  Registry& reg = Registry::instance();
36  return reg.getInfo( self.id ).library.c_str();
37 }
38 
40 {
41  Registry& reg = Registry::instance();
42  static std::string cache;
43  cache = demangle( reg.getInfo( self.id ).factory.type() );
44  return cache.c_str();
45 }
46 
48 {
49  Registry& reg = Registry::instance();
50  static std::string cache;
51  cache = reg.getInfo( self.id ).getprop( "ClassName" );
52  return cache.c_str();
53 }
54 
56 {
57  Registry& reg = Registry::instance();
58  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
59  return int( fi.properties.size() );
60 }
61 
63 {
64  cgaudi_property_t cprop{self.registry, self.id, nullptr};
65  Registry& reg = Registry::instance();
66  const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
67  if ( n < static_cast<int>( fi.properties.size() ) ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
68  return cprop;
69 }
70 
71 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
72 
74 {
75  Registry& reg = Registry::instance();
76  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
77  auto prop = fi.properties.find( self.key );
78  return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
79 }
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
STL class.
const char * cgaudi_property_get_value(cgaudi_property_t self)
const char * cgaudi_property_get_key(cgaudi_property_t self)
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
cgaudi_pluginsvc_t registry
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
T c_str(T...args)
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
std::string demangle(const std::string &id)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
const char * cgaudi_factory_get_library(cgaudi_factory_t self)