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 | removeRetriever (OutputDevice *retriever) |
Removes the retriever from the. | |
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 () |
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 | |
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 52 of file MsgHandler.h.
|
private |
Definition of the list of retrievers to inform.
Definition at line 178 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 59 of file MsgHandler.h.
|
private |
standard constructor
Definition at line 254 of file MsgHandler.cpp.
References addRetriever(), OutputDevice::getDevice(), and MT_MESSAGE.
Referenced by getErrorInstance(), getMessageInstance(), and getWarningInstance().
|
private |
destructor
Definition at line 264 of file MsgHandler.cpp.
|
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 161 of file MsgHandler.cpp.
References AbstractMutex::lock(), myLock, myRetrievers, and AbstractMutex::unlock().
Referenced by GUILoadThread::GUILoadThread(), GUIRunThread::init(), initOutputOptions(), MsgHandler(), GUIMessageWindow::registerMsgHandlers(), and GUILoadThread::run().
|
static |
Sets the lock to use The lock will not be deleted.
Definition at line 275 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 112 of file MsgHandler.cpp.
References build(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().
|
inlineprotected |
Builds the string which includes the mml-message type.
Definition at line 127 of file MsgHandler.h.
References MT_ERROR, MT_MESSAGE, MT_WARNING, and myType.
Referenced by beginProcessMsg(), and inform().
|
static |
Removes pending handler.
Definition at line 238 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 149 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 131 of file MsgHandler.cpp.
References AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by NLBuilder::build(), and NLBuilder::load().
|
static |
Returns the instance to add errors to.
Definition at line 80 of file MsgHandler.cpp.
References MsgHandler(), MT_ERROR, and myErrorInstance.
Referenced by NLBuilder::build(), RORouteHandler::closeVehicle(), ROJTRRouter::compute(), RONet::computeRoute(), GUIRunThread::deleteSim(), GUILoadThread::GUILoadThread(), GUIRunThread::init(), GUILoadThread::initOptions(), initOutputOptions(), PCLoaderOSM::loadIfSet(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), main(), GUIRunThread::makeStep(), ROLoader::openRoutes(), ROLoader::processRoutes(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), XMLSubSys::runParser(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add normal messages to.
Definition at line 62 of file MsgHandler.cpp.
References MsgHandler(), MT_MESSAGE, and myMessageInstance.
Referenced by NLBuilder::build(), GUIRunThread::deleteSim(), inform(), GUIRunThread::init(), initOutputOptions(), NLBuilder::load(), GUIMessageWindow::registerMsgHandlers(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add warnings to.
Definition at line 71 of file MsgHandler.cpp.
References MsgHandler(), MT_WARNING, and myWarningInstance.
Referenced by ROJTRRouter::compute(), RONet::computeRoute(), GUIRunThread::deleteSim(), GUIRunThread::init(), initOutputOptions(), PCLoaderOSM::loadIfSet(), NBLoadedTLDef::myCompute(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), traci::TraCIServer::TraCIServer(), and GUIMessageWindow::unregisterMsgHandlers().
void MsgHandler::inform | ( | std::string | msg, |
bool | addType = true |
||
) |
adds a new error to the list
Definition at line 89 of file MsgHandler.cpp.
References build(), getMessageInstance(), inform(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by RORouteHandler::addStop(), RORouteHandler::closeFlow(), RORouteHandler::closeRoute(), RORouteHandler::closeRouteDistribution(), RORouteHandler::closeVehicle(), RORouteHandler::closeVehicleTypeDistribution(), ROJTRRouter::compute(), DijkstraRouterTTBase< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), DijkstraRouterEffortBase< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), AStarRouterTTBase< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), RONet::computeRoute(), inform(), GUILoadThread::initOptions(), main(), GUIRunThread::makeStep(), NIXMLConnectionsHandler::myStartElement(), RORouteHandler::openRoute(), RORouteHandler::openRouteDistribution(), NIXMLConnectionsHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RORouteHandler::parseEdges(), RORouteHandler::parseFromTo(), NIXMLConnectionsHandler::parseLaneBound(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), traci::TraCIServer::TraCIServer(), and NIXMLConnectionsHandler::validateLaneInfo().
|
static |
Definition at line 193 of file MsgHandler.cpp.
References addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), getErrorInstance(), getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), getWarningInstance(), OptionsCont::isSet(), and removeRetriever().
Referenced by main(), and GUILoadThread::run().
|
inline |
Generic output operator.
Definition at line 117 of file MsgHandler.h.
References myRetrievers.
|
private |
invalid assignment operator
void MsgHandler::removeRetriever | ( | OutputDevice * | retriever | ) |
Removes the retriever from the.
Definition at line 177 of file MsgHandler.cpp.
References AbstractMutex::lock(), myLock, myRetrievers, and AbstractMutex::unlock().
Referenced by GUIRunThread::deleteSim(), initOutputOptions(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
bool MsgHandler::wasInformed | ( | ) | const |
Returns the information whether any messages were added.
Definition at line 269 of file MsgHandler.cpp.
References myWasInformed.
Referenced by NLBuilder::build(), ROLoader::openRoutes(), ROLoader::processRoutes(), and XMLSubSys::runParser().
|
staticprivate |
Information whether a process information is printed to cout.
Definition at line 164 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), and inform().
|
staticprivate |
The instance to handle errors.
Definition at line 155 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getErrorInstance().
|
staticprivate |
The lock if any has to be used The lock will not be deleted.
Definition at line 168 of file MsgHandler.h.
Referenced by addRetriever(), assignLock(), beginProcessMsg(), cleanupOnEnd(), clear(), endProcessMsg(), inform(), and removeRetriever().
|
staticprivate |
The instance to handle normal messages.
Definition at line 161 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getMessageInstance().
|
private |
The list of retrievers that shall be informed about new messages or errors.
Definition at line 181 of file MsgHandler.h.
Referenced by addRetriever(), beginProcessMsg(), endProcessMsg(), inform(), operator<<(), and removeRetriever().
|
private |
|
staticprivate |
The instance to handle warnings.
Definition at line 158 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getWarningInstance().
|
private |
information wehther an error occured at all
Definition at line 175 of file MsgHandler.h.
Referenced by beginProcessMsg(), clear(), endProcessMsg(), inform(), and wasInformed().