CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
zmex::ZMerrnoList Class Reference

#include <ZMerrno.h>

Public Member Functions

 ZMerrnoList ()
 
 ~ZMerrnoList ()
 
unsigned int setMax (unsigned int limit)
 
void write (const ZMexception &x)
 
int countSinceCleared () const
 
std::string name (unsigned int k=0) const
 
const ZMexceptionget (unsigned int k=0) const
 
void clear ()
 
void erase ()
 
int count () const
 
unsigned int size () const
 

Detailed Description

Definition at line 57 of file ZMerrno.h.

Constructor & Destructor Documentation

◆ ZMerrnoList()

zmex::ZMerrnoList::ZMerrnoList ( )

◆ ~ZMerrnoList()

zmex::ZMerrnoList::~ZMerrnoList ( )

Definition at line 50 of file ZMerrno.cc.

50 {
51
52 while ( size() > 0 ) {
53 const ZMexception * e = errors_.front();
54 errors_.pop_front();
55 delete const_cast<ZMexception *>( e );
56 }
57
58} // ZMerrnoList::~ZMerrnoList()
unsigned int size() const

Member Function Documentation

◆ clear()

void zmex::ZMerrnoList::clear ( )

◆ count()

int zmex::ZMerrnoList::count ( ) const

◆ countSinceCleared()

int zmex::ZMerrnoList::countSinceCleared ( ) const

◆ erase()

void zmex::ZMerrnoList::erase ( )

Definition at line 130 of file ZMerrno.cc.

130 {
131
132 if ( size() > 0 ) {
133 const ZMexception * e = errors_.back();
134 errors_.pop_back();
135 delete const_cast<ZMexception *>( e );
136 }
137
138} // ZMerrnoList::erase()

◆ get()

const ZMexception * zmex::ZMerrnoList::get ( unsigned int  k = 0) const

Definition at line 95 of file ZMerrno.cc.

95 {
96 // Obtain a const pointer to the exception for the latest-but-k entry
97 // on ZMerrno.
98 // Will be NULL if ZMerrno has been cleared since the last ZMthrow,
99 // and also if k is not less than ZMerrno.size().
100
101 return k < size() ? errors_[size()-1-k]
102 : 0;
103
104} // ZMerrnoList::get()

Referenced by main(), and name().

◆ name()

std::string zmex::ZMerrnoList::name ( unsigned int  k = 0) const

Definition at line 113 of file ZMerrno.cc.

113 {
114 // Obtain the mnemonic name of the latest-but-k exception on ZMerrno
115
116 return k < size() ? get(k)->name()
117 : std::string();
118
119} // ZMerrnoList::name()
const ZMexception * get(unsigned int k=0) const
Definition: ZMerrno.cc:95
virtual std::string name() const
Definition: ZMexception.cc:106

◆ setMax()

unsigned int zmex::ZMerrnoList::setMax ( unsigned int  limit)

Definition at line 147 of file ZMerrno.cc.

147 {
148 // Set the maximum number of exceptions to be kept in the list.
149 // Zero completely disables the ZMerrno mechanism.
150
151 unsigned int oldMax = max_;
152 // If a reduction, you may have to pop some old entries off:
153 while ( newMax < size() ) {
154 const ZMexception * e = errors_.front();
155 errors_.pop_front();
156 delete const_cast<ZMexception *>( e );
157 }
158 max_ = newMax;
159 return oldMax;
160
161} // ZMerrnoList::setMax()

Referenced by main().

◆ size()

unsigned int zmex::ZMerrnoList::size ( ) const

◆ write()

void zmex::ZMerrnoList::write ( const ZMexception x)

Definition at line 67 of file ZMerrno.cc.

67 {
68 // copy an exception onto ZMerrno
69
70 ++count_;
71 ++countSinceCleared_;
72
73 if ( max_ <= 0 ) {
74 return;
75 }
76
77 if ( max_ <= size() ) {
78 // Get rid of the oldest.
79 const ZMexception * e = errors_.front();
80 errors_.pop_front();
81 delete const_cast<ZMexception *>( e );
82 }
83
84 errors_.push_back( x.clone() );
85
86} // ZMerrnoList::write()

Referenced by zmex::ZMthrow_().


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