CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
pat::helper::RefHelper< T > Class Template Reference

#include <RefHelper.h>

Public Types

typedef edm::Ptr< TRef
 

Public Member Functions

template<typename V , typename SomeRef >
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". More...
 
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) More...
 
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. More...
 
Ref parentOrSelf (const Ref &ref) const
 Returns a Ref to the direct parent of "ref", or "ref" itself if it's already root. More...
 
template<typename V , typename SomeRef >
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. More...
 
bool sharedAncestor (const Ref &ref1, const Ref &ref2) const
 true if the two share the same root More...
 

Private Attributes

const edm::ValueMap< Ref > & backRefMap_
 

Detailed Description

template<typename T>
class pat::helper::RefHelper< T >

Definition at line 10 of file RefHelper.h.

Member Typedef Documentation

template<typename T >
typedef edm::Ptr<T> pat::helper::RefHelper< T >::Ref

Definition at line 12 of file RefHelper.h.

Constructor & Destructor Documentation

template<typename T >
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.

15 : backRefMap_(backRefMap) { }
const edm::ValueMap< Ref > & backRefMap_
Definition: RefHelper.h:45

Member Function Documentation

template<typename T >
template<typename V , typename SomeRef >
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.

124  {
125  Ref tref(ref);
126  return map[ancestorOrSelf(tref)];
127 }
edm::Ptr< T > Ref
Definition: RefHelper.h:12
Ref ancestorOrSelf(const Ref &ref) const
Climbs back the Ref chain and returns the root of the branch starting from &quot;ref&quot;. ...
Definition: RefHelper.h:72
template<typename T >
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(), runTheMatrix::ret, and ctpps_dqm_sourceclient-live_cfg::test.

72  {
73  Ref ret = ref;
74  do {
75  Ref test = parentOrNull(ret);
76  if (test.isNull()) return ret;
77  ret = test;
78  } while (true);
79 }
tuple ret
prodAgent to be discontinued
edm::Ptr< T > Ref
Definition: RefHelper.h:12
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of &quot;ref&quot;, or a null Ref if &quot;ref&quot; is already root.
Definition: RefHelper.h:49
template<typename T >
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(), and ctpps_dqm_sourceclient-live_cfg::test.

88  {
89  Ref test = young;
90  do {
91  if (test == old) return true;
92  test = parentOrNull(test);
93  } while (test.isNonnull());
94  return false;
95 }
edm::Ptr< T > Ref
Definition: RefHelper.h:12
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of &quot;ref&quot;, or a null Ref if &quot;ref&quot; is already root.
Definition: RefHelper.h:49
template<typename T >
bool pat::helper::RefHelper< T >::isRoot ( const Ref ref) const

Definition at line 83 of file RefHelper.h.

83  {
84  return parentOrNull(ref).isNull();
85 }
bool isNull() const
Checks for null.
Definition: Ptr.h:165
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of &quot;ref&quot;, or a null Ref if &quot;ref&quot; is already root.
Definition: RefHelper.h:49
template<typename T >
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.

49  {
50  if (backRefMap_.contains(ref.id())) {
51  try {
52  return backRefMap_[ref];
53  } catch (edm::Exception &e) {
55  return Ref();
56  } else {
57  throw;
58  }
59  }
60  } else {
61  return Ref();
62  }
63 }
Code categoryCode() const
Definition: EDMException.h:93
edm::Ptr< T > Ref
Definition: RefHelper.h:12
const edm::ValueMap< Ref > & backRefMap_
Definition: RefHelper.h:45
template<typename T >
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.

66  {
67  Ref ret = parentOrNull(ref);
68  return ret.isNonnull() ? ret : ref;
69 }
tuple ret
prodAgent to be discontinued
edm::Ptr< T > Ref
Definition: RefHelper.h:12
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of &quot;ref&quot;, or a null Ref if &quot;ref&quot; is already root.
Definition: RefHelper.h:49
template<typename T >
template<typename V , typename SomeRef >
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, edm::Ptr< T >::isNonnull(), and ctpps_dqm_sourceclient-live_cfg::test.

104  {
105  Ref test(ref);
106  do {
107  if (map.contains(test.id())) {
108  try {
109  return map[test];
110  } catch (edm::Exception &e) {
112  throw;
113  }
114  }
115  }
117  } while (test.isNonnull());
119  "RefHelper: recursive Lookup failed: neither the specified ref nor any of its parents are in the map.\n";
120 }
Code categoryCode() const
Definition: EDMException.h:93
edm::Ptr< T > Ref
Definition: RefHelper.h:12
bool contains(ProductID id) const
Definition: ValueMap.h:154
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of &quot;ref&quot;, or a null Ref if &quot;ref&quot; is already root.
Definition: RefHelper.h:49
template<typename T >
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.

98  {
99  return ( ancestorOrSelf(ref1) == ancestorOrSelf(ref2) );
100 }
Ref ancestorOrSelf(const Ref &ref) const
Climbs back the Ref chain and returns the root of the branch starting from &quot;ref&quot;. ...
Definition: RefHelper.h:72

Member Data Documentation

template<typename T >
const edm::ValueMap< Ref >& pat::helper::RefHelper< T >::backRefMap_
private

Definition at line 45 of file RefHelper.h.