thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
ThePEG::LoopGuard< ExceptionT, void > Class Template Reference

A LoopGuard object can be used to throw an exception if a loop is iterated too many times. More...

#include <LoopGuard.h>

Public Member Functions

 LoopGuard (long maxc=1000000)
 Create a loop guard object which will throw an exception of type ExceptionT, constructed with 'mess' as argument, if the maximum number of iterations is exceeded.
 
void operator() ()
 Increase the iteration count and throw an ExceptionT if the maximum number of iterations is exceeded.
 

Private Member Functions

 LoopGuard ()
 Default constructor is private and not implemented.
 
 LoopGuard (const LoopGuard &)
 Copy constructor is private and not implemented.
 

Private Attributes

long count
 The number of counts so far.
 
long maxCount
 The maximum number of counts allowed.
 

Detailed Description

template<typename ExceptionT>
class ThePEG::LoopGuard< ExceptionT, void >

A LoopGuard object can be used to throw an exception if a loop is iterated too many times.

It is used by constructing an object before the loop giving the maximum number of iterations allowed and a message to be used as argument to the constructor of the exception to be thrown. Inside the loop the parenthesis is called without argument, which will increment and check an internal counter. This specialization is for the case where the exception class cannot be created with a message.

See also
Level

Definition at line 95 of file LoopGuard.h.


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