Loading [MathJax]/jax/output/HTML-CSS/config.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Nodes.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 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 #pragma once
12 
13 #include <Gaudi/Decays/Decay.h>
14 #include <Gaudi/Decays/iNode.h>
15 #include <Gaudi/ParticleID.h>
16 #include <GaudiKernel/Kernel.h>
17 #include <GaudiKernel/SmartIF.h>
18 #include <GaudiKernel/StatusCode.h>
19 
26 namespace Gaudi::Decays {
34  template <typename Iterator>
36  return std::all_of( begin, end, []( const auto& i ) { return i.valid(); } );
37  }
38  template <typename Container>
39  bool valid( Container const& c ) {
40  return valid( c.begin(), c.end() );
41  }
42 
51  template <class Iterator>
53  for ( ; begin != end; ++begin ) {
54  StatusCode sc = begin->validate( svc );
55  if ( sc.isFailure() ) { return sc; }
56  }
57  return StatusCode::SUCCESS;
58  }
59  template <class TREE>
61  return validate( tree.begin(), tree.end(), svc );
62  }
63 
64  class NodeList;
65 
66  namespace Nodes {
73  class GAUDI_API Invalid : public Decays::iNode {
74  public:
76  Invalid() = default;
78  Invalid* clone() const override;
80  bool operator()( const Gaudi::ParticleID& /* p */ ) const override;
82  std::ostream& fillStream( std::ostream& s ) const override;
84  bool valid() const override;
86  StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
87  };
88 
95  class GAUDI_API _Node {
96  public:
98  _Node();
100  _Node( const iNode& node ) : m_node( node ) {}
102  _Node( const Node& node ) : m_node( node ) {}
103  // default copy constructor
104  _Node( const _Node& node ) = default;
106  inline bool valid() const { return m_node.node().valid(); }
109  return m_node.node().validate( svc );
110  }
112  inline bool operator()( const Gaudi::ParticleID& pid ) const { return m_node.node( pid ); }
113 
114  inline bool operator==( const Gaudi::ParticleID& pid ) const { return m_node.node( pid ); }
115 
116  inline bool operator!=( const Gaudi::ParticleID& pid ) const { return !m_node.node( pid ); }
117 
119  _Node& operator=( const Node& right ) {
120  m_node = right;
121  return *this;
122  }
124  _Node& operator=( const iNode& right ) {
125  m_node = right;
126  return *this;
127  }
129  _Node& operator=( const _Node& right ) {
130  m_node = right.m_node;
131  return *this;
132  }
133 
134  _Node& operator|=( const iNode& right ) {
135  m_node |= right;
136  return *this;
137  }
138  _Node& operator&=( const iNode& right ) {
139  m_node &= right;
140  return *this;
141  }
142 
143  _Node& operator|=( const NodeList& right ) { return op_or( right ); }
144  _Node& operator&=( const NodeList& right ) { return op_and( right ); }
145 
146  _Node& operator|=( const _Node& right ) {
147  m_node |= right;
148  return *this;
149  }
150  _Node& operator&=( const _Node& right ) {
151  m_node &= right;
152  return *this;
153  }
154 
156  const Decays::iNode& node() const { return m_node.node(); }
158  operator const Decays::iNode&() const { return node(); }
159 
160  private:
161  _Node& op_or( const NodeList& right );
162  _Node& op_and( const NodeList& right );
165  };
166  } // namespace Nodes
167 
169  public:
172  typedef Nodes_::const_iterator const_iterator;
173  typedef Nodes_::iterator iterator;
174  typedef Nodes_::value_type value_type;
175 
177  NodeList( const Nodes_& nodes = Nodes_() );
178 
179  void push_back( const Decays::Nodes::_Node& node );
180  void push_back( const Decays::iNode& node );
181  void push_back( const Nodes_& nodes );
182  void push_back( const NodeList& nodes );
183  void clear() { m_nodes.clear(); }
184 
185  NodeList& operator=( const Decays::Nodes::_Node& node );
186  NodeList& operator=( const Decays::iNode& node );
187 
189  push_back( node );
190  return *this;
191  }
193  push_back( node );
194  return *this;
195  }
196  NodeList& operator+=( const Nodes_& nodes ) {
197  push_back( nodes );
198  return *this;
199  }
200  NodeList& operator+=( const NodeList& nodes ) {
201  push_back( nodes );
202  return *this;
203  }
204 
205  size_t size() const { return m_nodes.size(); }
206  bool empty() const { return m_nodes.empty(); }
207  iterator begin() { return m_nodes.begin(); }
208  iterator end() { return m_nodes.end(); }
209  const_iterator begin() const { return m_nodes.begin(); }
210  const_iterator end() const { return m_nodes.end(); }
211 
212  operator const Nodes_&() const { return m_nodes; }
213 
214  private:
217  };
218 
219  namespace Nodes {
226  class GAUDI_API Or : public Decays::iNode {
227  public:
229  Or( const Decays::iNode& n1, const Decays::iNode& n2 );
231  Or( const Decays::iNode& n1, const Decays::iNode& n2, const Decays::iNode& n3 );
233  Or( const Decays::iNode& n1, const Decays::iNode& n2, const Decays::iNode& n3, const Decays::iNode& n4 );
235  Or( const Decays::NodeList& nodes );
237  Or* clone() const override;
239  bool operator()( const Gaudi::ParticleID& pid ) const override;
241  std::ostream& fillStream( std::ostream& s ) const override;
243  bool valid() const override;
245  StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
246 
247  protected:
248  size_t add( const Decays::iNode& node );
249  size_t add( const Decays::NodeList& nodes );
250 
251  public:
252  Or& operator+=( const Decays::iNode& node );
253  Or& operator+=( const Decays::NodeList& node );
254 
255  private:
257  Or(); // the default constructor is disabled
258 
261  };
262 
269  class GAUDI_API And : public Decays::iNode {
270  public:
272  And( const Decays::iNode& n1, const Decays::iNode& n2 );
274  And( const Decays::iNode& n1, const Decays::iNode& n2, const Decays::iNode& n3 );
276  And( const Decays::iNode& n1, const Decays::iNode& n2, const Decays::iNode& n3, const Decays::iNode& n4 );
278  And( const Decays::NodeList& nodes );
280  And* clone() const override;
282  bool operator()( const Gaudi::ParticleID& p ) const override;
284  std::ostream& fillStream( std::ostream& s ) const override;
286  bool valid() const override;
288  StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
289 
290  protected:
291  size_t add( const Decays::iNode& node );
292  size_t add( const Decays::NodeList& nodes );
293 
294  public:
295  And& operator+=( const Decays::iNode& node );
296  And& operator+=( const Decays::NodeList& nodes );
297 
298  private:
301  };
302 
308  class GAUDI_API Not : public Decays::iNode {
309  public:
311  Not( const Decays::iNode& node );
313  Not* clone() const override;
315  bool operator()( const Gaudi::ParticleID& pid ) const override;
317  std::ostream& fillStream( std::ostream& s ) const override;
319  bool valid() const override;
321  StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
322 
323  public:
325  const Decays::iNode& node() const { return m_node.node(); }
326 
327  private:
330  };
331 
336  inline Decays::Nodes::Not operator!( const Decays::Nodes::Not& o ) { return Decays::Node( o.node() ); }
337 
339  inline std::ostream& operator<<( std::ostream& s, const Decays::Nodes::_Node& n ) { return s << n.node(); }
340  } // namespace Nodes
341 
346  inline Decays::Nodes::Or operator||( const Decays::iNode& o1, const Decays::iNode& o2 ) {
347  return Decays::Nodes::Or( o1, o2 );
348  }
349 
354  inline Decays::Nodes::Or operator|( const Decays::iNode& o1, const Decays::iNode& o2 ) {
355  return Decays::Nodes::Or( o1, o2 );
356  }
357 
362  inline Decays::Nodes::And operator&&( const Decays::iNode& o1, const Decays::iNode& o2 ) {
363  return Decays::Nodes::And( o1, o2 );
364  }
365 
370  inline Decays::Nodes::And operator&( const Decays::iNode& o1, const Decays::iNode& o2 ) {
371  return Decays::Nodes::And( o1, o2 );
372  }
373 
378  inline Decays::Nodes::Not operator~( const Decays::iNode& o ) { return Decays::Nodes::Not( o ); }
379 
384  GAUDI_API
385  Decays::Nodes::Or operator||( const Decays::iNode& o1, const std::string& o2 );
386 
391  GAUDI_API
393 
398  GAUDI_API
400 
405  GAUDI_API
407 
412  GAUDI_API
413  Decays::Nodes::Or operator||( const std::string& o2, const Decays::iNode& o1 );
414 
419  GAUDI_API
421 
426  GAUDI_API
428 
433  GAUDI_API
435 
440  GAUDI_API
441  Decays::Nodes::And operator&&( const Decays::iNode& o1, const std::string& o2 );
442 
447  GAUDI_API
449 
454  GAUDI_API
456 
461  GAUDI_API
463 
468  GAUDI_API
469  Decays::Nodes::And operator&&( const std::string& o2, const Decays::iNode& o1 );
470 
475  GAUDI_API
477 
482  GAUDI_API
484 
489  GAUDI_API
491 
492 } // namespace Gaudi::Decays
Gaudi::Decays::NodeList::size
size_t size() const
Definition: Nodes.h:205
Gaudi::Decays::Nodes::_Node::operator==
bool operator==(const Gaudi::ParticleID &pid) const
Definition: Nodes.h:114
Gaudi::Functional::details::details2::push_back
void push_back(Container &c, const Value &v, std::true_type)
Definition: details.h:250
Gaudi::Decays::NodeList::Nodes_
std::vector< Decays::Nodes::_Node > Nodes_
the actual type of the sequence of nodes
Definition: Nodes.h:171
Gaudi::Decays::Nodes::Or::Or
Or()
the default constructor is disabled
GaudiPartProp.Nodes.NodeList
NodeList
Definition: Nodes.py:314
Gaudi::Decays::Node
Definition: iNode.h:74
Gaudi::Decays::Nodes::_Node::operator=
_Node & operator=(const Node &right)
pseudo-assignment operator:
Definition: Nodes.h:119
Gaudi::Decays::NodeList
Definition: Nodes.h:168
std::string
STL class.
Gaudi::Decays::NodeList::begin
const_iterator begin() const
Definition: Nodes.h:209
Gaudi::Decays::NodeList::empty
bool empty() const
Definition: Nodes.h:206
Gaudi::Decays::Nodes::_Node::_Node
_Node(const iNode &node)
the constructor from iNode
Definition: Nodes.h:100
Gaudi::Decays::operator&&
Decays::Nodes::And operator&&(const Decays::iNode &o1, const Decays::iNode &o2)
Create the "AND" of two nodes.
Definition: Nodes.h:362
Gaudi::Decays::NodeList::end
iterator end()
Definition: Nodes.h:208
Gaudi::Decays::NodeList::const_iterator
Nodes_::const_iterator const_iterator
Definition: Nodes.h:172
Gaudi::Decays::Nodes::_Node::operator&=
_Node & operator&=(const iNode &right)
Definition: Nodes.h:138
Gaudi::Decays::Nodes::Not::node
const Decays::iNode & node() const
get the underlying node
Definition: Nodes.h:325
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector< Decays::Nodes::_Node >
Gaudi::Decays::Nodes::_Node::m_node
Decays::Node m_node
the node holder itself
Definition: Nodes.h:164
Gaudi::Interfaces::IParticlePropertySvc
Definition: IParticlePropertySvc.h:29
Gaudi::Decays::Nodes::_Node
Definition: Nodes.h:95
Gaudi::Decays::operator&
Decays::Nodes::And operator&(const Decays::iNode &o1, const Decays::iNode &o2)
Create the "AND" of two nodes.
Definition: Nodes.h:370
ParticleID.h
Gaudi::Decays::NodeList::clear
void clear()
Definition: Nodes.h:183
gaudirun.c
c
Definition: gaudirun.py:525
GaudiPartProp.Nodes._Node
_Node
Definition: Nodes.py:272
std::all_of
T all_of(T... args)
Gaudi::Decays::Nodes::And::m_nodes
NodeList m_nodes
the sub-nodes
Definition: Nodes.h:300
GaudiPartProp.Nodes.Node
Node
Definition: Nodes.py:246
Gaudi::Decays::Nodes::_Node::validate
StatusCode validate(const Gaudi::Interfaces::IParticlePropertySvc *svc) const
The proper validation of the node.
Definition: Nodes.h:108
Gaudi::Decays::Nodes::_Node::operator|=
_Node & operator|=(const _Node &right)
Definition: Nodes.h:146
StatusCode.h
Gaudi::Decays::NodeList::begin
iterator begin()
Definition: Nodes.h:207
Gaudi::Decays::Nodes::_Node::operator!=
bool operator!=(const Gaudi::ParticleID &pid) const
Definition: Nodes.h:116
Gaudi::Decays::NodeList::operator+=
NodeList & operator+=(const Decays::Nodes::_Node &node)
Definition: Nodes.h:188
Gaudi::Decays::Nodes::Invalid::Invalid
Invalid()=default
MANDATORY: default constructor.
Gaudi::Decays::Nodes::Invalid
Definition: Nodes.h:73
Gaudi::Decays::Nodes::operator<<
std::ostream & operator<<(std::ostream &s, const Decays::Nodes::_Node &n)
output operator
Definition: Nodes.h:339
SmartIF.h
StatusCode
Definition: StatusCode.h:65
Gaudi::Decays::NodeList::end
const_iterator end() const
Definition: Nodes.h:210
Gaudi::Decays::NodeList::operator+=
NodeList & operator+=(const Nodes_ &nodes)
Definition: Nodes.h:196
Gaudi::Decays::operator||
Decays::Nodes::Or operator||(const Decays::iNode &o1, const Decays::iNode &o2)
Create the "OR" of two nodes.
Definition: Nodes.h:346
std::ostream
STL class.
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
Gaudi::Decays::Nodes::Or::m_nodes
Decays::NodeList m_nodes
the sub-nodes
Definition: Nodes.h:260
Gaudi::Decays::NodeList::iterator
Nodes_::iterator iterator
Definition: Nodes.h:173
Gaudi::Decays::validate
StatusCode validate(Iterator begin, Iterator end, const Gaudi::Interfaces::IParticlePropertySvc *svc)
validate trees/nodes
Definition: Nodes.h:52
Gaudi::Decays::Nodes::Or
Definition: Nodes.h:226
Gaudi::Decays::Nodes::_Node::node
const Decays::iNode & node() const
the accessor to the node
Definition: Nodes.h:156
GaudiPartProp.Nodes.Or
Or
Definition: Nodes.py:268
Gaudi::Decays::operator|
Decays::Nodes::Or operator|(const Decays::iNode &o1, const Decays::iNode &o2)
Create the "OR" of two nodes.
Definition: Nodes.h:354
Gaudi::Decays::Nodes::Not::m_node
Decays::Node m_node
the node itself
Definition: Nodes.h:329
Gaudi::ParticleProperty
Definition: ParticleProperty.h:37
Gaudi::Decays::operator~
Decays::Nodes::Not operator~(const Decays::iNode &o)
Create the "NOT" for the node.
Definition: Nodes.h:378
Gaudi::Decays::NodeList::operator+=
NodeList & operator+=(const NodeList &nodes)
Definition: Nodes.h:200
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:234
Gaudi::Decays::Nodes::_Node::valid
bool valid() const
Check the validity.
Definition: Nodes.h:106
Gaudi::Decays::NodeList::operator+=
NodeList & operator+=(const Decays::iNode &node)
Definition: Nodes.h:192
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Decays
Definition: CC.h:17
GaudiPartProp.Nodes.Not
Not
Definition: Nodes.py:270
Gaudi::Decays::Nodes::_Node::operator&=
_Node & operator&=(const NodeList &right)
Definition: Nodes.h:144
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Decay.h
Gaudi::Decays::valid
bool valid(Iterator begin, Iterator end)
check the validness of the trees or nodes
Definition: Nodes.h:35
Gaudi::Decays::Nodes::_Node::operator=
_Node & operator=(const iNode &right)
pseudo-assignment from arbitrary node
Definition: Nodes.h:124
Kernel.h
Gaudi::ParticleID
Definition: ParticleID.h:43
Gaudi::Decays::Nodes::_Node::operator&=
_Node & operator&=(const _Node &right)
Definition: Nodes.h:150
Gaudi::Decays::Decay::Item
Definition: Decay.h:39
Gaudi::Decays::Nodes::_Node::operator=
_Node & operator=(const _Node &right)
pseudo-assignment from arbitrary node
Definition: Nodes.h:129
Gaudi::Decays::NodeList::value_type
Nodes_::value_type value_type
Definition: Nodes.h:174
Gaudi::Decays::Nodes::_Node::operator|=
_Node & operator|=(const iNode &right)
Definition: Nodes.h:134
iNode.h
Gaudi::Decays::iNode
Definition: iNode.h:35
GaudiPartProp.Nodes.And
And
Definition: Nodes.py:269
Gaudi::Decays::NodeList::m_nodes
Nodes_ m_nodes
the actual list of nodes
Definition: Nodes.h:216
Gaudi::Decays::Nodes::_Node::_Node
_Node(const _Node &node)=default
IOTest.end
end
Definition: IOTest.py:123
Gaudi::Decays::Nodes::operator!
Decays::Nodes::Not operator!(const Decays::Nodes::Not &o)
Create the "NOT" for the node.
Definition: Nodes.h:336
DataOnDemand.Nodes
list Nodes
Definition: DataOnDemand.py:34
Gaudi::Decays::Nodes::_Node::operator|=
_Node & operator|=(const NodeList &right)
Definition: Nodes.h:143
Gaudi::Decays::Nodes::Not
Definition: Nodes.h:308
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:49
Gaudi::Decays::Nodes::And
Definition: Nodes.h:269
Gaudi::Decays::Nodes::_Node::operator()
bool operator()(const Gaudi::ParticleID &pid) const
The major method.
Definition: Nodes.h:112
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28
Gaudi::Decays::Nodes::_Node::_Node
_Node(const Node &node)
the constructor from Node
Definition: Nodes.h:102