SvcCatalog Class Referencefinal

#include <src/JobOptionsSvc/SvcCatalog.h>

Collaboration diagram for SvcCatalog:

Public Types

typedef std::vector< const Property * > PropertiesT
 

Public Member Functions

 SvcCatalog ()=default
 
 ~SvcCatalog ()
 
StatusCode addProperty (const std::string &client, const Property *property)
 
StatusCode removeProperty (const std::string &client, const std::string &name)
 
const PropertiesTgetProperties (const std::string &client) const
 
std::vector< std::string > getClients () const
 
std::ostream & fillStream (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::iterator > findProperty (PropertiesT &props, const std::string &name)
 

Private Attributes

std::map< std::string, PropertiesTm_catalog
 

Detailed Description

Member Typedef Documentation

typedef std::vector<const Property*> SvcCatalog::PropertiesT

Definition at line 28 of file SvcCatalog.h.

Constructor & Destructor Documentation

SvcCatalog::SvcCatalog ( )
default
SvcCatalog::~SvcCatalog ( )

Definition at line 26 of file SvcCatalog.cpp.

27 {
28  for (const auto& cur : m_catalog)
29  {
30  for (auto & prop : cur.second) delete prop;
31  }
32 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:46

Member Function Documentation

StatusCode SvcCatalog::addProperty ( const std::string &  client,
const Property property 
)

Definition at line 35 of file SvcCatalog.cpp.

37 {
38  auto props = findProperties(client);
39  if ( props ){
40  removeProperty(client,property->name()).ignore();
41  props->push_back(property);
42  }else{
43  m_catalog.emplace( client, PropertiesT{ property } );
44  }
45  return StatusCode::SUCCESS;
46 }
const std::string & name() const
property name
Definition: Property.h:45
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:49
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:76
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:46
std::vector< const Property * > PropertiesT
Definition: SvcCatalog.h:28
std::ostream & SvcCatalog::fillStream ( std::ostream &  o) const

dump the content of catalog to std::ostream

Definition at line 103 of file SvcCatalog.cpp.

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

Definition at line 76 of file SvcCatalog.cpp.

77 {
78  auto result = m_catalog.find(client);
79  return ( result != m_catalog.end() ) ? &result->second
80  : nullptr;
81 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:46
SvcCatalog::PropertiesT * SvcCatalog::findProperties ( const std::string &  client)
private

Definition at line 84 of file SvcCatalog.cpp.

85 {
86  auto result = m_catalog.find(client);
87  return ( result != m_catalog.end() ) ? &result->second
88  : nullptr;
89 }
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:46
std::pair< bool, SvcCatalog::PropertiesT::iterator > SvcCatalog::findProperty ( SvcCatalog::PropertiesT props,
const std::string &  name 
)
private

Definition at line 93 of file SvcCatalog.cpp.

95 {
96  auto p = std::find_if( std::begin(props), std::end(props),
97  [&](const Property* prop) {
98  return boost::iequals( name, prop->name());
99  });
100  return { p != std::end(props), p };
101 }
const std::string & name() const
property name
Definition: Property.h:45
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
std::vector< std::string > SvcCatalog::getClients ( ) const

Definition at line 67 of file SvcCatalog.cpp.

68 {
69  std::vector<std::string> result; result.reserve(m_catalog.size());
70  std::transform( std::begin(m_catalog), std::end(m_catalog),
71  std::back_inserter(result), select1st );
72  return result;
73 }
constexpr struct select1st_t select1st
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::map< std::string, PropertiesT > m_catalog
Definition: SvcCatalog.h:46
const SvcCatalog::PropertiesT * SvcCatalog::getProperties ( const std::string &  client) const

Definition at line 65 of file SvcCatalog.cpp.

65 { return findProperties(client); }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:76
StatusCode SvcCatalog::removeProperty ( const std::string &  client,
const std::string &  name 
)

Definition at line 49 of file SvcCatalog.cpp.

51 {
52  auto props = findProperties(client);
53  if (props) {
54  auto res = findProperty(*props,name);
55  if(res.first) {
56  delete *res.second;
57  props->erase(res.second);
58  }
59  }
60  return StatusCode::SUCCESS;
61 }
const PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:76
std::pair< bool, PropertiesT::iterator > findProperty(PropertiesT &props, const std::string &name)
Definition: SvcCatalog.cpp:93

Member Data Documentation

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

Definition at line 46 of file SvcCatalog.h.


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