Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:18:08

0001 #include "capi_pluginservice.h"
0002 
0003 #define GAUDI_PLUGIN_SERVICE_V2
0004 #include <Gaudi/PluginService.h>
0005 
0006 #include <algorithm>
0007 #include <vector>
0008 
0009 #include <iostream>
0010 
0011 using namespace Gaudi::PluginService::v2::Details;
0012 
0013 cgaudi_pluginsvc_t cgaudi_pluginsvc_instance() {
0014   static Registry& cxxreg = Registry::instance();
0015   return {&cxxreg};
0016 }
0017 
0018 int cgaudi_pluginsvc_get_factory_size( cgaudi_pluginsvc_t self ) {
0019   const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
0020   return int( fmap.size() );
0021 }
0022 
0023 cgaudi_factory_t cgaudi_pluginsvc_get_factory_at( cgaudi_pluginsvc_t self, int n ) {
0024   const Registry* reg       = static_cast<const Registry*>( self.registry );
0025   const auto&     factories = reg->factories();
0026   if ( n >= static_cast<int>( factories.size() ) ) return {self, nullptr};
0027   return {self, next( begin( factories ), n )->first.c_str()};
0028 }
0029 
0030 const char* cgaudi_factory_get_library( cgaudi_factory_t self ) {
0031   Registry& reg = Registry::instance();
0032   return reg.getInfo( self.id ).library.c_str();
0033 }
0034 
0035 const char* cgaudi_factory_get_type( cgaudi_factory_t self ) {
0036   Registry&          reg = Registry::instance();
0037   static std::string cache;
0038   cache = demangle( reg.getInfo( self.id ).factory.type() );
0039   return cache.c_str();
0040 }
0041 
0042 const char* cgaudi_factory_get_classname( cgaudi_factory_t self ) {
0043   Registry&          reg = Registry::instance();
0044   static std::string cache;
0045   cache = reg.getInfo( self.id ).getprop( "ClassName" );
0046   return cache.c_str();
0047 }
0048 
0049 int cgaudi_factory_get_property_size( cgaudi_factory_t self ) {
0050   Registry&                    reg = Registry::instance();
0051   const Registry::FactoryInfo& fi  = reg.getInfo( self.id );
0052   return int( fi.properties.size() );
0053 }
0054 
0055 cgaudi_property_t cgaudi_factory_get_property_at( cgaudi_factory_t self, int n ) {
0056   cgaudi_property_t            cprop{self.registry, self.id, nullptr};
0057   Registry&                    reg = Registry::instance();
0058   const Registry::FactoryInfo& fi  = reg.getInfo( cprop.id );
0059   if ( n < static_cast<int>( fi.properties.size() ) ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
0060   return cprop;
0061 }
0062 
0063 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
0064 
0065 const char* cgaudi_property_get_value( cgaudi_property_t self ) {
0066   Registry&                    reg  = Registry::instance();
0067   const Registry::FactoryInfo& fi   = reg.getInfo( self.id );
0068   auto                         prop = fi.properties.find( self.key );
0069   return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
0070 }