ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
SubDetHitStatistics::OverflowControlledRef Class Reference

A simple class to retrofit overflow protection into the existing code. More...

#include <SubDetHitStatistics.h>

Collaboration diagram for SubDetHitStatistics::OverflowControlledRef:

Public Member Functions

 OverflowControlledRef (unsigned char &c)
 constructor from a ref to the storage we control More...
 
 operator unsigned int () const
 conversion to a number More...
 
unsigned int value () const
 
OverflowControlledRef operator= (unsigned int rhs)
 protected assignment More...
 
OverflowControlledRef operator++ ()
 protected (prefix) increment More...
 
OverflowControlledRef operator+= (unsigned int rhs)
 protected add-to More...
 

Static Public Attributes

static const unsigned int OVERFLOW_VALUE = 255
 

Private Attributes

unsigned char * m_p
 

Detailed Description

A simple class to retrofit overflow protection into the existing code.

The intention is not to provide a full-blown "tiny int" facility but rather a class that is sufficiently functional to compile existing code in other packages without modifications.

Definition at line 43 of file SubDetHitStatistics.h.

Constructor & Destructor Documentation

◆ OverflowControlledRef()

SubDetHitStatistics::OverflowControlledRef::OverflowControlledRef ( unsigned char &  c)
inline

constructor from a ref to the storage we control

Definition at line 49 of file SubDetHitStatistics.h.

49 : m_p(&c) {}

Member Function Documentation

◆ operator unsigned int()

SubDetHitStatistics::OverflowControlledRef::operator unsigned int ( ) const
inline

conversion to a number

Definition at line 52 of file SubDetHitStatistics.h.

52 { return *m_p; }

◆ operator++()

OverflowControlledRef SubDetHitStatistics::OverflowControlledRef::operator++ ( )
inline

protected (prefix) increment

Definition at line 59 of file SubDetHitStatistics.h.

59 { unsigned int tmp = 1 + *m_p; *m_p = (tmp > OVERFLOW_VALUE) ? OVERFLOW_VALUE : tmp; return *this; }

◆ operator+=()

OverflowControlledRef SubDetHitStatistics::OverflowControlledRef::operator+= ( unsigned int  rhs)
inline

protected add-to

Definition at line 62 of file SubDetHitStatistics.h.

62  {
63  unsigned int tmp = *m_p + rhs;
64  *m_p = ((tmp > OVERFLOW_VALUE)
65  ||(tmp < rhs)/*protection agains overflowing tmp */
66  ) ? OVERFLOW_VALUE : tmp;
67  return *this;
68  }

◆ operator=()

OverflowControlledRef SubDetHitStatistics::OverflowControlledRef::operator= ( unsigned int  rhs)
inline

protected assignment

Definition at line 56 of file SubDetHitStatistics.h.

56 { *m_p = (rhs > OVERFLOW_VALUE) ? OVERFLOW_VALUE : rhs; return *this; }

◆ value()

unsigned int SubDetHitStatistics::OverflowControlledRef::value ( ) const
inline

Definition at line 53 of file SubDetHitStatistics.h.

53 { return *m_p; }

Member Data Documentation

◆ m_p

unsigned char* SubDetHitStatistics::OverflowControlledRef::m_p
private

Definition at line 44 of file SubDetHitStatistics.h.

◆ OVERFLOW_VALUE

const unsigned int SubDetHitStatistics::OverflowControlledRef::OVERFLOW_VALUE = 255
static

Definition at line 46 of file SubDetHitStatistics.h.


The documentation for this class was generated from the following file:
SubDetHitStatistics::OverflowControlledRef::OVERFLOW_VALUE
static const unsigned int OVERFLOW_VALUE
Definition: SubDetHitStatistics.h:46
SubDetHitStatistics::OverflowControlledRef::m_p
unsigned char * m_p
Definition: SubDetHitStatistics.h:44
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
python.compressB64.c
def c
Definition: compressB64.py:93