BRL-CAD
PeakCounter< T > Class Template Reference

#include <oslexec_pvt.h>

Public Types

typedef T value_t
 

Public Member Functions

 PeakCounter ()
 
void clear ()
 
value_t operator() () const
 
value_t current (void) const
 
value_t requested (void) const
 
value_t peak (void) const
 
const value_t operator= (value_t newval)
 
const value_t operator+= (value_t sz)
 
const value_t operator-= (value_t sz)
 
const value_t operator++ ()
 
const value_t operator++ (int)
 
const value_t operator-- ()
 
const value_t operator-- (int)
 
std::string memstat () const
 

Friends

std::ostream & operator<< (std::ostream &out, const PeakCounter &p)
 

Detailed Description

template<typename T>
class OSL::pvt::PeakCounter< T >

Like an int (of type T), but also internally keeps track of the maximum value is has held, and the total "requested" deltas. You really shouldn't use an unsigned type for T, for two reasons: (1) Our implementation of '-=' will fail; and (2) you actually want to allow the counter to go negative, to detect if you have made a mistake in your bookkeeping by forgetting an allocation.

Definition at line 114 of file oslexec_pvt.h.

Member Typedef Documentation

typedef T value_t

Definition at line 117 of file oslexec_pvt.h.

Constructor & Destructor Documentation

PeakCounter ( )
inline

Definition at line 118 of file oslexec_pvt.h.

Member Function Documentation

void clear ( )
inline

Reset all counts to zero.

Definition at line 121 of file oslexec_pvt.h.

value_t operator() ( ) const
inline

Return the current value.

Definition at line 126 of file oslexec_pvt.h.

value_t current ( void  ) const
inline

Return the current value.

Definition at line 130 of file oslexec_pvt.h.

value_t requested ( void  ) const
inline

Return the sum of all requests.

Definition at line 133 of file oslexec_pvt.h.

value_t peak ( void  ) const
inline

Return the peak value we saw.

Definition at line 136 of file oslexec_pvt.h.

const value_t operator= ( value_t  newval)
inline

Reassign the current value, adjust peak and requested as necessary.

Definition at line 140 of file oslexec_pvt.h.

const value_t operator+= ( value_t  sz)
inline

Add to current value, adjust peak and requested as necessary.

Definition at line 151 of file oslexec_pvt.h.

const value_t operator-= ( value_t  sz)
inline

Subtract from current value

Definition at line 162 of file oslexec_pvt.h.

const value_t operator++ ( )
inline

Definition at line 167 of file oslexec_pvt.h.

const value_t operator++ ( int  )
inline

Definition at line 168 of file oslexec_pvt.h.

const value_t operator-- ( )
inline

Definition at line 169 of file oslexec_pvt.h.

const value_t operator-- ( int  )
inline

Definition at line 170 of file oslexec_pvt.h.

std::string memstat ( ) const
inline

Definition at line 179 of file oslexec_pvt.h.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PeakCounter< T > &  p 
)
friend

Definition at line 172 of file oslexec_pvt.h.


The documentation for this class was generated from the following file: