ATLAS Offline Software
Loading...
Searching...
No Matches
IDTPM2::PredicateAncestorFinder< T, P > Class Template Reference

a type using a generic bool function pointer since - for some reason, I can not fathom, people like to use eg MC::isTau(p) rather than say, just t->pdfId() == MC::Tau - I mean why just use a value you can change at runtime, when you could hard code an actual function that you can't change at all, even if you need to More...

#include <AncestorFinder.h>

Inheritance diagram for IDTPM2::PredicateAncestorFinder< T, P >:
Collaboration diagram for IDTPM2::PredicateAncestorFinder< T, P >:

Public Member Functions

 PredicateAncestorFinder (P p)
bool predicate (const T *t) const override
const T * findAncestor (const T *t) const

Private Attributes

Predicate m_predicate

Detailed Description

template<typename T, typename P = bool (*)(const T*)>
class IDTPM2::PredicateAncestorFinder< T, P >

a type using a generic bool function pointer since - for some reason, I can not fathom, people like to use eg MC::isTau(p) rather than say, just t->pdfId() == MC::Tau - I mean why just use a value you can change at runtime, when you could hard code an actual function that you can't change at all, even if you need to

Definition at line 182 of file AncestorFinder.h.

Constructor & Destructor Documentation

◆ PredicateAncestorFinder()

template<typename T, typename P = bool (*)(const T*)>
IDTPM2::PredicateAncestorFinder< T, P >::PredicateAncestorFinder ( P p)
inline

Definition at line 184 of file AncestorFinder.h.

a type using a generic bool function pointer since - for some reason, I can not fathom,...

Member Function Documentation

◆ findAncestor()

template<typename T>
const T * IDTPM2::IFinder< T >::findAncestor ( const T * t) const
inlineinherited

successful stopping condition ...

isn't recursion great boys and girls ?

Definition at line 33 of file AncestorFinder.h.

33 {
34
35 // reached the end ...
36 if (!t) return 0;
37
39 if ( predicate(t) ) return t;
40
41 for ( size_t p=0 ; p<t->nParents() ; p++ ) {
42 const T* parent = t->parent(p);
43
44 if ( parent==t ) continue;
45
47 if ( const T* found = findAncestor(parent) ) return found;
48 }
49
50 return 0;
51 }
const T * findAncestor(const T *t) const
virtual bool predicate(const T *t) const =0

◆ predicate()

template<typename T, typename Predicate>
bool IDTPM2::GenericAncestorFinder< T, Predicate >::predicate ( const T * t) const
inlineoverridevirtualinherited

Implements IDTPM2::IFinder< T >.

Definition at line 68 of file AncestorFinder.h.

68{ return m_predicate(t); }
allow generic predicate types ...

Member Data Documentation

◆ m_predicate

template<typename T, typename Predicate>
Predicate IDTPM2::GenericAncestorFinder< T, Predicate >::m_predicate
privateinherited

Definition at line 72 of file AncestorFinder.h.


The documentation for this class was generated from the following file: