The Gaudi Framework  master (37c0b60a)
capi_pluginservice.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 2013-2019 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
15 
16 #include <algorithm>
17 #include <vector>
18 
19 #include <iostream>
20 
21 using namespace Gaudi::PluginService::v2::Details;
22 
24  static Registry& cxxreg = Registry::instance();
25  return { &cxxreg };
26 }
27 
29  const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
30  return int( fmap.size() );
31 }
32 
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 }
39 
41  Registry& reg = Registry::instance();
42  return reg.getInfo( self.id ).library.c_str();
43 }
44 
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 }
51 
53  Registry& reg = Registry::instance();
54  static std::string cache;
55  cache = reg.getInfo( self.id ).getprop( "ClassName" );
56  return cache.c_str();
57 }
58 
60  Registry& reg = Registry::instance();
61  const Registry::FactoryInfo& fi = reg.getInfo( self.id );
62  return int( fi.properties.size() );
63 }
64 
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 }
72 
73 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
74 
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 }
cgaudi_pluginsvc_t
Definition: capi_pluginservice.h:36
std::string
STL class.
cgaudi_property_get_key
const char * cgaudi_property_get_key(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:73
Gaudi::PluginService::v2::Details
Definition: PluginServiceV2.cpp:94
cgaudi_pluginsvc_instance
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
Definition: capi_pluginservice.cpp:23
capi_pluginservice.h
cgaudi_pluginsvc_get_factory_size
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
Definition: capi_pluginservice.cpp:28
cgaudi_property_get_value
const char * cgaudi_property_get_value(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:75
cgaudi_factory_get_property_at
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
Definition: capi_pluginservice.cpp:65
PluginService.h
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
std::string::c_str
T c_str(T... args)
cgaudi_factory_t
Definition: capi_pluginservice.h:40
cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:93
cgaudi_property_t
Definition: capi_pluginservice.h:45
cgaudi_pluginsvc_get_factory_at
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
Definition: capi_pluginservice.cpp:33
cpluginsvc.n
n
Definition: cpluginsvc.py:234
cgaudi_factory_get_classname
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:52
cgaudi_factory_get_property_size
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:59
cgaudi_factory_get_library
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:40
cgaudi_factory_get_type
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:45
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:46
ProduceConsume.key
key
Definition: ProduceConsume.py:84
Gaudi::PluginService::v2::Details::demangle
std::string demangle(const std::string &id)
Definition: PluginServiceV2.cpp:95