ATLAS Offline Software
Loading...
Searching...
No Matches
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.
template<typename Element>
bool operator() (Element *f, Element *s) const
 Compare two pointers.
void warn (const std::type_info &ti, const void *f) const
 Duplicate elements were found; print a warning.

Private Attributes

bool m_quiet
 Quiet flag.

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.

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 }
void warn(const std::type_info &ti, const void *f) const
Duplicate elements were found; print a warning.

◆ 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: