ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
larcfm::ErrorLog Class Reference
Inheritance diagram for larcfm::ErrorLog:
larcfm::ErrorReporter

Public Member Functions

 ErrorLog (const std::string &name)
 
void setFailFast (bool ff)
 
void setConsoleOutput (bool console)
 
void addError (const std::string &msg)
 
void addWarning (const std::string &msg)
 
void addReporter (ErrorReporter &reporter)
 
bool isPositive (const std::string &method, double val)
 
bool isNonNegative (const std::string &method, double val)
 
bool isNonPositive (const std::string &method, double val)
 
bool isLessThan (const std::string &method, double val, double thr)
 
bool isBetween (const std::string &method, double val, double lb, double ub)
 
bool hasError () const
 
bool hasMessage () const
 
std::string getMessage ()
 
std::string getMessageNoClear () const
 
void setName (const std::string &logname)
 

Static Public Member Functions

static void purge ()
 
static void setSizeLimit (int sz)
 

Private Attributes

std::string name
 
std::string message
 
bool has_error
 
bool fail_fast
 
bool console_out
 
int local_purge_flag
 
int size
 

Static Private Attributes

static int global_purge_flag = 0
 
static int limit = 25
 

Constructor & Destructor Documentation

◆ ErrorLog()

larcfm::ErrorLog::ErrorLog ( const std::string &  name)
explicit

Construct a new ErrorLog object. Every message includes the name of this error log.

Parameters
namethe name of this error log

Member Function Documentation

◆ addError()

void larcfm::ErrorLog::addError ( const std::string &  msg)

Indicate that the given error has occurred.

Parameters
msgthe error message

◆ addReporter()

void larcfm::ErrorLog::addReporter ( ErrorReporter reporter)

Add all the errors and warnings from the given ErrorReporter into the current ErrorLog. The given ErrorReporter's status (as indicated by the hasError() and hasMessage() messages) is always clear at the end of this method.

Parameters
reporterthe ErrorReporter to take messages from

◆ addWarning()

void larcfm::ErrorLog::addWarning ( const std::string &  msg)

Indicate that the given warning has occurred.

Parameters
msgthe error message

◆ getMessage()

string larcfm::ErrorLog::getMessage ( )
virtual

Return a string representation of any errors or warnings. Calling this method will clear any messages and reset both the error and warning status to none.

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getMessageNoClear()

string larcfm::ErrorLog::getMessageNoClear ( ) const
virtual

Return a string representation of any errors or warnings. Calling this method will not clear the error or warning status (i.e., hasError() will return the same value before and after this call.)

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ hasError()

bool larcfm::ErrorLog::hasError ( ) const
virtual

Does this object have an error?

Returns
true if there is an error.

Implements larcfm::ErrorReporter.

◆ hasMessage()

bool larcfm::ErrorLog::hasMessage ( ) const
virtual

Does this object have an error or a warning?

Returns
true if there is an error or warning.

Implements larcfm::ErrorReporter.

◆ isBetween()

bool larcfm::ErrorLog::isBetween ( const std::string &  method,
double  val,
double  lb,
double  ub 
)

Checks if a value is between lb and ub. Otherwise, adds an error message and returns false.

Parameters
methodname of method
valvalue
lblower bound
ubupper bound
Returns
true, if value is between upper and lower bound

Checks if a value is between lb and ub. Otherwise, adds an error message and returns false.

◆ isLessThan()

bool larcfm::ErrorLog::isLessThan ( const std::string &  method,
double  val,
double  thr 
)

Checks if a value is less than value in internal units. Otherwise, adds an error message and returns false.

Parameters
methodname of method
valvalue #1
thrvalue #2
Returns
true, if value #1 is less than value #2

Checks if a value is less than value in internal units. Otherwise, adds an error message and returns false.

◆ isNonNegative()

bool larcfm::ErrorLog::isNonNegative ( const std::string &  method,
double  val 
)

Checks if a value is non negative and, in that case, returns true. Otherwise, adds an error message and returns false.

Parameters
methodname of method
valvalue
Returns
true, if value is non-negative

Checks if a value is non negative and, in that case, returns true. Otherwise, adds an error message and returns false.

◆ isNonPositive()

bool larcfm::ErrorLog::isNonPositive ( const std::string &  method,
double  val 
)

Checks if a value is non positive and, in that case, returns true. Otherwise, adds an error message and returns false.

Parameters
methodname of method
valvalue
Returns
true, if value is non-positive

Checks if a value is non positive and, in that case, returns true. Otherwise, adds an error message and returns false.

◆ isPositive()

bool larcfm::ErrorLog::isPositive ( const std::string &  method,
double  val 
)

Checks if a value is positive and, in that case, returns true. Otherwise, adds an error message and returns false.

Parameters
methodname of method
valvalue
Returns
true, if value is positive

Checks if a value is positive and, in that case, returns true. Otherwise, adds an error message and returns false.

◆ purge()

void larcfm::ErrorLog::purge ( )
static

Set a flag that causes all instances to clear their message buffers prior to the next add operation (Note: Java also has an explicit copy constructor). Messages will be preserved if only getMessageNoClear() is called.

◆ setConsoleOutput()

void larcfm::ErrorLog::setConsoleOutput ( bool  console)

If console output is set to true, then every error message and warning is output to the console.

Parameters
consoletrue, if output should go to console.

◆ setFailFast()

void larcfm::ErrorLog::setFailFast ( bool  ff)

If fail fast is true, then when an error is added, the program will terminate.

Parameters
fftrue indicates that the program should terminate when an error is added.

◆ setSizeLimit()

void larcfm::ErrorLog::setSizeLimit ( int  sz)
static

Set this maximum number of messages that can be held in any given ErrorLog

Parameters
sznumber of messages to store per log

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