The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
Catalog.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include "
Catalog.h
"
12
#include <format>
13
14
namespace
gp
=
Gaudi::Parsers
;
15
namespace
{
16
constexpr
struct
select1st_t {
17
template
<
typename
S,
typename
T>
18
const
S& operator()(
const
std::pair<S, T>& p )
const
{
19
return
p.first;
20
}
21
template
<
typename
S,
typename
T>
22
S& operator()( std::pair<S, T>& p )
const
{
23
return
p.first;
24
}
25
} select1st{};
26
}
// namespace
27
28
std::vector<std::string>
gp::Catalog::ClientNames
()
const
{
29
std::vector<std::string> result;
30
std::transform( std::begin(
catalog_
), std::end(
catalog_
), std::back_inserter( result ), select1st );
31
return
result;
32
}
33
bool
gp::Catalog::Add
(
Property
* property ) {
34
assert( property );
35
auto
it =
catalog_
.find( property->
ClientName
() );
36
if
( it ==
catalog_
.end() ) {
37
CatalogSet::mapped_type properties;
38
properties.insert( property );
39
catalog_
.emplace( property->
ClientName
(), properties );
40
return
true
;
41
}
42
it->second.erase( *property );
43
it->second.insert( property );
44
// TODO: check return value
45
return
true
;
46
}
47
gp::Property
*
gp::Catalog::Find
( std::string_view client, std::string_view name ) {
48
auto
it =
catalog_
.find( client );
49
if
( it ==
catalog_
.end() )
return
nullptr
;
50
51
auto
pit = std::find_if( it->second.begin(), it->second.end(),
52
[&](
const
Property
& property ) { return name == property.NameInClient(); } );
53
54
return
( pit != it->second.end() ) ? &*pit :
nullptr
;
55
}
56
std::string
gp::Catalog::ToString
()
const
{
57
std::string result;
58
for
(
const
auto
& client :
catalog_
) {
59
for
(
const
auto
& current : client.second ) { result += current.ToString() +
"\n"
; }
60
}
61
return
result;
62
}
63
std::ostream&
Gaudi::Parsers::Catalog::fillStream
( std::ostream& o )
const
{
64
o << R
"(// ==================================================================================
65
// Parser catalog
66
// ==================================================================================
67
)";
68
69
size_t
nComponents = 0;
70
size_t
nProperties = 0;
71
72
for
(
const
auto
& client :
catalog_
) {
73
o << std::format(
"// Properties of {:<25} # = {}"
, std::format(
"'{}'"
, client.first ), client.second.size() );
74
++nComponents;
75
nProperties += client.second.size();
76
for
(
const
auto
& current : client.second ) {
77
o << std::format(
"{:<44} = {} ;"
, current.FullName(), current.ValueAsString() );
78
}
79
}
80
o << std::format( R
"(// ==================================================================================
81
// End parser catalog #Components={} #Properties={}
82
// ==================================================================================
83
)",
84
nComponents, nProperties );
85
return
o;
86
}
Catalog.h
Gaudi::Parsers::Catalog::Find
Property * Find(std::string_view client, std::string_view name)
Definition
Catalog.cpp:47
Gaudi::Parsers::Catalog::Add
bool Add(Property *property)
Definition
Catalog.cpp:33
Gaudi::Parsers::Catalog::catalog_
CatalogSet catalog_
Definition
Catalog.h:46
Gaudi::Parsers::Catalog::ClientNames
std::vector< std::string > ClientNames() const
Definition
Catalog.cpp:28
Gaudi::Parsers::Catalog::ToString
std::string ToString() const
Definition
Catalog.cpp:56
Gaudi::Parsers::Catalog::fillStream
std::ostream & fillStream(std::ostream &out) const
print the content of the catalogue to std::ostream
Definition
Catalog.cpp:63
Gaudi::Parsers::Property
Definition
Property.h:20
Gaudi::Parsers::Property::ClientName
const std::string & ClientName() const
Definition
Property.cpp:21
Gaudi::Parsers
Definition
DODBasicMapper.cpp:17
GaudiCoreSvc
src
JobOptionsSvc
Catalog.cpp
Generated on
for The Gaudi Framework by
1.17.0