All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SvcCatalog Class Reference

#include <src/JobOptionsSvc/SvcCatalog.h>

Collaboration diagram for SvcCatalog:

Public Types

typedef std::vector< const
Property * > 
PropertiesT
 
typedef std::map< std::string,
PropertiesT
ObjectsT
 

Public Member Functions

 SvcCatalog ()
 
virtual ~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

PropertiesTfindProperties (const std::string &client) const
 
bool findProperty (PropertiesT *props, const std::string &name, PropertiesT::iterator &result)
 

Private Attributes

ObjectsTm_catalog
 

Detailed Description

Member Typedef Documentation

typedef std::map<std::string, PropertiesT > SvcCatalog::ObjectsT

Definition at line 32 of file SvcCatalog.h.

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

Definition at line 31 of file SvcCatalog.h.

Constructor & Destructor Documentation

SvcCatalog::SvcCatalog ( )

Definition at line 20 of file SvcCatalog.cpp.

21 { m_catalog = new ObjectsT(); }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50
std::map< std::string, PropertiesT > ObjectsT
Definition: SvcCatalog.h:32
SvcCatalog::~SvcCatalog ( )
virtual

Definition at line 23 of file SvcCatalog.cpp.

24 {
25  for (ObjectsT::const_iterator cur=m_catalog->begin();
26  cur!=m_catalog->end();cur++)
27  {
28  for(PropertiesT::const_iterator prop=cur->second.begin();
29  prop!=cur->second.end(); prop++)
30  { if(NULL != *prop){ delete *prop; } }
31  }
32  delete m_catalog;
33 }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50

Member Function Documentation

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

Definition at line 36 of file SvcCatalog.cpp.

38 {
39  PropertiesT* props = findProperties(client);
40  if ( props != 0 ){
41  removeProperty(client,property->name()).ignore();
42  props->push_back(property);
43  }else{
44  PropertiesT toInsert;
45  toInsert.push_back(property);
46  m_catalog->insert(std::pair<std::string,PropertiesT>(client,toInsert));
47  }
48  return StatusCode::SUCCESS;
49 }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50
PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:82
const std::string & name() const
property name
Definition: Property.h:47
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:53
std::vector< const Property * > PropertiesT
Definition: SvcCatalog.h:31
std::ostream & SvcCatalog::fillStream ( std::ostream &  o) const

dump the content of catalog to std::ostream

Definition at line 101 of file SvcCatalog.cpp.

102 {
103  // loop over the clients:
104  for ( ObjectsT::const_iterator iclient = m_catalog->begin();
105  m_catalog->end() != iclient ; ++iclient )
106  {
107  const PropertiesT& props = iclient->second ;
108  o << "Client '" << iclient->first << "'" << std::endl ;
109  for ( PropertiesT::const_iterator ip = props.begin() ;
110  props.end() != ip ; ++ip )
111  {
112  const Property* p = *ip ;
113  if ( 0 == p ) { continue ; } // CONTINUE
114  o << "\t" << (*p) << std::endl ;
115  }
116  }
117  //
118  return o ; // RETURN
119 }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
std::vector< const Property * > PropertiesT
Definition: SvcCatalog.h:31
SvcCatalog::PropertiesT * SvcCatalog::findProperties ( const std::string &  client) const
private

Definition at line 82 of file SvcCatalog.cpp.

83 {
84  ObjectsT::iterator result;
85  if((result = m_catalog->find(client)) == m_catalog->end()){ return 0; }
86  return &result->second;
87 }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50
bool SvcCatalog::findProperty ( SvcCatalog::PropertiesT props,
const std::string &  name,
PropertiesT::iterator &  result 
)
private

Definition at line 90 of file SvcCatalog.cpp.

93 {
94  for(result = props->begin();result!=props->end();result++){
95  if(boost::to_lower_copy((*result)->name()) == boost::to_lower_copy(name))
96  { return true; }
97  }
98  return false;
99 }
std::vector< std::string > SvcCatalog::getClients ( ) const

Definition at line 73 of file SvcCatalog.cpp.

74 {
75  std::vector<std::string> result;
76  for (ObjectsT::const_iterator cur = m_catalog->begin();
77  cur != m_catalog->end(); cur++) { result.push_back(cur->first); }
78  return result;
79 }
ObjectsT * m_catalog
Definition: SvcCatalog.h:50
const SvcCatalog::PropertiesT * SvcCatalog::getProperties ( const std::string &  client) const

Definition at line 71 of file SvcCatalog.cpp.

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

Definition at line 53 of file SvcCatalog.cpp.

55 {
56  PropertiesT* props = findProperties(client);
57  if (props)
58  {
59  PropertiesT::iterator toRemove;
60  if(findProperty(props,name,toRemove))
61  {
62  delete *toRemove;
63  props->erase(toRemove);
64  }
65  }
66  return StatusCode::SUCCESS;
67 }
PropertiesT * findProperties(const std::string &client) const
Definition: SvcCatalog.cpp:82
bool findProperty(PropertiesT *props, const std::string &name, PropertiesT::iterator &result)
Definition: SvcCatalog.cpp:90
std::vector< const Property * > PropertiesT
Definition: SvcCatalog.h:31

Member Data Documentation

ObjectsT* SvcCatalog::m_catalog
private

Definition at line 50 of file SvcCatalog.h.


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