![]() |
Eclipse SUMO - Simulation of Urban MObility
|
#include <MsgHandler.h>
Public Types | |
enum | MsgType { MT_MESSAGE , MT_WARNING , MT_ERROR , MT_DEBUG , MT_GLDEBUG } |
Public Member Functions | |
virtual void | addRetriever (OutputDevice *retriever) |
Adds a further retriever to the instance responsible for a certain msg type. More... | |
virtual void | beginProcessMsg (std::string msg, bool addType=true) |
Begins a process information. More... | |
virtual void | clear (bool resetInformed=true) |
Clears information whether an error occurred previously and print aggregated message summary. More... | |
virtual void | endProcessMsg (std::string msg) |
Ends a process information. More... | |
virtual void | inform (std::string msg, bool addType=true) |
adds a new error to the list More... | |
template<typename T , typename... Targs> | |
void | informf (const std::string &format, T value, Targs... Fargs) |
adds a new formatted message 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... | |
virtual 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 | cleanupOnEnd () |
Removes pending handler. More... | |
static void | enableDebugGLMessages (bool enable) |
enable/disable gl-debug messages More... | |
static void | enableDebugMessages (bool enable) |
enable/disable debug messages More... | |
static MsgHandler * | getDebugInstance () |
Returns the instance to add debug to. More... | |
static MsgHandler * | getErrorInstance () |
Returns the instance to add errors to. More... | |
static MsgHandler * | getGLDebugInstance () |
Returns the instance to add GLdebug 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 () |
init output options More... | |
static void | removeRetrieverFromAllInstances (OutputDevice *out) |
ensure that that given output device is no longer used as retriever by any instance More... | |
static void | setFactory (Factory func) |
Sets the factory function to use for new MsgHandlers. More... | |
static bool | writeDebugGLMessages () |
check whether to enable/disable gl-debug messages More... | |
static bool | writeDebugMessages () |
check whether to enable/disable debug messages More... | |
Protected Member Functions | |
void | _informf (const char *format, std::ostringstream &os) |
template<typename T , typename... Targs> | |
void | _informf (const char *format, std::ostringstream &os, T value, Targs... Fargs) |
adds a new formatted message More... | |
virtual bool | aggregationThresholdReached (const std::string &format) |
std::string | build (const std::string &msg, bool addType) |
Builds the string which includes the mml-message type. More... | |
MsgHandler (MsgType type) | |
standard constructor More... | |
void | setAggregationThreshold (const int thresh) |
virtual | ~MsgHandler () |
destructor More... | |
Private Types | |
typedef MsgHandler *(* | Factory) (MsgType) |
Private Member Functions | |
MsgHandler (const MsgHandler &s)=delete | |
invalid copy constructor More... | |
MsgHandler & | operator= (const MsgHandler &s)=delete |
invalid assignment operator More... | |
Private Attributes | |
std::map< const std::string, int > | myAggregationCount |
count for messages of the same type More... | |
int | myAggregationThreshold |
do not output more messages of the same type if the count exceeds this threshold More... | |
std::vector< OutputDevice * > | 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 whether an output occurred at all More... | |
Static Private Attributes | |
static bool | myAmProcessingProcess = false |
Information whether a process information is printed to cout. More... | |
static MsgHandler * | myDebugInstance = nullptr |
The instance to handle debug. More... | |
static MsgHandler * | myErrorInstance = nullptr |
The instance to handle errors. More... | |
static Factory | myFactory = nullptr |
The function to call for new MsgHandlers, nullptr means use default constructor. More... | |
static MsgHandler * | myGLDebugInstance = nullptr |
The instance to handle glDebug. More... | |
static MsgHandler * | myMessageInstance = nullptr |
The instance to handle normal messages. More... | |
static MsgHandler * | myWarningInstance = nullptr |
The instance to handle warnings. More... | |
static bool | myWriteDebugGLMessages |
static bool | myWriteDebugMessages |
Flag to enable or disable debug GL Functions. More... | |
Definition at line 36 of file MsgHandler.h.
|
private |
Definition at line 57 of file MsgHandler.h.
enum MsgHandler::MsgType |
An enumeration to differ between different types of messages (errors, warning and information)
Definition at line 43 of file MsgHandler.h.
|
protected |
standard constructor
Definition at line 266 of file MsgHandler.cpp.
References addRetriever(), OutputDevice::getDevice(), and MT_MESSAGE.
Referenced by getDebugInstance(), getErrorInstance(), getGLDebugInstance(), getMessageInstance(), and getWarningInstance().
|
protectedvirtual |
destructor
Definition at line 276 of file MsgHandler.cpp.
|
privatedelete |
invalid copy constructor
|
inlineprotected |
Definition at line 191 of file MsgHandler.h.
Referenced by _informf(), and informf().
|
inlineprotected |
|
virtual |
Adds a further retriever to the instance responsible for a certain msg type.
Reimplemented in MsgHandlerSynchronized.
Definition at line 175 of file MsgHandler.cpp.
References isRetriever(), and myRetrievers.
Referenced by MsgHandlerSynchronized::addRetriever(), GNELoadThread::GNELoadThread(), GUILoadThread::GUILoadThread(), GUIRunThread::init(), initOutputOptions(), MsgHandler(), GUIMessageWindow::registerMsgHandlers(), GUILoadThread::run(), and GNELoadThread::run().
|
inlineprotectedvirtual |
Reimplemented in MsgHandlerSynchronized.
Definition at line 187 of file MsgHandler.h.
References myAggregationCount, and myAggregationThreshold.
Referenced by MsgHandlerSynchronized::aggregationThresholdReached(), and informf().
|
virtual |
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.
Reimplemented in MsgHandlerSynchronized.
Definition at line 134 of file MsgHandler.cpp.
References build(), myAmProcessingProcess, myRetrievers, and myWasInformed.
Referenced by MsgHandlerSynchronized::beginProcessMsg().
|
inlineprotected |
Builds the string which includes the mml-message type.
Definition at line 163 of file MsgHandler.h.
References MT_DEBUG, MT_ERROR, MT_GLDEBUG, MT_MESSAGE, MT_WARNING, and myType.
Referenced by beginProcessMsg(), and inform().
|
static |
Removes pending handler.
Definition at line 252 of file MsgHandler.cpp.
References myDebugInstance, myErrorInstance, myGLDebugInstance, myMessageInstance, and myWarningInstance.
Referenced by SystemFrame::close(), GUIRunThread::deleteSim(), and setFactory().
|
virtual |
Clears information whether an error occurred previously and print aggregated message summary.
Reimplemented in MsgHandlerSynchronized.
Definition at line 159 of file MsgHandler.cpp.
References inform(), myAggregationCount, myAggregationThreshold, myWasInformed, and toString().
Referenced by MsgHandlerSynchronized::clear(), SystemFrame::close(), NLBuilder::init(), loadJTRDefinitions(), main(), NBLoadedTLDef::myCompute(), GUILoadThread::run(), GNELoadThread::run(), and XMLSubSys::runParser().
|
static |
enable/disable gl-debug messages
Definition at line 112 of file MsgHandler.cpp.
References myWriteDebugGLMessages.
Referenced by GUIDialog_Options::InputBool::onCmdSetOption(), and GNELoadThread::run().
|
static |
enable/disable debug messages
Definition at line 107 of file MsgHandler.cpp.
References myWriteDebugMessages.
Referenced by GUIDialog_Options::InputBool::onCmdSetOption(), and GNELoadThread::run().
|
virtual |
Ends a process information.
Reimplemented in MsgHandlerSynchronized.
Definition at line 147 of file MsgHandler.cpp.
References myAmProcessingProcess, myRetrievers, and myWasInformed.
Referenced by CHBuilder< E, V >::buildContractionHierarchy(), MsgHandlerSynchronized::endProcessMsg(), and NBHeightMapper::loadIfSet().
|
static |
Returns the instance to add debug to.
Definition at line 89 of file MsgHandler.cpp.
References MsgHandler(), MT_DEBUG, and myDebugInstance.
Referenced by GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add errors to.
Definition at line 80 of file MsgHandler.cpp.
References MsgHandler(), MT_ERROR, and myErrorInstance.
Referenced by NLHandler::addPhase(), MSRouteHandler::addStop(), GNERouteHandler::addStop(), NLBuilder::build(), MSSOTLTrafficLightLogic::checkPhases(), OutputDevice::closeAll(), RORouteHandler::closeFlow(), RORouteHandler::closeVehicle(), ROJTRRouter::compute(), GUIRunThread::deleteSim(), GNELoadThread::GNELoadThread(), GUILoadThread::GUILoadThread(), NLBuilder::init(), GUIRunThread::init(), initOutputOptions(), PCLoaderOSM::loadIfSet(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), LIBSUMO_NAMESPACE::Simulation::loadState(), main(), GUIRunThread::makeStep(), MSPhaseDefinition::MSPhaseDefinition(), ROLoader::openRoutes(), RORouteDef::preComputeCurrentRoute(), ROLoader::processRoutes(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), GNELoadThread::run(), XMLSubSys::runParser(), RONet::saveAndRemoveRoutesUntil(), MSSOTLTrafficLightLogic::setToATargetPhase(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add GLdebug to.
Definition at line 98 of file MsgHandler.cpp.
References MsgHandler(), MT_GLDEBUG, and myGLDebugInstance.
Referenced by GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add normal messages to.
Definition at line 54 of file MsgHandler.cpp.
References MsgHandler(), MT_MESSAGE, myFactory, and myMessageInstance.
Referenced by CHBuilder< E, V >::buildContractionHierarchy(), MSDeterministicHiLevelTrafficLightLogic::decideNextPhase(), MSSwarmTrafficLightLogic::decideNextPhase(), GUIRunThread::deleteSim(), inform(), NLBuilder::init(), GUIRunThread::init(), initOutputOptions(), NBHeightMapper::loadIfSet(), MSSOTLPhaseTrafficLightLogic::MSSOTLPhaseTrafficLightLogic(), MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(), MSSOTLWaveTrafficLightLogic::MSSOTLWaveTrafficLightLogic(), GUIMessageWindow::registerMsgHandlers(), GUILoadThread::run(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
Returns the instance to add warnings to.
Definition at line 67 of file MsgHandler.cpp.
References MsgHandler(), MT_WARNING, myFactory, and myWarningInstance.
Referenced by NLHandler::addPhase(), AStarRouter< E, V >::clone(), CHRouter< E, V >::clone(), DijkstraRouter< E, V >::clone(), SystemFrame::close(), ROJTRRouter::compute(), GUIRunThread::deleteSim(), RailwayRouter< E, V >::ensureInternalRouter(), NLBuilder::init(), GUIRunThread::init(), initOutputOptions(), PCLoaderOSM::loadIfSet(), NBLoadedTLDef::myCompute(), RORouteDef::preComputeCurrentRoute(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), GNELoadThread::run(), RONet::saveAndRemoveRoutesUntil(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), TraCIServer::TraCIServer(), and GUIMessageWindow::unregisterMsgHandlers().
|
virtual |
adds a new error to the list
Reimplemented in MsgHandlerSynchronized.
Definition at line 117 of file MsgHandler.cpp.
References build(), getMessageInstance(), inform(), myAmProcessingProcess, myRetrievers, and myWasInformed.
Referenced by NLHandler::addPhase(), RORouteHandler::addStop(), ROVehicle::addStop(), MSSOTLTrafficLightLogic::checkPhases(), clear(), RORouteHandler::closeFlow(), RORouteHandler::closeRoute(), RORouteHandler::closeRouteDistribution(), RORouteHandler::closeVehicle(), RORouteHandler::closeVehicleTypeDistribution(), AStarRouter< E, V >::compute(), DijkstraRouter< E, V >::compute(), ROJTRRouter::compute(), ROPerson::computeIntermodal(), ROVehicle::computeRoute(), MSDeterministicHiLevelTrafficLightLogic::decideNextPhase(), MSSwarmTrafficLightLogic::decideNextPhase(), RORouteHandler::getJunctionTaz(), inform(), MsgHandlerSynchronized::inform(), informf(), GUIRunThread::init(), main(), GUIRunThread::makeStep(), MSPhaseDefinition::MSPhaseDefinition(), MSSOTLPhaseTrafficLightLogic::MSSOTLPhaseTrafficLightLogic(), MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(), MSSOTLWaveTrafficLightLogic::MSSOTLWaveTrafficLightLogic(), NIXMLConnectionsHandler::myStartElement(), RORouteHandler::myStartElement(), RORouteHandler::openRoute(), RORouteHandler::openRouteDistribution(), RORouteHandler::openVehicleTypeDistribution(), NIXMLConnectionsHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RORouteHandler::parseEdges(), RORouteHandler::parseFromViaTo(), RORouteHandler::parseGeoEdges(), NIXMLConnectionsHandler::parseLaneBound(), SUMORouteHandler::parseStop(), RORouteHandler::parseWalkPositions(), RORouteDef::preComputeCurrentRoute(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), MSSOTLTrafficLightLogic::setToATargetPhase(), and TraCIServer::TraCIServer().
|
inline |
adds a new formatted message
Definition at line 113 of file MsgHandler.h.
References _informf(), aggregationThresholdReached(), gPrecision, and inform().
Referenced by AStarRouter< E, V >::compute(), CHRouter< E, V >::compute(), DijkstraRouter< E, V >::compute(), SUMOAbstractRouter< E, V >::computeLooped(), NIXMLConnectionsHandler::myStartElement(), and NIXMLConnectionsHandler::parseLaneBound().
|
static |
init output options
Definition at line 217 of file MsgHandler.cpp.
References addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), getErrorInstance(), OptionsCont::getInt(), getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), getWarningInstance(), OptionsCont::isSet(), removeRetriever(), and setAggregationThreshold().
Referenced by NLBuilder::init(), main(), GUILoadThread::run(), and GNELoadThread::run().
bool MsgHandler::isRetriever | ( | OutputDevice * | retriever | ) | const |
Returns whether the given output device retrieves messages from the handler.
Definition at line 192 of file MsgHandler.cpp.
References myRetrievers.
Referenced by addRetriever().
|
inline |
Generic output operator.
Definition at line 153 of file MsgHandler.h.
References myRetrievers.
|
privatedelete |
invalid assignment operator
|
virtual |
Removes the retriever from the handler.
Reimplemented in MsgHandlerSynchronized.
Definition at line 183 of file MsgHandler.cpp.
References myRetrievers.
Referenced by GUIRunThread::deleteSim(), initOutputOptions(), MsgHandlerSynchronized::removeRetriever(), removeRetrieverFromAllInstances(), GUILoadThread::run(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
static |
ensure that that given output device is no longer used as retriever by any instance
Definition at line 198 of file MsgHandler.cpp.
References myDebugInstance, myErrorInstance, myGLDebugInstance, myMessageInstance, myWarningInstance, and removeRetriever().
Referenced by OutputDevice::close().
|
inlineprotected |
Definition at line 209 of file MsgHandler.h.
References myAggregationThreshold.
Referenced by initOutputOptions().
|
inlinestatic |
Sets the factory function to use for new MsgHandlers.
Definition at line 61 of file MsgHandler.h.
References cleanupOnEnd(), and myFactory.
Referenced by NLBuilder::init(), and main().
bool MsgHandler::wasInformed | ( | ) | const |
Returns the information whether any messages were added.
Definition at line 281 of file MsgHandler.cpp.
References myWasInformed.
Referenced by ROLoader::processRoutes(), and XMLSubSys::runParser().
|
inlinestatic |
check whether to enable/disable gl-debug messages
Definition at line 94 of file MsgHandler.h.
References myWriteDebugGLMessages.
Referenced by SUMORTree::addAdditionalGLObject(), and SUMORTree::removeAdditionalGLObject().
|
inlinestatic |
check whether to enable/disable debug messages
Definition at line 89 of file MsgHandler.h.
References myWriteDebugMessages.
|
private |
count for messages of the same type
Definition at line 252 of file MsgHandler.h.
Referenced by aggregationThresholdReached(), and clear().
|
private |
do not output more messages of the same type if the count exceeds this threshold
Definition at line 249 of file MsgHandler.h.
Referenced by aggregationThresholdReached(), clear(), and setAggregationThreshold().
|
staticprivate |
Information whether a process information is printed to cout.
Definition at line 239 of file MsgHandler.h.
Referenced by beginProcessMsg(), endProcessMsg(), and inform().
|
staticprivate |
The instance to handle debug.
Definition at line 224 of file MsgHandler.h.
Referenced by cleanupOnEnd(), getDebugInstance(), and removeRetrieverFromAllInstances().
|
staticprivate |
The instance to handle errors.
Definition at line 230 of file MsgHandler.h.
Referenced by cleanupOnEnd(), getErrorInstance(), and removeRetrieverFromAllInstances().
|
staticprivate |
The function to call for new MsgHandlers, nullptr means use default constructor.
Definition at line 221 of file MsgHandler.h.
Referenced by getMessageInstance(), getWarningInstance(), and setFactory().
|
staticprivate |
The instance to handle glDebug.
Definition at line 227 of file MsgHandler.h.
Referenced by cleanupOnEnd(), getGLDebugInstance(), and removeRetrieverFromAllInstances().
|
staticprivate |
The instance to handle normal messages.
Definition at line 236 of file MsgHandler.h.
Referenced by cleanupOnEnd(), getMessageInstance(), and removeRetrieverFromAllInstances().
|
private |
The list of retrievers that shall be informed about new messages or errors.
Definition at line 255 of file MsgHandler.h.
Referenced by addRetriever(), beginProcessMsg(), endProcessMsg(), inform(), isRetriever(), operator<<(), and removeRetriever().
|
private |
|
staticprivate |
The instance to handle warnings.
Definition at line 233 of file MsgHandler.h.
Referenced by cleanupOnEnd(), getWarningInstance(), and removeRetrieverFromAllInstances().
|
private |
information whether an output occurred at all
Definition at line 246 of file MsgHandler.h.
Referenced by beginProcessMsg(), clear(), endProcessMsg(), inform(), and wasInformed().
|
staticprivate |
Definition at line 269 of file MsgHandler.h.
Referenced by enableDebugGLMessages(), and writeDebugGLMessages().
|
staticprivate |
Flag to enable or disable debug GL Functions.
This value is used to show more internal information throught warning messages about certain operations
Definition at line 268 of file MsgHandler.h.
Referenced by enableDebugMessages(), and writeDebugMessages().