The Gaudi Framework  master (fb3055f7)
Loading...
Searching...
No Matches
capi_pluginservice.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 2013-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#include "capi_pluginservice.h"
12
13#define GAUDI_PLUGIN_SERVICE_V2
14#include <Gaudi/PluginService.h>
15
16#include <sstream>
17#include <vector>
18
20
22 static Registry& cxxreg = Registry::instance();
23 return { &cxxreg };
24}
25
27 const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
28 return int( fmap.size() );
29}
30
32 const Registry* reg = static_cast<const Registry*>( self.registry );
33 const auto& factories = reg->factories();
34 if ( n >= static_cast<int>( factories.size() ) ) return { self, nullptr };
35 return { self, next( begin( factories ), n )->first.c_str() };
36}
37
39 Registry& reg = Registry::instance();
40 return reg.getInfo( self.id ).library.c_str();
41}
42
44 Registry& reg = Registry::instance();
45 static std::string cache;
46 cache = demangle( reg.getInfo( self.id ).factory.type() );
47 return cache.c_str();
48}
49
51 Registry& reg = Registry::instance();
52 static std::string cache;
53 cache = reg.getInfo( self.id ).getprop( "ClassName" );
54 return cache.c_str();
55}
56
58 Registry& reg = Registry::instance();
59 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
60 return int( fi.properties.size() );
61}
62
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
71const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
72
74 Registry& reg = Registry::instance();
75 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
76 auto prop = fi.properties.find( self.key );
77 return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
78}
79
81 static std::string cache = [] {
82 std::ostringstream oss;
83 const auto& paths = Gaudi::PluginService::Details::getPluginSearchPath();
84 for ( auto it = paths.begin(); it != paths.end(); ++it ) {
85 if ( it != paths.begin() ) {
86#ifdef _WIN32
87 oss << ';';
88#else
89 oss << ':';
90#endif
91 }
92 oss << *it;
93 }
94 return oss.str();
95 }();
96 return cache.c_str();
97}
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
const char * cgaudi_property_get_key(cgaudi_property_t self)
const char * cgaudi_pluginsvc_plugin_search_path()
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
const char * cgaudi_property_get_value(cgaudi_property_t self)
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
std::string demangle(const std::string &id)