![]() |
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. More... | |
void | beginProcessMsg (std::string msg, bool addType=true) |
Begins a process information. More... | |
void | clear () |
Clears information whether an error occured previously. More... | |
void | endProcessMsg (std::string msg) |
Ends a process information. More... | |
void | inform (std::string msg, bool addType=true) |
adds a new error to the list More... | |
bool | isRetriever (OutputDevice *retriever) const |
Returns whether the given output device retrieves messages from the handler. More... | |
template<class T > | |
MsgHandler & | operator<< (const T &t) |
Generic output operator. More... | |
void | removeRetriever (OutputDevice *retriever) |
Removes the retriever from the handler. More... | |
bool | wasInformed () const |
Returns the information whether any messages were added. More... | |
Static Public Member Functions | |
static void | assignLock (AbstractMutex *lock) |
Sets the lock to use The lock will not be deleted. More... | |
static void | cleanupOnEnd () |
Removes pending handler. More... | |
static MsgHandler * | getErrorInstance () |
Returns the instance to add errors to. More... | |
static MsgHandler * | getMessageInstance () |
Returns the instance to add normal messages to. More... | |
static MsgHandler * | getWarningInstance () |
Returns the instance to add warnings to. More... | |
static void | initOutputOptions () |
Protected Member Functions | |
std::string | build (const std::string &msg, bool addType) |
Builds the string which includes the mml-message type. More... | |
Private Types | |
typedef std::vector< OutputDevice * > | RetrieverVector |
Definition of the list of retrievers to inform. More... | |
Private Member Functions | |
MsgHandler (MsgType type) | |
standard constructor More... | |
MsgHandler (const MsgHandler &s) | |
MsgHandler & | operator= (const MsgHandler &s) |
~MsgHandler () | |
destructor More... | |
Private Attributes | |
RetrieverVector | myRetrievers |
The list of retrievers that shall be informed about new messages or errors. More... | |
MsgType | myType |
The type of the instance. More... | |
bool | myWasInformed |
information wehther an error occured at all More... | |
Static Private Attributes | |
static bool | myAmProcessingProcess = false |
Information whether a process information is printed to cout. More... | |
static MsgHandler * | myErrorInstance = 0 |
The instance to handle errors. More... | |
static AbstractMutex * | myLock = 0 |
The lock if any has to be used The lock will not be deleted. More... | |
static MsgHandler * | myMessageInstance = 0 |
The instance to handle normal messages. More... | |
static MsgHandler * | myWarningInstance = 0 |
The instance to handle warnings. More... | |
Definition at line 52 of file MsgHandler.h.
|
private |
Definition of the list of retrievers to inform.
Definition at line 181 of file MsgHandler.h.
enum MsgHandler::MsgType |
An enumeration to differ between different types of messages (errors, warning and information)
Enumerator | |
---|---|
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 253 of file MsgHandler.cpp.
References addRetriever(), OutputDevice::getDevice(), and MT_MESSAGE.
Referenced by build(), getErrorInstance(), getMessageInstance(), and getWarningInstance().
|
private |
|
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 156 of file MsgHandler.cpp.
References isRetriever(), AbstractMutex::lock(), myLock, myRetrievers, and AbstractMutex::unlock().
Referenced by GNELoadThread::GNELoadThread(), GUILoadThread::GUILoadThread(), GUIRunThread::init(), initOutputOptions(), MsgHandler(), GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), and GUILoadThread::run().
|
static |
Sets the lock to use The lock will not be deleted.
Definition at line 274 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 107 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 130 of file MsgHandler.h.
References MsgHandler(), MT_ERROR, MT_MESSAGE, MT_WARNING, myType, and ~MsgHandler().
Referenced by beginProcessMsg(), and inform().
|
static |
Removes pending handler.
Definition at line 237 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 144 of file MsgHandler.cpp.
References AbstractMutex::lock(), myLock, myWasInformed, and AbstractMutex::unlock().
Referenced by NLBuilder::init(), loadJTRDefinitions(), main(), NBLoadedTLDef::myCompute(), GNELoadThread::run(), and GUILoadThread::run().
void MsgHandler::endProcessMsg | ( | std::string | msg | ) |
Ends a process information.
Definition at line 126 of file MsgHandler.cpp.
References AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by CHBuilder< E, V >::buildContractionHierarchy(), and NBHeightMapper::loadIfSet().
|
static |
Returns the instance to add errors to.
Definition at line 75 of file MsgHandler.cpp.
References MsgHandler(), MT_ERROR, and myErrorInstance.
Referenced by NLHandler::addPhase(), MSRouteHandler::addStop(), NLBuilder::build(), MSSOTLTrafficLightLogic::checkPhases(), OutputDevice::closeAll(), RORouteHandler::closeFlow(), RORouteHandler::closeVehicle(), ROJTRRouter::compute(), GUIRunThread::deleteSim(), GNELoadThread::GNELoadThread(), GUILoadThread::GUILoadThread(), GUIRunThread::init(), NLBuilder::init(), initOutputOptions(), PCLoaderOSM::loadIfSet(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), main(), GUIRunThread::makeStep(), MSPhaseDefinition::MSPhaseDefinition(), ROLoader::openRoutes(), RORouteDef::preComputeCurrentRoute(), ROLoader::processRoutes(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GNELoadThread::run(), GUILoadThread::run(), XMLSubSys::runParser(), RONet::saveAndRemoveRoutesUntil(), MSSOTLTrafficLightLogic::setToATargetPhase(), GUILoadThread::submitEndAndCleanup(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add normal messages to.
Definition at line 57 of file MsgHandler.cpp.
References MsgHandler(), MT_MESSAGE, and myMessageInstance.
Referenced by CHBuilder< E, V >::buildContractionHierarchy(), MSDeterministicHiLevelTrafficLightLogic::decideNextPhase(), MSSwarmTrafficLightLogic::decideNextPhase(), GUIRunThread::deleteSim(), inform(), GUIRunThread::init(), NLBuilder::init(), initOutputOptions(), NBHeightMapper::loadIfSet(), MSSOTLPhaseTrafficLightLogic::MSSOTLPhaseTrafficLightLogic(), MSSOTLPlatoonTrafficLightLogic::MSSOTLPlatoonTrafficLightLogic(), MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(), MSSOTLRequestTrafficLightLogic::MSSOTLRequestTrafficLightLogic(), MSSOTLWaveTrafficLightLogic::MSSOTLWaveTrafficLightLogic(), GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add warnings to.
Definition at line 66 of file MsgHandler.cpp.
References MsgHandler(), MT_WARNING, and myWarningInstance.
Referenced by NLHandler::addPhase(), DijkstraRouter< IntermodalEdge< E, L, N, V >, IntermodalTrip< E, N, V >, prohibited_withPermissions< IntermodalEdge< E, L, N, V >, IntermodalTrip< E, N, V > > >::clone(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::clone(), CHRouter< E, V, PF >::clone(), ROJTRRouter::compute(), GUIRunThread::deleteSim(), GUIRunThread::init(), NLBuilder::init(), initOutputOptions(), PCLoaderOSM::loadIfSet(), NBLoadedTLDef::myCompute(), RORouteDef::preComputeCurrentRoute(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GNELoadThread::run(), GUILoadThread::run(), RONet::saveAndRemoveRoutesUntil(), GUILoadThread::submitEndAndCleanup(), GNELoadThread::submitEndAndCleanup(), TraCIServer::TraCIServer(), and GUIMessageWindow::unregisterMsgHandlers().
void MsgHandler::inform | ( | std::string | msg, |
bool | addType = true |
||
) |
adds a new error to the list
Definition at line 84 of file MsgHandler.cpp.
References build(), getMessageInstance(), inform(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().
Referenced by RORouteHandler::addPersonTrip(), NLHandler::addPhase(), ROVehicle::addStop(), RORouteHandler::addStop(), MSSOTLTrafficLightLogic::checkPhases(), RORouteHandler::closeFlow(), RORouteHandler::closeRoute(), RORouteHandler::closeRouteDistribution(), RORouteHandler::closeVehicle(), RORouteHandler::closeVehicleTypeDistribution(), ROJTRRouter::compute(), DijkstraRouter< IntermodalEdge< E, L, N, V >, IntermodalTrip< E, N, V >, prohibited_withPermissions< IntermodalEdge< E, L, N, V >, IntermodalTrip< E, N, V > > >::compute(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), CHRouter< E, V, PF >::compute(), ROPerson::computeIntermodal(), ROVehicle::computeRoute(), MSDeterministicHiLevelTrafficLightLogic::decideNextPhase(), MSSwarmTrafficLightLogic::decideNextPhase(), inform(), GUIRunThread::init(), main(), GUIRunThread::makeStep(), MSPhaseDefinition::MSPhaseDefinition(), MSSOTLPhaseTrafficLightLogic::MSSOTLPhaseTrafficLightLogic(), MSSOTLPlatoonTrafficLightLogic::MSSOTLPlatoonTrafficLightLogic(), MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(), MSSOTLRequestTrafficLightLogic::MSSOTLRequestTrafficLightLogic(), MSSOTLWaveTrafficLightLogic::MSSOTLWaveTrafficLightLogic(), NIXMLConnectionsHandler::myStartElement(), RORouteHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), PCLoaderOSM::RelationsHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), RORouteHandler::openRoute(), RORouteHandler::openRouteDistribution(), RORouteHandler::openVehicleTypeDistribution(), NIXMLConnectionsHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RORouteHandler::parseEdges(), RORouteHandler::parseFromViaTo(), NIXMLConnectionsHandler::parseLaneBound(), SUMORouteHandler::parseStop(), RORouteDef::preComputeCurrentRoute(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), MSSOTLTrafficLightLogic::setToATargetPhase(), and TraCIServer::TraCIServer().
|
static |
Definition at line 192 of file MsgHandler.cpp.
References addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), getErrorInstance(), getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), getWarningInstance(), OptionsCont::isSet(), and removeRetriever().
Referenced by NLBuilder::init(), main(), GNELoadThread::run(), and GUILoadThread::run().
bool MsgHandler::isRetriever | ( | OutputDevice * | retriever | ) | const |
Returns whether the given output device retrieves messages from the handler.
Definition at line 186 of file MsgHandler.cpp.
References myRetrievers.
Referenced by addRetriever(), and OutputDevice::closeAll().
|
inline |
Generic output operator.
Definition at line 120 of file MsgHandler.h.
References myRetrievers.
|
private |
invalid assignment operator
void MsgHandler::removeRetriever | ( | OutputDevice * | retriever | ) |
Removes the retriever from the handler.
Definition at line 170 of file MsgHandler.cpp.
References AbstractMutex::lock(), myLock, myRetrievers, and AbstractMutex::unlock().
Referenced by GUIRunThread::deleteSim(), initOutputOptions(), GUILoadThread::run(), GUILoadThread::submitEndAndCleanup(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
bool MsgHandler::wasInformed | ( | ) | const |
Returns the information whether any messages were added.
Definition at line 268 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 167 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), and inform().
|
staticprivate |
The instance to handle errors.
Definition at line 158 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 171 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 164 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 184 of file MsgHandler.h.
Referenced by addRetriever(), beginProcessMsg(), endProcessMsg(), inform(), isRetriever(), operator<<(), and removeRetriever().
|
private |
|
staticprivate |
The instance to handle warnings.
Definition at line 161 of file MsgHandler.h.
Referenced by cleanupOnEnd(), and getWarningInstance().
|
private |
information wehther an error occured at all
Definition at line 178 of file MsgHandler.h.
Referenced by beginProcessMsg(), clear(), endProcessMsg(), inform(), and wasInformed().