ATLAS Offline Software
PropertyWrapper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 #ifndef ASG_TOOLS__PROPERTY_WRAPPER_H
10 #define ASG_TOOLS__PROPERTY_WRAPPER_H
11 
12 
13 #ifdef XAOD_STANDALONE
14 
15 #include <iosfwd>
16 #include <string>
17 #include <utility>
18 
19 namespace Gaudi
20 {
31 
32  template<typename T> class Property final
33  {
34  public:
35  template<typename T2>
36  Property (T2 *owner, const std::string& name, const T& value,
37  const std::string& title = "");
38 
39  public:
40  template<typename T2>
41  Property (T2 *owner, const std::string& name, T&& value,
42  const std::string& title = "");
43 
44  public:
45  operator const T& () const noexcept;
46  const T& value () const noexcept {return m_value;}
47 
48  public:
49  template<typename T2>
50  Property<T>& operator = (T2&& that);
51 
52  public:
53  template<typename T2>
54  decltype(auto) operator + (T2&& that) const;
55 
56  public:
57  decltype(auto) empty () const {return m_value.empty();}
58  decltype(auto) size () const {return m_value.size();};
59  decltype(auto) begin () const {return m_value.begin();}
60  decltype(auto) end () const {return m_value.end();}
61  template<typename T2> decltype(auto) operator [] (const T2& index) const {
62  return m_value[index];}
63 
64  private:
65  T m_value;
66  };
67 
68 
69 
72 
73  template<typename T> template<typename T2>
75  Property (T2 *owner, const std::string& name, const T& value,
76  const std::string& title)
77  : m_value (value)
78  {
79  owner->declareProperty (name, m_value, title);
80  }
81 
82 
83 
84  template<typename T> template<typename T2>
86  Property (T2 *owner, const std::string& name, T&& value,
87  const std::string& title)
88  : m_value (std::move (value))
89  {
90  owner->declareProperty (name, m_value, title);
91  }
92 
93 
94 
95  template<typename T>
96  Property<T> ::
97  operator const T& () const noexcept
98  {
99  return m_value;
100  }
101 
102 
103 
104  template<typename T> template<typename T2>
106  operator = (T2&& that)
107  {
108  m_value = std::forward<T2>(that);
109  return *this;
110  }
111 
112 
113 
114  template<typename T> template<typename T2>
115  decltype(auto) Property<T> ::
116  operator + (T2&& that) const
117  {
118  return m_value + std::forward<T2>(that);
119  }
120 
121 
122 
123  template<typename T1,typename T2>
124  decltype(auto) operator + (T1&& lh, const Property<T2>& rh)
125  {
126  return std::forward<T1>(lh) + rh.value();
127  }
128 
129 
130 
131  template<typename T,typename T2>
132  bool operator == (const Property<T>& lhs, const T2& rhs)
133  {
134  return lhs.value() == rhs;
135  }
136 
137 
138 
139  template<typename T,typename T2>
140  bool operator != (const Property<T>& lhs, const T2& rhs)
141  {
142  return lhs.value() != rhs;
143  }
144 
145 
146 
147  template<typename T>
148  std::ostream& operator << (std::ostream& str, const Property<T>& property)
149  {
150  return str << property.value();
151  }
152 }
153 
154 #endif
155 
156 #endif
DiTauMassTools::TauTypes::lh
@ lh
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:53
operator==
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
Property::Property
Property()
Default constructor.
Definition: Property.cxx:43
index
Definition: index.py:1
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:124
EL::Detail::ManagerStep::final
@ final
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
Property
Support class for PropertyMgr.
Definition: Property.h:23
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
operator!=
bool operator!=(const DataVector< T > &a, const DataVector< T > &b)
Based on operator==.
covarianceTool.title
title
Definition: covarianceTool.py:542
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
DeMoScan.index
string index
Definition: DeMoScan.py:364
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
Property::name
static const std::string & name(Type type)
Function returning a user-readable name for a property type.
Definition: Property.cxx:21
str
Definition: BTagTrackIpAccessor.cxx:11
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35