The Gaudi Framework  v29r0 (ff2e7097)
capi_pluginservice.cpp
Go to the documentation of this file.
1 #include "capi_pluginservice.h"
2 #include <Gaudi/PluginService.h>
3 #include <algorithm>
4 #include <vector>
5 
6 #include <iostream>
7 using namespace Gaudi::PluginService::Details;
8 
10 {
11  static Registry& cxxreg = Registry::instance();
12  return {(void*)( &cxxreg )};
13 }
14 
16 {
17  const Registry::FactoryMap& fmap = ( (const Registry*)self.registry )->factories();
18  return int( fmap.size() );
19 }
20 
22 {
23  const Registry* reg = ( (const Registry*)self.registry );
24  const auto& factories = reg->factories();
25  if ( n >= (int)factories.size() ) return {self, nullptr};
26  return {self, next( begin( factories ), n )->first.c_str()};
27 }
28 
30 {
32  return reg.getInfo( self.id ).library.c_str();
33 }
34 
36 {
38  return reg.getInfo( self.id ).type.c_str();
39 }
40 
42 {
44  return reg.getInfo( self.id ).rtype.c_str();
45 }
46 
48 {
50  return reg.getInfo( self.id ).className.c_str();
51 }
52 
54 {
56  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
57  return int( fi.properties.size() );
58 }
59 
61 {
62  cgaudi_property_t cprop{self.registry, self.id, nullptr};
64  const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
65  if ( n < (int)fi.properties.size() ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
66  return cprop;
67 }
68 
69 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
70 
72 {
74  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
75  auto prop = fi.properties.find( self.key );
76  return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
77 }
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
const FactoryInfo & getInfo(const std::string &id) const
Retrieve the FactoryInfo object for an id.
T end(T...args)
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
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)
const char * cgaudi_factory_get_rtype(cgaudi_factory_t self)
const FactoryMap & factories() const
Return the known factories (loading the list if not yet done).
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 find(T...args)
T size(T...args)
T c_str(T...args)
static Registry & instance()
Retrieve the singleton instance of Registry.
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
In-memory database of the loaded factories.
const char * cgaudi_factory_get_library(cgaudi_factory_t self)