|
last update 20 Sep 2009 |
|
#include <cvrStatus.h>

Public Member Functions | |
| statusObject () | |
| statusObject (const statusObject &other) | |
| ~statusObject () | |
| statusObject & | copy (const statusObject &other) |
| statusObject & | operator= (const statusObject &other) |
| void | set (const std::string &className, const std::string &str) |
| void | set (const std::string &className, const char *str) |
| const std::string & | get () const |
| statusObject & | operator% (const int data) |
| statusObject & | operator% (const double data) |
| statusObject & | operator% (const std::string &data) |
| statusObject & | operator% (const char *data) |
Static Public Member Functions | |
| static void | setStatusMonitor (statusMonitor &monitor) |
The status::statusObject is an abstraction that allows a flexible formatting of the status strings and a way of knowing that the string has been completed.
When you have a class that inherits from cvs::status the methods of that at class can report errors simply by calling
setStatusString("Invalid arguments detected.");
That method returns an instance of a status::statusObject, which allows appending additional information, but only if the string set through setStatusString has the special tokens %1 to %9. These tokens are then replaced by some information you provide through the operator%.
For instance:
int val = 5; std::string str = "hello"; setStatusString("Val=%1 and the string str=%2")%val%str;
If you wish to delay providing the parameters you can do:
int val = 5; std::string str = " setStatusString("Val val=%1 and the string str=%2"); getStatusObject()%val; getStatusObject()%str;
This is an internal class to encapsulate the operator%. Outside this object, the operator% means modulus, but in the context of error reports it can have its own meaning. If fact, the use of operator% for this task is is inspired (remotely) on one of the boost libraries.
| cvr::status::status::statusObject::statusObject | ( | ) |
Constructor.
| cvr::status::status::statusObject::statusObject | ( | const statusObject & | other | ) |
Copy constructor.
| cvr::status::status::statusObject::~statusObject | ( | ) |
Destructor.
| statusObject& cvr::status::status::statusObject::copy | ( | const statusObject & | other | ) |
Copy another statusObject instance.
| const std::string& cvr::status::status::statusObject::get | ( | ) | const |
Get the current status string.
| statusObject& cvr::status::status::statusObject::operator% | ( | const char * | data | ) |
Fill a const char chain.
| statusObject& cvr::status::status::statusObject::operator% | ( | const std::string & | data | ) |
Fill a std::string argument.
| statusObject& cvr::status::status::statusObject::operator% | ( | const double | data | ) |
Fill a double argument.
| statusObject& cvr::status::status::statusObject::operator% | ( | const int | data | ) |
Fill an integer argument.
| statusObject& cvr::status::status::statusObject::operator= | ( | const statusObject & | other | ) |
Copy another statusObject instance (alias for copy()).
| void cvr::status::status::statusObject::set | ( | const std::string & | className, | |
| const char * | str | |||
| ) |
Set and parse the status string.
| void cvr::status::status::statusObject::set | ( | const std::string & | className, | |
| const std::string & | str | |||
| ) |
Set and parse the status string.
| static void cvr::status::status::statusObject::setStatusMonitor | ( | statusMonitor & | monitor | ) | [static] |
Set Status Monitor.
All functors in the CVR-Lib share this object, which controls what to do when the status string is set or changed. You can set it to throw an exception (see cvr::statusMonitorException), you can redirect the statusString directly to the std::cerr; see cvr::statusMonitorCerr), or you can do nothing but store internally the statusString (see cvr::statusMonitorInactive), which is the default behaviour.
If you implement an own class for this (like and error-log window) ensure that you follow the interface explained in cvr::statusMonitor to avoid memory leaks.
You have to ensure that this method is called only once at a time in your application, especially if you use several threads.