#include <RefHelper.h>
Public Types | |
typedef edm::Ptr< T > | Ref |
Public Member Functions | |
template<typename V , typename SomeRef > | |
V | ancestorLookup (const SomeRef &ref, const edm::ValueMap< V > &map) const |
Ref | ancestorOrSelf (const Ref &ref) const |
Climbs back the Ref chain and returns the root of the branch starting from "ref". | |
bool | isAncestorOf (const Ref &old, const Ref &young) const |
true if old is some ancestor of young (it does not have to be the root) | |
bool | isRoot (const Ref &ref) const |
Ref | parentOrNull (const Ref &ref) const |
Returns a Ref to the direct parent of "ref", or a null Ref if "ref" is already root. | |
Ref | parentOrSelf (const Ref &ref) const |
Returns a Ref to the direct parent of "ref", or "ref" itself if it's already root. | |
template<typename V , typename SomeRef > | |
V | recursiveLookup (const SomeRef &ref, const edm::ValueMap< V > &map) const |
RefHelper (const edm::ValueMap< Ref > &backRefMap) | |
Constructor taking a ValueMap of back-references daughter => mother. | |
bool | sharedAncestor (const Ref &ref1, const Ref &ref2) const |
true if the two share the same root | |
Private Attributes | |
const edm::ValueMap< Ref > & | backRefMap_ |
Definition at line 10 of file RefHelper.h.
typedef edm::Ptr<T> pat::helper::RefHelper< T >::Ref |
Definition at line 12 of file RefHelper.h.
pat::helper::RefHelper< T >::RefHelper | ( | const edm::ValueMap< Ref > & | backRefMap | ) | [inline] |
Constructor taking a ValueMap of back-references daughter => mother.
Definition at line 15 of file RefHelper.h.
: backRefMap_(backRefMap) { }
V pat::helper::RefHelper< T >::ancestorLookup | ( | const SomeRef & | ref, |
const edm::ValueMap< V > & | map | ||
) | const |
Looks up map to find something associated to the root ancestor of "ref" Throws edm::Exception(edm::errors::InvalidReference) if there's no match
Definition at line 124 of file RefHelper.h.
{ Ref tref(ref); return map[ancestorOrSelf(tref)]; }
RefHelper< T >::Ref pat::helper::RefHelper< T >::ancestorOrSelf | ( | const Ref & | ref | ) | const |
Climbs back the Ref chain and returns the root of the branch starting from "ref".
Definition at line 72 of file RefHelper.h.
References edm::Ptr< T >::isNull(), and runTheMatrix::ret.
{ Ref ret = ref; do { Ref test = parentOrNull(ret); if (test.isNull()) return ret; ret = test; } while (true); }
bool pat::helper::RefHelper< T >::isAncestorOf | ( | const Ref & | old, |
const Ref & | young | ||
) | const |
true if old is some ancestor of young (it does not have to be the root)
Definition at line 88 of file RefHelper.h.
References edm::Ptr< T >::isNonnull().
{ Ref test = young; do { if (test == old) return true; test = parentOrNull(test); } while (test.isNonnull()); return false; }
bool pat::helper::RefHelper< T >::isRoot | ( | const Ref & | ref | ) | const |
Definition at line 83 of file RefHelper.h.
{ return parentOrNull(ref).isNull(); }
RefHelper< T >::Ref pat::helper::RefHelper< T >::parentOrNull | ( | const Ref & | ref | ) | const |
Returns a Ref to the direct parent of "ref", or a null Ref if "ref" is already root.
Definition at line 49 of file RefHelper.h.
References edm::Exception::categoryCode(), alignCSCRings::e, edm::Ptr< T >::id(), and edm::errors::InvalidReference.
{ if (backRefMap_.contains(ref.id())) { try { return backRefMap_[ref]; } catch (edm::Exception &e) { if (e.categoryCode() == edm::errors::InvalidReference) { return Ref(); } else { throw; } } } else { return Ref(); } }
RefHelper< T >::Ref pat::helper::RefHelper< T >::parentOrSelf | ( | const Ref & | ref | ) | const |
Returns a Ref to the direct parent of "ref", or "ref" itself if it's already root.
Definition at line 66 of file RefHelper.h.
References edm::Ptr< T >::isNonnull(), and runTheMatrix::ret.
{ Ref ret = parentOrNull(ref); return ret.isNonnull() ? ret : ref; }
V pat::helper::RefHelper< T >::recursiveLookup | ( | const SomeRef & | ref, |
const edm::ValueMap< V > & | map | ||
) | const |
Recursively looks up map to find something associated to ref, or one of its parents. Throws edm::Exception(edm::errors::InvalidReference) if there's no match
Definition at line 104 of file RefHelper.h.
References edm::Exception::categoryCode(), edm::ValueMap< T >::contains(), alignCSCRings::e, Exception, edm::Ptr< T >::id(), edm::errors::InvalidReference, and edm::Ptr< T >::isNonnull().
{ Ref test(ref); do { if (map.contains(test.id())) { try { return map[test]; } catch (edm::Exception &e) { if (e.categoryCode() != edm::errors::InvalidReference) { throw; } } } test = parentOrNull(test); } while (test.isNonnull()); throw edm::Exception(edm::errors::InvalidReference) << "RefHelper: recursive Lookup failed: neither the specified ref nor any of its parents are in the map.\n"; }
bool pat::helper::RefHelper< T >::sharedAncestor | ( | const Ref & | ref1, |
const Ref & | ref2 | ||
) | const |
true if the two share the same root
Definition at line 98 of file RefHelper.h.
{ return ( ancestorOrSelf(ref1) == ancestorOrSelf(ref2) ); }
const edm::ValueMap< Ref >& pat::helper::RefHelper< T >::backRefMap_ [private] |
Definition at line 45 of file RefHelper.h.