The Gaudi Framework  master (37c0b60a)
capi_pluginservice.cpp File Reference
#include "capi_pluginservice.h"
#include <Gaudi/PluginService.h>
#include <algorithm>
#include <vector>
#include <iostream>
Include dependency graph for capi_pluginservice.cpp:

Go to the source code of this file.

Macros

#define GAUDI_PLUGIN_SERVICE_V2
 

Functions

cgaudi_pluginsvc_t cgaudi_pluginsvc_instance ()
 
int cgaudi_pluginsvc_get_factory_size (cgaudi_pluginsvc_t self)
 
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at (cgaudi_pluginsvc_t self, int n)
 
const char * cgaudi_factory_get_library (cgaudi_factory_t self)
 
const char * cgaudi_factory_get_type (cgaudi_factory_t self)
 
const char * cgaudi_factory_get_classname (cgaudi_factory_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)
 
const char * cgaudi_property_get_key (cgaudi_property_t self)
 
const char * cgaudi_property_get_value (cgaudi_property_t self)
 

Macro Definition Documentation

◆ GAUDI_PLUGIN_SERVICE_V2

#define GAUDI_PLUGIN_SERVICE_V2

Definition at line 14 of file capi_pluginservice.cpp.

Function Documentation

◆ cgaudi_factory_get_classname()

const char* cgaudi_factory_get_classname ( cgaudi_factory_t  self)

Definition at line 52 of file capi_pluginservice.cpp.

52  {
53  Registry& reg = Registry::instance();
54  static std::string cache;
55  cache = reg.getInfo( self.id ).getprop( "ClassName" );
56  return cache.c_str();
57 }

◆ cgaudi_factory_get_library()

const char* cgaudi_factory_get_library ( cgaudi_factory_t  self)

Definition at line 40 of file capi_pluginservice.cpp.

40  {
41  Registry& reg = Registry::instance();
42  return reg.getInfo( self.id ).library.c_str();
43 }

◆ cgaudi_factory_get_property_at()

cgaudi_property_t cgaudi_factory_get_property_at ( cgaudi_factory_t  self,
int  n 
)

Definition at line 65 of file capi_pluginservice.cpp.

65  {
66  cgaudi_property_t cprop{ self.registry, self.id, nullptr };
67  Registry& reg = Registry::instance();
68  const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
69  if ( n < static_cast<int>( fi.properties.size() ) ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
70  return cprop;
71 }

◆ cgaudi_factory_get_property_size()

int cgaudi_factory_get_property_size ( cgaudi_factory_t  self)

Definition at line 59 of file capi_pluginservice.cpp.

59  {
60  Registry& reg = Registry::instance();
61  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
62  return int( fi.properties.size() );
63 }

◆ cgaudi_factory_get_type()

const char* cgaudi_factory_get_type ( cgaudi_factory_t  self)

Definition at line 45 of file capi_pluginservice.cpp.

45  {
46  Registry& reg = Registry::instance();
47  static std::string cache;
48  cache = demangle( reg.getInfo( self.id ).factory.type() );
49  return cache.c_str();
50 }

◆ cgaudi_pluginsvc_get_factory_at()

cgaudi_factory_t cgaudi_pluginsvc_get_factory_at ( cgaudi_pluginsvc_t  self,
int  n 
)

Definition at line 33 of file capi_pluginservice.cpp.

33  {
34  const Registry* reg = static_cast<const Registry*>( self.registry );
35  const auto& factories = reg->factories();
36  if ( n >= static_cast<int>( factories.size() ) ) return { self, nullptr };
37  return { self, next( begin( factories ), n )->first.c_str() };
38 }

◆ cgaudi_pluginsvc_get_factory_size()

int cgaudi_pluginsvc_get_factory_size ( cgaudi_pluginsvc_t  self)

Definition at line 28 of file capi_pluginservice.cpp.

28  {
29  const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
30  return int( fmap.size() );
31 }

◆ cgaudi_pluginsvc_instance()

cgaudi_pluginsvc_t cgaudi_pluginsvc_instance ( )

Definition at line 23 of file capi_pluginservice.cpp.

23  {
24  static Registry& cxxreg = Registry::instance();
25  return { &cxxreg };
26 }

◆ cgaudi_property_get_key()

const char* cgaudi_property_get_key ( cgaudi_property_t  self)

Definition at line 73 of file capi_pluginservice.cpp.

73 { return self.key; }

◆ cgaudi_property_get_value()

const char* cgaudi_property_get_value ( cgaudi_property_t  self)

Definition at line 75 of file capi_pluginservice.cpp.

75  {
76  Registry& reg = Registry::instance();
77  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
78  auto prop = fi.properties.find( self.key );
79  return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
80 }
std::string
STL class.
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
std::string::c_str
T c_str(T... args)
cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:93
cgaudi_property_t
Definition: capi_pluginservice.h:45
cpluginsvc.n
n
Definition: cpluginsvc.py:234
Gaudi::PluginService::v1::Details::demangle
GAUDIPS_API std::string demangle(const std::type_info &id)
Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).
Definition: PluginServiceV1.cpp:131
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:46
ProduceConsume.key
key
Definition: ProduceConsume.py:84
std::next
T next(T... args)