The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
iNode.cpp
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#include <Gaudi/Decays/Nodes.h>
12#include <Gaudi/Decays/iNode.h>
14#include <sstream>
15#include <typeinfo>
16
17namespace Decays = Gaudi::Decays;
18
24std::string Decays::iNode::toString() const {
25 std::ostringstream s;
26 fillStream( s );
27 return s.str();
28}
29
30bool Decays::iNode::operator!() const { return !( this->valid() ); }
31
33 if ( typeid( Decays::Node ) == typeid( node ) ) {
34 const Node& _node = dynamic_cast<const Node&>( node );
35 m_node.reset( _node.m_node->clone() );
36 } else {
37 m_node.reset( node.clone() );
38 }
39}
40
41Decays::Node::Node( const Decays::Node& right ) : Decays::iNode( right ), m_node( right.m_node->clone() ) {}
42
43bool Decays::Node::operator()( const Gaudi::ParticleID& pid ) const { return node( pid ); }
44
45std::ostream& Decays::Node::fillStream( std::ostream& s ) const { return m_node->fillStream( s ); }
46
47bool Decays::Node::valid() const { return m_node->valid(); }
48
50 return m_node->validate( svc );
51}
52
54 if ( &right == this ) { return *this; }
55 m_node.reset( right.m_node->clone() );
56 return *this;
57}
58
60 if ( &right == this ) { return *this; }
61 Decays::iNode* node = nullptr;
62 if ( typeid( Decays::Node ) == typeid( right ) ) {
63 const Node& _node = dynamic_cast<const Node&>( right );
64 node = _node.m_node->clone();
65 } else {
66 node = right.clone();
67 }
68 m_node.reset( node );
69 return *this;
70}
71
72Decays::Node* Decays::Node::clone() const { return new Decays::Node( *this ); }
73
74Decays::Node& Decays::Node::op_and( const Decays::iNode& right ) { return ( *this = ( *m_node && right ) ); }
75
76Decays::Node& Decays::Node::op_or( const Decays::iNode& right ) { return ( *this = ( *m_node || right ) ); }
Helper general purpose utilities to deal with decay nodes.
The generic class to hold the pointer to other node.
Definition iNode.h:74
Node & op_or(const iNode &right)
Definition iNode.cpp:76
Node * clone() const override
MANDATORY: clone method ("virtual constructor")
Definition iNode.cpp:72
Node & op_and(const iNode &right)
Definition iNode.cpp:74
bool valid() const override
MANDATORY: check the validity of the node.
Definition iNode.cpp:47
std::unique_ptr< iNode > m_node
the node itself:
Definition iNode.h:111
Node(const Decays::iNode &node)
constructor from the node
Definition iNode.cpp:32
bool operator()(const Gaudi::ParticleID &p) const override
MANDATORY: the only one essential method.
Definition iNode.cpp:43
std::ostream & fillStream(std::ostream &s) const override
MANDATORY: the specific printout.
Definition iNode.cpp:45
const iNode & node() const
Definition iNode.h:96
StatusCode validate(const Gaudi::Interfaces::IParticlePropertySvc *svc) const override
MANDATORY: the proper validation of the node.
Definition iNode.cpp:49
Node & operator=(const Node &right)
assignment operator:
Definition iNode.cpp:53
The abstract class which represents the single "node" of decay tree.
Definition iNode.h:35
virtual std::string toString() const
the string representation of the node
Definition iNode.cpp:24
virtual bool operator!() const
invalid node?
Definition iNode.cpp:30
virtual std::ostream & fillStream(std::ostream &s) const =0
printout of the stream
virtual iNode * clone() const =0
clone method ("virtual constructor")
The abstract interface to Particle Property Service.
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
Definition ParticleID.h:43
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool valid(Iterator begin, Iterator end)
check the validness of the trees or nodes
Definition Nodes.h:36