The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
ExtendedProperties.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// ============================================================================
12// Include files
13// ============================================================================
14// STD & STL
15// ============================================================================
16#include <array>
17#include <map>
18#include <string>
19#include <tuple>
20#include <unordered_set>
21#include <utility>
22#include <vector>
23
24#include <GaudiKernel/Map.h>
25
26// ============================================================================
27// Include parsers for creating parser that handles tuple
28// ============================================================================
31
33// ============================================================================
34
35#ifdef __ICC
36// disable icc remark #177: declared but never referenced
37# pragma warning( disable : 177 )
38#endif
39
47
55
57public:
58 StatusCode execute() override;
59
60 ExtendedProperties( const std::string& name, ISvcLocator* pSvc ) : Algorithm( name, pSvc ) {
61 setProperty( "PropertiesPrint", true ).ignore();
62
63 m_20["key"] = "value";
64 m_21.value().push_back( 123 );
65 }
66
67private:
69
72 Gaudi::Property<std::vector<std::vector<double>>> m_4{ this, "VectorOfVectorsDouble" };
73
79
83
86
89
91 Gaudi::Property<std::vector<int>> m_21{ this, "EmptyVector" };
92
95
98
99 // std::array must be explicitly initialized
100 Gaudi::Property<std::array<double, 3>> m_23{ this, "StdArrayDouble3", { 0 } };
101 Gaudi::Property<std::array<int, 1>> m_26{ this, "StdArrayInt1", { 0 } };
102
104
105 using Triplet = std::tuple<std::string, std::string, std::string>;
106 static inline std::hash<std::string> hasher;
108 std::size_t operator()( Triplet const& entry ) const {
109 return hasher( std::get<0>( entry ) ) ^ hasher( std::get<1>( entry ) ) ^ hasher( std::get<2>( entry ) );
110 }
111 };
112
116 using VS = std::vector<std::string>;
118 using SS = std::set<std::string>;
120 using USS = std::unordered_set<std::string>;
122};
123// ============================================================================
125// ============================================================================
127// ============================================================================
129 always() << " My Properties : " << endmsg;
130
131 always() << " \t" << m_1 << endmsg;
132 always() << " \t" << m_2 << endmsg;
133 always() << " \t" << m_3 << endmsg;
134 always() << " \t" << m_4 << endmsg;
135 always() << " \t" << m_5 << endmsg;
136 always() << " \t" << m_6 << endmsg;
137 always() << " \t" << m_7 << endmsg;
138 always() << " \t" << m_8 << endmsg;
139 always() << " \t" << m_9 << endmsg;
140 always() << " \t" << m_10 << endmsg;
141 always() << " \t" << m_11 << endmsg;
142 always() << " \t" << m_12 << endmsg;
143 always() << " \t" << m_13 << endmsg;
144 always() << " \t" << m_14 << endmsg;
145 always() << " \t" << m_14 << endmsg;
146 always() << " \t" << m_15 << endmsg;
147 always() << " \t" << m_16 << endmsg;
148
149 always() << " \t" << m_20 << endmsg;
150 always() << " \t" << m_21 << endmsg;
151
152 always() << " \t" << m_22 << endmsg;
153 always() << " \t" << m_25 << endmsg;
154 always() << " \t" << m_23 << endmsg;
155 always() << " \t" << m_26 << endmsg;
156
157 always() << " \t" << m_24 << endmsg;
158
159 always() << " \t" << m_30 << endmsg;
160 always() << " \t" << m_31 << endmsg;
161
162 always() << " \t" << m_tuplevector << endmsg;
163 always() << " \t" << m_intvectortuple << endmsg;
164 always() << " \t" << m_tupleset << endmsg;
165 always() << " \t" << m_intsettuple << endmsg;
166 always() << " \t" << m_tupleunset << endmsg;
167 always() << " \t" << m_intunsettuple << endmsg;
168
169 // some properties could be created from other (convertible) types:
170 Gaudi::Property<short> m1( "a", 0 );
171 Gaudi::Property<double> m2( "b", m1 );
172
173 // some properties could be assigned from other (convertible) types
174 Gaudi::Property<int> m3( "c", 0 );
175 m3 = m1;
176
177 float i = 10;
178 Gaudi::Property<float&> m4( "d", i );
179
180 m4 = 12;
181
182 return StatusCode::SUCCESS;
183}
184// ============================================================================
185// The END
186// ============================================================================
bool PyHelper setProperty(IInterface *p, char *name, char *value)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
Collection of utilities, which allows to use class std::array as property for Gaudi-components.
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
std::tuple< std::string, std::string, std::string > Triplet
Gaudi::Property< std::array< double, 3 > > m_23
Gaudi::Property< std::unordered_set< std::string > > m_31
Gaudi::Property< std::map< std::string, std::string > > m_20
Gaudi::Property< std::array< int, 1 > > m_26
Gaudi::Property< std::vector< int > > m_21
ExtendedProperties(const std::string &name, ISvcLocator *pSvc)
Gaudi::Property< std::pair< int, int > > m_10
Gaudi::Property< std::map< std::string, int > > m_7
Gaudi::Property< std::map< unsigned int, std::string > > m_16
Gaudi::Property< std::map< int, double > > m_5
Gaudi::Property< std::map< std::string, double > > m_8
Gaudi::Property< std::map< int, int > > m_13
Gaudi::Property< std::map< int, std::string > > m_15
Gaudi::Property< std::set< Triplet > > m_tupleset
Gaudi::Property< std::tuple< std::string, int, double > > m_22
std::set< std::string > SS
std::unordered_set< std::string > USS
static std::hash< std::string > hasher
Gaudi::Property< std::map< std::string, std::vector< int > > > m_12
Gaudi::Property< std::vector< std::pair< double, double > > > m_2
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_9
Gaudi::Property< std::map< std::string, std::string > > m_6
Gaudi::Property< std::map< std::string, std::vector< double > > > m_11
StatusCode execute() override
factory
Gaudi::Property< std::tuple< int, VS > > m_intvectortuple
Gaudi::Property< std::tuple< int, SS > > m_intsettuple
Gaudi::Property< std::vector< std::vector< std::string > > > m_3
Gaudi::Property< std::vector< std::pair< int, int > > > m_14
Gaudi::Property< std::tuple< int, USS > > m_intunsettuple
Gaudi::Property< std::vector< std::vector< double > > > m_4
Gaudi::Property< GaudiUtils::Map< std::string, std::string > > m_24
Gaudi::Property< std::unordered_set< Triplet, HashFunction > > m_tupleunset
Gaudi::Property< std::pair< double, double > > m_1
Gaudi::Property< std::tuple< std::string > > m_25
std::vector< std::string > VS
Gaudi::Property< std::vector< Triplet > > m_tuplevector
Gaudi::Property< std::unordered_set< int > > m_30
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
const std::string & name() const override
The identifying name of the algorithm object.
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
std::size_t operator()(Triplet const &entry) const