|
SUMO - Simulation of Urban MObility
|
#include <MsgHandler.h>
Public Types | |
| enum | MsgType { MT_MESSAGE, MT_WARNING, MT_ERROR } |
Public Member Functions | |
| void | addRetriever (OutputDevice *retriever) |
| Adds a further retriever to the instance responsible for a certain msg type. | |
| void | beginProcessMsg (std::string msg, bool addType=true) |
| Begins a process information. | |
| void | clear () |
| Clears information whether an error occured previously. | |
| void | endProcessMsg (std::string msg) |
| Ends a process information. | |
| void | inform (std::string msg, bool addType=true) |
| adds a new error to the list | |
| template<class T > | |
| MsgHandler & | operator<< (const T &t) |
| Generic output operator. | |
| void | progressMsg (std::string msg, bool addType=true) |
| Writes a progress message. | |
| void | removeRetriever (OutputDevice *retriever) |
| Removes the retriever from the. | |
| void | report2cerr (bool value) |
| Sets the information whether stderr shall be used as output device. | |
| void | report2cout (bool value) |
| Sets the information whether stdout shall be used as output device. | |
| bool | wasInformed () const |
| Returns the information whether any messages were added. | |
Static Public Member Functions | |
| static void | assignLock (AbstractMutex *lock) |
| Sets the lock to use The lock will not be deleted. | |
| static void | cleanupOnEnd () |
| Removes pending handler. | |
| static MsgHandler * | getErrorInstance () |
| Returns the instance to add errors to. | |
| static MsgHandler * | getMessageInstance () |
| Returns the instance to add normal messages to. | |
| static MsgHandler * | getWarningInstance () |
| Returns the instance to add warnings to. | |
| static void | initOutputOptions (bool gui=false) |
Protected Member Functions | |
| std::string | build (const std::string &msg, bool addType) |
| Builds the string which includes the mml-message type. | |
Private Types | |
| typedef std::vector < OutputDevice * > | RetrieverVector |
| Definition of the list of retrievers to inform. | |
Private Member Functions | |
| MsgHandler (MsgType type) | |
| standard constructor | |
| MsgHandler (const MsgHandler &s) | |
| MsgHandler & | operator= (const MsgHandler &s) |
| ~MsgHandler () | |
| destructor | |
Private Attributes | |
| bool | myReport2CERR |
| Information whether stderr shall be used as output device, too. | |
| bool | myReport2COUT |
| Information whether stdout shall be used as output device, too. | |
| RetrieverVector | myRetrievers |
| The list of retrievers that shall be informed about new messages or errors. | |
| MsgType | myType |
| The type of the instance. | |
| bool | myWasInformed |
| information wehther an error occured at all | |
Static Private Attributes | |
| static bool | myAmProcessingProcess = false |
| Information whether a process information is printed to cout. | |
| static MsgHandler * | myErrorInstance = 0 |
| The instance to handle errors. | |
| static AbstractMutex * | myLock = 0 |
| The lock if any has to be used The lock will not be deleted. | |
| static MsgHandler * | myMessageInstance = 0 |
| The instance to handle normal messages. | |
| static MsgHandler * | myWarningInstance = 0 |
| The instance to handle warnings. | |
Definition at line 57 of file MsgHandler.h.
typedef std::vector<OutputDevice*> MsgHandler::RetrieverVector [private] |
Definition of the list of retrievers to inform.
Definition at line 208 of file MsgHandler.h.
| enum MsgHandler::MsgType |
An enumeration to differ between different types of messages (errors, warning and information)
| MT_MESSAGE |
The message is only something to show. |
| MT_WARNING |
The message is a warning. |
| MT_ERROR |
The message is an error. |
Definition at line 64 of file MsgHandler.h.
| MsgHandler::MsgHandler | ( | MsgType | type | ) | [private] |
standard constructor
Definition at line 365 of file MsgHandler.cpp.
Referenced by getErrorInstance(), getMessageInstance(), and getWarningInstance().
| MsgHandler::~MsgHandler | ( | ) | [private] |
destructor
Definition at line 370 of file MsgHandler.cpp.
| MsgHandler::MsgHandler | ( | const MsgHandler & | s | ) | [private] |
invalid copy constructor
| void MsgHandler::addRetriever | ( | OutputDevice * | retriever | ) |
Adds a further retriever to the instance responsible for a certain msg type.
Definition at line 225 of file MsgHandler.cpp.
References OptionsCont::exists(), OptionsCont::getBool(), OptionsCont::getOptions(), AbstractMutex::lock(), MT_MESSAGE, MT_WARNING, myLock, myRetrievers, myType, and AbstractMutex::unlock().
Referenced by GUILoadThread::GUILoadThread(), GUIRunThread::init(), initOutputOptions(), and GUILoadThread::run().
| void MsgHandler::assignLock | ( | AbstractMutex * | lock | ) | [static] |
Sets the lock to use The lock will not be deleted.
Definition at line 381 of file MsgHandler.cpp.
References myLock.
Referenced by main().
| void MsgHandler::beginProcessMsg | ( | std::string | msg, |
| bool | addType = true |
||
| ) |
Begins a process information.
When a longer action is started, this method should be used to inform the user about it. There will be no newline printed, but the message handler will be informed that a process message has been begun. If an error occurs, a newline will be printed. After the action has been performed, use endProcessMsg to inform the user about it.
Definition at line 156 of file MsgHandler.cpp.
References build(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myReport2CERR, myReport2COUT, myRetrievers, myWasInformed, and AbstractMutex::unlock().
| std::string MsgHandler::build | ( | const std::string & | msg, |
| bool | addType | ||
| ) | [inline, protected] |
Builds the string which includes the mml-message type.
Definition at line 151 of file MsgHandler.h.
References MT_ERROR, MT_MESSAGE, MT_WARNING, and myType.
Referenced by beginProcessMsg(), inform(), and progressMsg().
| void MsgHandler::cleanupOnEnd | ( | ) | [static] |
Removes pending handler.
Definition at line 349 of file MsgHandler.cpp.
References AbstractMutex::lock(), myErrorInstance, myLock, myMessageInstance, myWarningInstance, and AbstractMutex::unlock().
Referenced by SystemFrame::close(), and GUIRunThread::deleteSim().
| void MsgHandler::clear | ( | ) |
Clears information whether an error occured previously.
Definition at line 213 of file MsgHandler.cpp.
References AbstractMutex::lock(), myLock, myWasInformed, and AbstractMutex::unlock().
Referenced by loadJTRDefinitions(), main(), NBLoadedTLDef::myCompute(), and GUILoadThread::run().
| void MsgHandler::endProcessMsg | ( | std::string | msg | ) |
Ends a process information.
Definition at line 187 of file MsgHandler.cpp.
References AbstractMutex::lock(), myAmProcessingProcess, myLock, myReport2CERR, myReport2COUT, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by NLBuilder::build(), and NLBuilder::load().
| MsgHandler * MsgHandler::getErrorInstance | ( | ) | [static] |
Returns the instance to add errors to.
Definition at line 85 of file MsgHandler.cpp.
References MsgHandler(), MT_ERROR, and myErrorInstance.
Referenced by NLBuilder::build(), RORouteDef_Complete::buildCurrentRoute(), RORDLoader_SUMOBase::closeVehicle(), ROJTRRouter::compute(), RONet::computeRoute(), GUIRunThread::deleteSim(), GUILoadThread::GUILoadThread(), GUIRunThread::init(), GUILoadThread::initOptions(), initOutputOptions(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), main(), ROLoader::makeSingleStep(), GUIRunThread::makeStep(), RORDLoader_TripDefs::myEndElement(), RORDGenerator_ODAmounts::myEndFlowAmountDef(), ROLoader::processRoutesStepWise(), GUILoadThread::run(), XMLSubSys::runParser(), and GUILoadThread::submitEndAndCleanup().
| MsgHandler * MsgHandler::getMessageInstance | ( | ) | [static] |
Returns the instance to add normal messages to.
Definition at line 67 of file MsgHandler.cpp.
References MsgHandler(), MT_MESSAGE, and myMessageInstance.
Referenced by NLBuilder::build(), GUIRunThread::deleteSim(), GUIRunThread::init(), initOutputOptions(), NIVissimConnectionCluster::joinBySameEdges(), NLBuilder::load(), main(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), ODMatrix::write(), and ROLoader::writeStats().
| MsgHandler * MsgHandler::getWarningInstance | ( | ) | [static] |
Returns the instance to add warnings to.
Definition at line 76 of file MsgHandler.cpp.
References MsgHandler(), MT_WARNING, and myWarningInstance.
Referenced by RORouteDef_Complete::buildCurrentRoute(), ROJTRRouter::compute(), RONet::computeRoute(), GUIRunThread::deleteSim(), GUIRunThread::init(), initOutputOptions(), main(), NBLoadedTLDef::myCompute(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), and traci::TraCIServer::TraCIServer().
| void MsgHandler::inform | ( | std::string | msg, |
| bool | addType = true |
||
| ) |
adds a new error to the list
Definition at line 94 of file MsgHandler.cpp.
References build(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myReport2CERR, myReport2COUT, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by RORouteDef_Complete::buildCurrentRoute(), ROJTRRouter::compute(), DijkstraRouterTTBase< E, V, PF >::compute(), DijkstraRouterEffortBase< E, V, PF >::compute(), RONet::computeRoute(), GUILoadThread::initOptions(), main(), GUIRunThread::makeStep(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), GUILoadThread::run(), traci::TraCIServer::TraCIServer(), and NIXMLConnectionsHandler::validateLaneInfo().
| void MsgHandler::initOutputOptions | ( | bool | gui = false | ) | [static] |
Definition at line 313 of file MsgHandler.cpp.
References addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), getErrorInstance(), getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), getWarningInstance(), OptionsCont::isSet(), report2cerr(), and report2cout().
Referenced by AGActivityGen::importInfoCity(), main(), and GUILoadThread::run().
| MsgHandler& MsgHandler::operator<< | ( | const T & | t | ) | [inline] |
Generic output operator.
Definition at line 134 of file MsgHandler.h.
References myReport2CERR, myReport2COUT, and myRetrievers.
| MsgHandler& MsgHandler::operator= | ( | const MsgHandler & | s | ) | [private] |
invalid assignment operator
| void MsgHandler::progressMsg | ( | std::string | msg, |
| bool | addType = true |
||
| ) |
Writes a progress message.
Writes the message and closes it with a (char) 13
Definition at line 125 of file MsgHandler.cpp.
References build(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myReport2CERR, myReport2COUT, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by NIVissimConnectionCluster::joinBySameEdges(), ODMatrix::write(), and ROLoader::writeStats().
| void MsgHandler::removeRetriever | ( | OutputDevice * | retriever | ) |
Removes the retriever from the.
Definition at line 249 of file MsgHandler.cpp.
References OptionsCont::exists(), OptionsCont::getBool(), OptionsCont::getOptions(), AbstractMutex::lock(), MT_MESSAGE, MT_WARNING, myLock, myReport2COUT, myRetrievers, myType, and AbstractMutex::unlock().
Referenced by GUIRunThread::deleteSim(), and GUILoadThread::submitEndAndCleanup().
| void MsgHandler::report2cerr | ( | bool | value | ) |
Sets the information whether stderr shall be used as output device.
Definition at line 293 of file MsgHandler.cpp.
References OptionsCont::exists(), OptionsCont::getBool(), OptionsCont::getOptions(), AbstractMutex::lock(), MT_MESSAGE, MT_WARNING, myLock, myReport2CERR, myReport2COUT, myRetrievers, myType, and AbstractMutex::unlock().
Referenced by initOutputOptions(), main(), and GUILoadThread::run().
| void MsgHandler::report2cout | ( | bool | value | ) |
Sets the information whether stdout shall be used as output device.
Definition at line 273 of file MsgHandler.cpp.
References OptionsCont::exists(), OptionsCont::getBool(), OptionsCont::getOptions(), AbstractMutex::lock(), MT_MESSAGE, MT_WARNING, myLock, myReport2COUT, myRetrievers, myType, and AbstractMutex::unlock().
Referenced by initOutputOptions(), main(), and GUILoadThread::run().
| bool MsgHandler::wasInformed | ( | ) | const |
Returns the information whether any messages were added.
Definition at line 375 of file MsgHandler.cpp.
References myWasInformed.
Referenced by NLBuilder::build(), ROLoader::makeSingleStep(), ROLoader::processRoutesStepWise(), and XMLSubSys::runParser().
bool MsgHandler::myAmProcessingProcess = false [static, private] |
Information whether a process information is printed to cout.
Definition at line 188 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), inform(), and progressMsg().
MsgHandler * MsgHandler::myErrorInstance = 0 [static, private] |
The instance to handle errors.
Definition at line 179 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getErrorInstance().
AbstractMutex * MsgHandler::myLock = 0 [static, private] |
The lock if any has to be used The lock will not be deleted.
Definition at line 192 of file MsgHandler.h.
Referenced by addRetriever(), assignLock(), beginProcessMsg(), cleanupOnEnd(), clear(), endProcessMsg(), inform(), progressMsg(), removeRetriever(), report2cerr(), and report2cout().
MsgHandler * MsgHandler::myMessageInstance = 0 [static, private] |
The instance to handle normal messages.
Definition at line 185 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getMessageInstance().
bool MsgHandler::myReport2CERR [private] |
Information whether stderr shall be used as output device, too.
Definition at line 205 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), inform(), operator<<(), progressMsg(), and report2cerr().
bool MsgHandler::myReport2COUT [private] |
Information whether stdout shall be used as output device, too.
Definition at line 202 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), inform(), operator<<(), progressMsg(), removeRetriever(), report2cerr(), and report2cout().
RetrieverVector MsgHandler::myRetrievers [private] |
The list of retrievers that shall be informed about new messages or errors.
Definition at line 211 of file MsgHandler.h.
Referenced by addRetriever(), beginProcessMsg(), endProcessMsg(), inform(), operator<<(), progressMsg(), removeRetriever(), report2cerr(), and report2cout().
MsgType MsgHandler::myType [private] |
The type of the instance.
Definition at line 196 of file MsgHandler.h.
Referenced by addRetriever(), build(), removeRetriever(), report2cerr(), and report2cout().
MsgHandler * MsgHandler::myWarningInstance = 0 [static, private] |
The instance to handle warnings.
Definition at line 182 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getWarningInstance().
bool MsgHandler::myWasInformed [private] |
information wehther an error occured at all
Definition at line 199 of file MsgHandler.h.
Referenced by beginProcessMsg(), clear(), endProcessMsg(), inform(), progressMsg(), and wasInformed().