Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SvcCatalog.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ===========================================================================
4 // STD & STL:
5 // ===========================================================================
6 #include <iostream>
7 #include <sstream>
8 // ===========================================================================
9 // Boost:
10 // ===========================================================================
11 #include "boost/algorithm/string.hpp"
12 // ===========================================================================
13 // Local
14 // ===========================================================================
15 #include "SvcCatalog.h"
16 // ===========================================================================
17 namespace {
18  constexpr struct select1st_t {
19  template <typename S, typename T>
20  const S& operator()( const std::pair<S, T>& p ) const {
21  return p.first;
22  }
23  template <typename S, typename T>
24  S& operator()( std::pair<S, T>& p ) const {
25  return p.first;
26  }
27  } select1st{};
28 } // namespace
29 // ===========================================================================
31  for ( const auto& cur : m_catalog ) {
32  for ( auto& prop : cur.second ) delete prop;
33  }
34 }
35 // ============================================================================
37  auto props = findProperties( client );
38  if ( props ) {
39  removeProperty( client, property->name() ).ignore();
40  props->push_back( property );
41  } else {
42  m_catalog.emplace( client, PropertiesT{property} );
43  }
44  return StatusCode::SUCCESS;
45 }
46 // ============================================================================
48  auto props = findProperties( client );
49  if ( props ) {
50  auto res = findProperty( *props, name );
51  if ( res.first ) {
52  delete *res.second;
53  props->erase( res.second );
54  }
55  }
56  return StatusCode::SUCCESS;
57 }
58 // ============================================================================
60  return findProperties( client );
61 }
62 // ============================================================================
65  result.reserve( m_catalog.size() );
66  std::transform( std::begin( m_catalog ), std::end( m_catalog ), std::back_inserter( result ), select1st );
67  return result;
68 }
69 // ============================================================================
71  auto result = m_catalog.find( client );
72  return ( result != m_catalog.end() ) ? &result->second : nullptr;
73 }
74 // ============================================================================
76  auto result = m_catalog.find( client );
77  return ( result != m_catalog.end() ) ? &result->second : nullptr;
78 }
79 // ============================================================================
81  const std::string& name ) const {
82  auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) {
83  return boost::iequals( name, prop->name() );
84  } );
85  return {p != std::end( props ), p};
86 }
87 // ============================================================================
89  const std::string& name ) {
90  auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) {
91  return boost::iequals( name, prop->name() );
92  } );
93  return {p != std::end( props ), p};
94 }
95 // ============================================================================
97  // loop over the clients:
98  for ( const auto& iclient : m_catalog ) {
99  o << "Client '" << iclient.first << "'" << std::endl;
100  for ( const auto& p : iclient.second ) {
101  if ( p ) o << "\t" << ( *p ) << std::endl;
102  }
103  }
104  //
105  return o; // RETURN
106 }
108  const std::string& name ) const {
109  auto props = findProperties( client );
110  if ( props ) {
111  const auto res = findProperty( *props, name );
112  if ( res.first ) { return *res.second; }
113  }
114  return nullptr;
115 }
116 // ============================================================================
117 // printoput operator
118 // ============================================================================
119 std::ostream& operator<<( std::ostream& o, const SvcCatalog& c ) { return c.fillStream( o ); }
120 // ============================================================================
121 // The END
122 // ============================================================================
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:59
std::ostream & fillStream(std::ostream &o) const
dump the content of catalog to std::ostream
Definition: SvcCatalog.cpp:96
const std::string name() const
property name
Definition: Property.h:36
T endl(T...args)
Gaudi::Details::PropertyBase * property(const std::string &name) const
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
StatusCode addProperty(const std::string &client, const Gaudi::Details::PropertyBase *property)
Definition: SvcCatalog.cpp:36
std::ostream & operator<<(std::ostream &o, const SvcCatalog &c)
printoput operator
Definition: SvcCatalog.cpp:119
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:47
std::vector< std::string > getClients() const
Definition: SvcCatalog.cpp:63
STL class.
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:70
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::pair< bool, PropertiesT::const_iterator > findProperty(const PropertiesT &props, const std::string &name) const
Definition: SvcCatalog.cpp:80
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
const Gaudi::Details::PropertyBase * getProperty(const std::string &client, const std::string &name) const
Definition: SvcCatalog.cpp:107
T find_if(T...args)
STL class.
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
T begin(T...args)
T back_inserter(T...args)
T transform(T...args)
STL class.
T reserve(T...args)