The Gaudi Framework  v33r0 (d5ea422b)
SvcCatalog Class Referencefinal

#include <src/JobOptionsSvc/SvcCatalog.h>

Collaboration diagram for SvcCatalog:

Public Types

typedef std::vector< const Gaudi::Details::PropertyBase * > PropertiesT
 

Public Member Functions

 SvcCatalog ()=default
 
 ~SvcCatalog ()
 
StatusCode addProperty (const std::string &client, const Gaudi::Details::PropertyBase *property)
 
StatusCode removeProperty (const std::string &client, const std::string &name)
 
const PropertiesTgetProperties (const std::string &client) const
 
std::vector< std::stringgetClients () const
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &client, const std::string &name) const
 
std::ostreamfillStream (std::ostream &o) const
 dump the content of catalog to std::ostream More...
 

Private Member Functions

const PropertiesTfindProperties (const std::string &client) const
 
PropertiesTfindProperties (const std::string &client)
 
std::pair< bool, PropertiesT::const_iterator > findProperty (const PropertiesT &props, const std::string &name) const
 
std::pair< bool, PropertiesT::iterator > findProperty (PropertiesT &props, const std::string &name)
 

Private Attributes

std::map< std::string, PropertiesTm_catalog
 

Detailed Description

Member Typedef Documentation

◆ PropertiesT

Constructor & Destructor Documentation

◆ SvcCatalog()

SvcCatalog::SvcCatalog ( )
default

◆ ~SvcCatalog()

SvcCatalog::~SvcCatalog ( )

Definition at line 40 of file SvcCatalog.cpp.

40  {
41  for ( const auto& cur : m_catalog ) {
42  for ( auto& prop : cur.second ) delete prop;
43  }
44 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57

Member Function Documentation

◆ addProperty()

StatusCode SvcCatalog::addProperty ( const std::string client,
const Gaudi::Details::PropertyBase property 
)

Definition at line 46 of file SvcCatalog.cpp.

46  {
47  auto props = findProperties( client );
48  if ( props ) {
49  removeProperty( client, property->name() ).ignore();
50  props->push_back( property );
51  } else {
52  m_catalog.emplace( client, PropertiesT{property} );
53  }
54  return StatusCode::SUCCESS;
55 }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:80
std::vector< const Gaudi::Details::PropertyBase * > PropertiesT
Definition: SvcCatalog.h:37
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
const std::string name() const
property name
Definition: Property.h:46
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:57
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57

◆ fillStream()

std::ostream & SvcCatalog::fillStream ( std::ostream o) const

dump the content of catalog to std::ostream

Definition at line 106 of file SvcCatalog.cpp.

106  {
107  // loop over the clients:
108  for ( const auto& iclient : m_catalog ) {
109  o << "Client '" << iclient.first << "'" << std::endl;
110  for ( const auto& p : iclient.second ) {
111  if ( p ) o << "\t" << ( *p ) << std::endl;
112  }
113  }
114  //
115  return o; // RETURN
116 }
T endl(T... args)
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57

◆ findProperties() [1/2]

const SvcCatalog::PropertiesT * SvcCatalog::findProperties ( const std::string client) const
private

Definition at line 80 of file SvcCatalog.cpp.

80  {
81  auto result = m_catalog.find( client );
82  return ( result != m_catalog.end() ) ? &result->second : nullptr;
83 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57

◆ findProperties() [2/2]

SvcCatalog::PropertiesT * SvcCatalog::findProperties ( const std::string client)
private

Definition at line 85 of file SvcCatalog.cpp.

85  {
86  auto result = m_catalog.find( client );
87  return ( result != m_catalog.end() ) ? &result->second : nullptr;
88 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57

◆ findProperty() [1/2]

std::pair< bool, SvcCatalog::PropertiesT::const_iterator > SvcCatalog::findProperty ( const PropertiesT props,
const std::string name 
) const
private

Definition at line 90 of file SvcCatalog.cpp.

91  {
92  auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) {
93  return boost::iequals( name, prop->name() );
94  } );
95  return {p != std::end( props ), p};
96 }
T end(T... args)
const std::string name() const
property name
Definition: Property.h:46
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:42
T find_if(T... args)
T begin(T... args)

◆ findProperty() [2/2]

std::pair< bool, SvcCatalog::PropertiesT::iterator > SvcCatalog::findProperty ( SvcCatalog::PropertiesT props,
const std::string name 
)
private

Definition at line 98 of file SvcCatalog.cpp.

99  {
100  auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) {
101  return boost::iequals( name, prop->name() );
102  } );
103  return {p != std::end( props ), p};
104 }
T end(T... args)
const std::string name() const
property name
Definition: Property.h:46
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:42
T find_if(T... args)
T begin(T... args)

◆ getClients()

std::vector< std::string > SvcCatalog::getClients ( ) const

Definition at line 73 of file SvcCatalog.cpp.

73  {
75  result.reserve( m_catalog.size() );
77  return result;
78 }
T end(T... args)
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:57
T begin(T... args)
T back_inserter(T... args)
T transform(T... args)
T reserve(T... args)

◆ getProperties()

const SvcCatalog::PropertiesT * SvcCatalog::getProperties ( const std::string client) const

Definition at line 69 of file SvcCatalog.cpp.

69  {
70  return findProperties( client );
71 }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:80

◆ getProperty()

const Gaudi::Details::PropertyBase * SvcCatalog::getProperty ( const std::string client,
const std::string name 
) const

Definition at line 117 of file SvcCatalog.cpp.

118  {
119  auto props = findProperties( client );
120  if ( props ) {
121  const auto res = findProperty( *props, name );
122  if ( res.first ) { return *res.second; }
123  }
124  return nullptr;
125 }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:80
std::pair< bool, PropertiesT::const_iterator > findProperty(const PropertiesT &props, const std::string &name) const
Definition: SvcCatalog.cpp:90

◆ removeProperty()

StatusCode SvcCatalog::removeProperty ( const std::string client,
const std::string name 
)

Definition at line 57 of file SvcCatalog.cpp.

57  {
58  auto props = findProperties( client );
59  if ( props ) {
60  auto res = findProperty( *props, name );
61  if ( res.first ) {
62  delete *res.second;
63  props->erase( res.second );
64  }
65  }
66  return StatusCode::SUCCESS;
67 }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:80
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
std::pair< bool, PropertiesT::const_iterator > findProperty(const PropertiesT &props, const std::string &name) const
Definition: SvcCatalog.cpp:90

Member Data Documentation

◆ m_catalog

std::map<std::string, PropertiesT> SvcCatalog::m_catalog
private

Definition at line 57 of file SvcCatalog.h.


The documentation for this class was generated from the following files: