ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DataModel_detail::CompareAndPrint Class Reference

Helper for remove_duplicates. More...

#include <CompareAndPrint.h>

Collaboration diagram for DataModel_detail::CompareAndPrint:

Public Member Functions

 CompareAndPrint (bool quiet)
 Constructor. More...
 
template<typename Element >
bool operator() (Element *f, Element *s) const
 Compare two pointers. More...
 
void warn (const std::type_info &ti, const void *f) const
 Duplicate elements were found; print a warning. More...
 

Private Attributes

bool m_quiet
 Quiet flag. More...
 

Detailed Description

Helper for remove_duplicates.

Functor to compare two pointers and optionally print a complaint if they're the same.

Definition at line 22 of file CompareAndPrint.h.

Constructor & Destructor Documentation

◆ CompareAndPrint()

DataModel_detail::CompareAndPrint::CompareAndPrint ( bool  quiet)
inline

Constructor.

Parameters
quietIf false, then print a complaint if duplicate pointers are found.

Definition at line 30 of file CompareAndPrint.h.

31  : m_quiet(quiet) {}

Member Function Documentation

◆ operator()()

template<typename Element >
bool DataModel_detail::CompareAndPrint::operator() ( Element *  f,
Element *  s 
) const
inline

Compare two pointers.

Maybe print a complaint if we find a duplicate.

Parameters
fFirst pointer to compare.
sSecond pointer to compare.
Returns
The result of the comparison.

Definition at line 42 of file CompareAndPrint.h.

43  {
44  bool areEq = (f == s);
45  if (!m_quiet && areEq && f != 0)
46  warn (typeid (*f), f);
47  return areEq;
48  }

◆ warn()

void DataModel_detail::CompareAndPrint::warn ( const std::type_info &  ti,
const void *  f 
) const

Duplicate elements were found; print a warning.

Parameters
titype_info for the element.
fThe element pointer.

Definition at line 26 of file CompareAndPrint.cxx.

27 {
28  std::cout << "DataVector ERROR: duplicated pointer found in a DataVector of "
29  << AthContainers_detail::typeinfoName(ti)
30  << " owning its elements! "
31  << std::hex << f << std::dec << std::endl;
32 }

Member Data Documentation

◆ m_quiet

bool DataModel_detail::CompareAndPrint::m_quiet
private

Quiet flag.

Definition at line 62 of file CompareAndPrint.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
quiet
bool quiet
Definition: TrigGlobEffCorrValidation.cxx:190
DataModel_detail::CompareAndPrint::warn
void warn(const std::type_info &ti, const void *f) const
Duplicate elements were found; print a warning.
Definition: CompareAndPrint.cxx:26
DataModel_detail::CompareAndPrint::m_quiet
bool m_quiet
Quiet flag.
Definition: CompareAndPrint.h:62