| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Catalog.cpp
Go to the documentation of this file.
1 // ============================================================================
2 #include "Catalog.h"
3 // ============================================================================
4 // Boost:
5 // ============================================================================
6 #include <boost/foreach.hpp>
7 #include <boost/format.hpp>
8 // ============================================================================
9 // Namesapce aliases:
10 // ============================================================================
11 namespace gp = Gaudi::Parsers;
12 // ============================================================================
13 std::vector<std::string> gp::Catalog::ClientNames() const {
14 std::vector<std::string> result;
15 BOOST_FOREACH(const CatalogSet::value_type& prop, catalog_) {
16 result.push_back(prop.first);
17 }
18 return result;
19 }
20 // ============================================================================
21 bool gp::Catalog::Add(Property* property) {
22 assert( property != NULL);
23 CatalogSet::iterator it = catalog_.find(property->ClientName());
24 if (it == catalog_.end()) {
25 CatalogSet::mapped_type properties;
26 properties.insert(property);
27 catalog_.insert(CatalogSet::value_type(property->ClientName(), properties));
28 return true;
29 }
30 it->second.erase(*property);
31 it->second.insert(property);
32 //TODO: check return value
33 return true;
34 }
35 // ============================================================================
36 gp::Property* gp::Catalog::Find(const std::string& client,
37 const std::string& name) {
38 CatalogSet::iterator it = catalog_.find(client);
39 if (it == catalog_.end()) return NULL;
40
41 CatalogSet::mapped_type::iterator pit = std::find_if(it->second.begin(),
42 it->second.end(), Property::Equal(name));
43 if (pit == it->second.end()) return NULL;
44 return &*pit;
45
46 }
47 // ============================================================================
48 std::string gp::Catalog::ToString() const {
49 std::string result;
50 BOOST_FOREACH(const CatalogSet::value_type& client, catalog_) {
51 for (CatalogSet::mapped_type::const_iterator current = client.second.begin();
52 current != client.second.end(); ++current) {
53 result += current->ToString()+"\n";
54 }
55 }
56 return result;
57 }
58 // ============================================================================
59 // print the content of the catalogue to std::ostream
60 // ============================================================================
61 std::ostream& Gaudi::Parsers::Catalog::fillStream ( std::ostream& o ) const
62 {
63 o << "// " << std::string(82,'=') << std::endl
64 << "// Parser catalog " << std::endl
65 << "// " << std::string(82,'=') << std::endl ;
66
67 size_t nComponents = 0 ;
68 size_t nProperties = 0 ;
69
70 BOOST_FOREACH(const CatalogSet::value_type& client, catalog_) {
71 o << boost::format("// Properties of '%1%' %|43t|# = %2%" )
72 % client.first % client.second.size() << std::endl ;
73 ++nComponents ;
74 nProperties += client.second.size() ;
75 for (CatalogSet::mapped_type::const_iterator current = client.second.begin();
76 current != client.second.end(); ++current) {
77 o << boost::format("%1% %|44t| = %2% ; ")
78 % current->FullName()
79 % current->ValueAsString()
80 << std::endl;
81 }
82 }
83 o << "// " << std::string(82,'=') << std::endl
84 << boost::format("// End parser catalog #Components=%1% #Properties=%2%")
85 % nComponents % nProperties << std::endl
86 << "// " << std::string(82,'=') << std::endl ;
87 return o ;
88 }