Eclipse SUMO - Simulation of Urban MObility
|
#include <MsgHandlerSynchronized.h>
Public Types | |
enum class | MsgType { MT_MESSAGE , MT_WARNING , MT_ERROR , MT_DEBUG , MT_GLDEBUG } |
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 (bool resetInformed=true) |
Clears information whether an error occurred previously. | |
void | endProcessMsg (std::string msg) |
Ends a process information. | |
virtual void | endProcessMsg2 (bool success, long duration=-1) |
Ends a process information with predefined messages. | |
void | inform (std::string msg, bool addType=true) |
adds a new error to the list | |
template<typename T , typename... Targs> | |
void | informf (const std::string &format, T value, Targs... Fargs) |
adds a new formatted message | |
bool | isRetriever (OutputDevice *retriever) const |
Returns whether the given output device retrieves messages from the handler. | |
template<class T > | |
MsgHandler & | operator<< (const T &t) |
Generic output operator. | |
void | removeRetriever (OutputDevice *retriever) |
Removes the retriever from the handler. | |
bool | wasInformed () const |
Returns the information whether any messages were added. | |
Static Public Member Functions | |
static void | cleanupOnEnd () |
Removes pending handler. | |
static MsgHandler * | create (MsgType type) |
static void | enableDebugGLMessages (bool enable) |
enable/disable gl-debug messages | |
static void | enableDebugMessages (bool enable) |
enable/disable debug messages | |
static MsgHandler * | getDebugInstance () |
Returns the instance to add debug to. | |
static MsgHandler * | getErrorInstance () |
Returns the instance to add errors to. | |
static MsgHandler * | getGLDebugInstance () |
Returns the instance to add GLdebug 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 () |
init output options | |
static std::string | insertLineBreaks (std::string msg, int lineWidth) |
reformats a long string to contain newline after a certain line length in px (depending on the current font) | |
static void | removeRetrieverFromAllInstances (OutputDevice *out) |
ensure that that given output device is no longer used as retriever by any instance | |
static void | setFactory (Factory func) |
Sets the factory function to use for new MsgHandlers. | |
static void | setupI18n (const std::string &locale="") |
set up gettext stuff | |
static bool | writeDebugGLMessages () |
check whether to enable/disable gl-debug messages | |
static bool | writeDebugMessages () |
check whether to enable/disable debug messages | |
Protected Member Functions | |
bool | aggregationThresholdReached (const std::string &format) |
std::string | build (const std::string &msg, bool addType) |
Builds the string which includes the mml-message type. | |
std::string | buildProcessIdPrefix (void) const |
std::string | buildTimestampPrefix (void) const |
void | setAggregationThreshold (const int thresh) |
Private Types | |
typedef MsgHandler *(* | Factory) (MsgType) |
Private Member Functions | |
MsgHandlerSynchronized (const MsgHandlerSynchronized &s)=delete | |
invalid copy constructor | |
MsgHandlerSynchronized (MsgType type) | |
standard constructor | |
MsgHandlerSynchronized & | operator= (const MsgHandlerSynchronized &s)=delete |
invalid assignment operator | |
~MsgHandlerSynchronized () | |
destructor | |
Private Attributes | |
std::map< const std::string, int > | myAggregationCount |
count for messages of the same type | |
int | myAggregationThreshold |
do not output more messages of the same type if the count exceeds this threshold | |
std::vector< std::string > | myInitialMessages |
storage for initial messages | |
FXMutex | myLock |
The lock for synchronizing all outputs using handlers of this class. | |
std::vector< OutputDevice * > | myRetrievers |
The list of retrievers that shall be informed about new messages or errors. | |
MsgType | myType |
The type of the instance. | |
bool | myWasInformed |
information whether an output occurred at all | |
Static Private Attributes | |
static bool | myAmProcessingProcess = false |
Information whether a process information is printed to cout. | |
static MsgHandler * | myDebugInstance = nullptr |
The instance to handle debug. | |
static MsgHandler * | myErrorInstance = nullptr |
The instance to handle errors. | |
static std::string | myErrorPrefix = "Error: " |
The possibly translated error prefix (mainly for speedup) | |
static Factory | myFactory = nullptr |
The function to call for new MsgHandlers, nullptr means use default constructor. | |
static MsgHandler * | myGLDebugInstance = nullptr |
The instance to handle glDebug. | |
static MsgHandler * | myMessageInstance = nullptr |
The instance to handle normal messages. | |
static MsgHandler * | myWarningInstance = nullptr |
The instance to handle warnings. | |
static std::string | myWarningPrefix = "Warning: " |
The possibly translated warning prefix (mainly for speedup) | |
static bool | myWriteDebugGLMessages = false |
Flag to enable or disable GL specific debug output. | |
static bool | myWriteDebugMessages = false |
Flag to enable or disable debug output. | |
static bool | myWriteProcessId = false |
Whether to prefix every message with the process id. | |
static bool | myWriteTimestamps = false |
Whether to prefix every message with a time stamp. | |
Definition at line 46 of file MsgHandlerSynchronized.h.
|
privateinherited |
Definition at line 60 of file MsgHandler.h.
|
stronginherited |
An enumeration to differ between different types of messages (errors, warning and information)
Definition at line 46 of file MsgHandler.h.
|
inlineprivate |
standard constructor
Definition at line 102 of file MsgHandlerSynchronized.h.
|
inlineprivate |
destructor
Definition at line 107 of file MsgHandlerSynchronized.h.
|
privatedelete |
invalid copy constructor
|
inlinevirtual |
Adds a further retriever to the instance responsible for a certain msg type.
Reimplemented from MsgHandler.
Definition at line 83 of file MsgHandlerSynchronized.h.
References MsgHandler::addRetriever(), and myLock.
|
inlineprotectedvirtual |
Reimplemented from MsgHandler.
Definition at line 95 of file MsgHandlerSynchronized.h.
References MsgHandler::aggregationThresholdReached(), and myLock.
|
inlinevirtual |
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 from MsgHandler.
Definition at line 65 of file MsgHandlerSynchronized.h.
References MsgHandler::beginProcessMsg(), and myLock.
|
inlineprotectedinherited |
Builds the string which includes the mml-message type.
Definition at line 176 of file MsgHandler.h.
References MsgHandler::buildProcessIdPrefix(), MsgHandler::buildTimestampPrefix(), MsgHandler::MT_DEBUG, MsgHandler::MT_ERROR, MsgHandler::MT_GLDEBUG, MsgHandler::MT_MESSAGE, MsgHandler::MT_WARNING, MsgHandler::myErrorPrefix, MsgHandler::myType, MsgHandler::myWarningPrefix, MsgHandler::myWriteProcessId, and MsgHandler::myWriteTimestamps.
Referenced by MsgHandler::beginProcessMsg(), and MsgHandler::inform().
|
protectedinherited |
Definition at line 388 of file MsgHandler.cpp.
Referenced by MsgHandler::build().
|
protectedinherited |
Definition at line 374 of file MsgHandler.cpp.
Referenced by MsgHandler::build().
|
staticinherited |
Removes pending handler.
Definition at line 359 of file MsgHandler.cpp.
References MsgHandler::myDebugInstance, MsgHandler::myErrorInstance, MsgHandler::myGLDebugInstance, MsgHandler::myMessageInstance, and MsgHandler::myWarningInstance.
Referenced by SystemFrame::close(), GUIRunThread::deleteSim(), main(), and MsgHandler::setFactory().
|
inlinevirtual |
Clears information whether an error occurred previously.
Reimplemented from MsgHandler.
Definition at line 77 of file MsgHandlerSynchronized.h.
References MsgHandler::clear(), and myLock.
|
inlinestatic |
Definition at line 48 of file MsgHandlerSynchronized.h.
Referenced by NLBuilder::init(), and main().
|
staticinherited |
enable/disable gl-debug messages
Definition at line 124 of file MsgHandler.cpp.
References MsgHandler::myWriteDebugGLMessages.
Referenced by GNEOptionsDialogElements::InputBool::onCmdSetOption(), and GNELoadThread::run().
|
staticinherited |
enable/disable debug messages
Definition at line 119 of file MsgHandler.cpp.
References MsgHandler::myWriteDebugMessages.
Referenced by GNEOptionsDialogElements::InputBool::onCmdSetOption(), and GNELoadThread::run().
|
inlinevirtual |
Ends a process information.
Reimplemented from MsgHandler.
Definition at line 71 of file MsgHandlerSynchronized.h.
References MsgHandler::endProcessMsg(), and myLock.
|
virtualinherited |
Ends a process information with predefined messages.
Definition at line 187 of file MsgHandler.cpp.
References MsgHandler::endProcessMsg(), TL, TLF, and toString().
|
staticinherited |
Returns the instance to add debug to.
Definition at line 101 of file MsgHandler.cpp.
References MsgHandler::MT_DEBUG, and MsgHandler::myDebugInstance.
Referenced by GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
staticinherited |
Returns the instance to add errors to.
Definition at line 92 of file MsgHandler.cpp.
References MsgHandler::MT_ERROR, and MsgHandler::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(), NLBuilder::init(), GUIRunThread::init(), MsgHandler::initOutputOptions(), RORoute::isValid(), NIImporter_OpenStreetMap::load(), PCLoaderOSM::loadIfSet(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), MSNet::loadState(), main(), main(), GUIRunThread::makeStep(), 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().
|
staticinherited |
Returns the instance to add GLdebug to.
Definition at line 110 of file MsgHandler.cpp.
References MsgHandler::MT_GLDEBUG, and MsgHandler::myGLDebugInstance.
Referenced by GUIMessageWindow::registerMsgHandlers(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
staticinherited |
Returns the instance to add normal messages to.
Definition at line 66 of file MsgHandler.cpp.
References MsgHandler::MT_MESSAGE, MsgHandler::myFactory, and MsgHandler::myMessageInstance.
Referenced by CHBuilder< E, V >::buildContractionHierarchy(), MSDeterministicHiLevelTrafficLightLogic::decideNextPhase(), MSSwarmTrafficLightLogic::decideNextPhase(), GUIRunThread::deleteSim(), MsgHandler::inform(), NLBuilder::init(), GUIRunThread::init(), MsgHandler::initOutputOptions(), NBHeightMapper::loadIfSet(), MSSOTLPhaseTrafficLightLogic::MSSOTLPhaseTrafficLightLogic(), MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(), MSSOTLWaveTrafficLightLogic::MSSOTLWaveTrafficLightLogic(), GUIMessageWindow::registerMsgHandlers(), GUILoadThread::run(), GNELoadThread::run(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), and GUIMessageWindow::unregisterMsgHandlers().
|
staticinherited |
Returns the instance to add warnings to.
Definition at line 79 of file MsgHandler.cpp.
References MsgHandler::MT_WARNING, MsgHandler::myFactory, and MsgHandler::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(), MsgHandler::initOutputOptions(), RORoute::isValid(), PCLoaderOSM::loadIfSet(), main(), NBLoadedTLDef::myCompute(), RORouteDef::preComputeCurrentRoute(), GUIMessageWindow::registerMsgHandlers(), RORouteDef::repairCurrentRoute(), GUILoadThread::run(), GNELoadThread::run(), RONet::saveAndRemoveRoutesUntil(), GNELoadThread::submitEndAndCleanup(), GUILoadThread::submitEndAndCleanup(), TraCIServer::TraCIServer(), and GUIMessageWindow::unregisterMsgHandlers().
|
inlinevirtual |
adds a new error to the list
Reimplemented from MsgHandler.
Definition at line 53 of file MsgHandlerSynchronized.h.
References MsgHandler::inform(), and myLock.
|
inlineinherited |
adds a new formatted message
Definition at line 122 of file MsgHandler.h.
References MsgHandler::aggregationThresholdReached(), StringUtils::format(), and MsgHandler::inform().
Referenced by IntermodalRouter< E, L, N, V >::compute(), AStarRouter< E, V >::compute(), CHRouter< E, V >::compute(), DijkstraRouter< E, V >::compute(), SUMOAbstractRouter< E, V >::computeLooped(), NIXMLConnectionsHandler::delConnection(), RORoute::isValid(), and NIXMLConnectionsHandler::parseLaneBound().
|
staticinherited |
init output options
Definition at line 316 of file MsgHandler.cpp.
References MsgHandler::addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), MsgHandler::getErrorInstance(), OptionsCont::getInt(), MsgHandler::getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), MsgHandler::getWarningInstance(), OptionsCont::isSet(), MsgHandler::myInitialMessages, MsgHandler::myWriteProcessId, MsgHandler::myWriteTimestamps, MsgHandler::removeRetriever(), and MsgHandler::setAggregationThreshold().
Referenced by NLBuilder::init(), main(), main(), GUILoadThread::run(), and GNELoadThread::run().
|
staticinherited |
reformats a long string to contain newline after a certain line length in px (depending on the current font)
Definition at line 130 of file MsgHandler.cpp.
|
inherited |
Returns whether the given output device retrieves messages from the handler.
Definition at line 254 of file MsgHandler.cpp.
References MsgHandler::myRetrievers.
Referenced by MsgHandler::addRetriever(), and OutputDevice::closeAll().
|
inlineinherited |
Generic output operator.
Definition at line 162 of file MsgHandler.h.
References MsgHandler::myRetrievers.
|
privatedelete |
invalid assignment operator
|
inlinevirtual |
Removes the retriever from the handler.
Reimplemented from MsgHandler.
Definition at line 89 of file MsgHandlerSynchronized.h.
References myLock, and MsgHandler::removeRetriever().
|
staticinherited |
ensure that that given output device is no longer used as retriever by any instance
Definition at line 260 of file MsgHandler.cpp.
References MsgHandler::myDebugInstance, MsgHandler::myErrorInstance, MsgHandler::myGLDebugInstance, MsgHandler::myMessageInstance, MsgHandler::myWarningInstance, and MsgHandler::removeRetriever().
Referenced by OutputDevice::close().
|
inlineprotectedinherited |
Definition at line 211 of file MsgHandler.h.
References MsgHandler::myAggregationThreshold.
Referenced by MsgHandler::initOutputOptions().
|
inlinestaticinherited |
Sets the factory function to use for new MsgHandlers.
Definition at line 64 of file MsgHandler.h.
References MsgHandler::cleanupOnEnd(), and MsgHandler::myFactory.
Referenced by NLBuilder::init(), and main().
|
staticinherited |
set up gettext stuff
Definition at line 280 of file MsgHandler.cpp.
References MsgHandler::myErrorPrefix, MsgHandler::myWarningPrefix, TL, UNUSED_PARAMETER, WRITE_WARNING, and WRITE_WARNINGF.
Referenced by OptionsCont::processMetaOptions().
|
inherited |
Returns the information whether any messages were added.
Definition at line 416 of file MsgHandler.cpp.
References MsgHandler::myWasInformed.
Referenced by MsgHandler::clear(), NIImporter_OpenStreetMap::load(), NBLoadedTLDef::myCompute(), ROLoader::processRoutes(), and XMLSubSys::runParser().
|
inlinestaticinherited |
check whether to enable/disable gl-debug messages
Definition at line 97 of file MsgHandler.h.
References MsgHandler::myWriteDebugGLMessages.
Referenced by SUMORTree::addAdditionalGLObject(), and SUMORTree::removeAdditionalGLObject().
|
inlinestaticinherited |
check whether to enable/disable debug messages
Definition at line 92 of file MsgHandler.h.
References MsgHandler::myWriteDebugMessages.
|
privateinherited |
count for messages of the same type
Definition at line 254 of file MsgHandler.h.
Referenced by MsgHandler::aggregationThresholdReached(), and MsgHandler::clear().
|
privateinherited |
do not output more messages of the same type if the count exceeds this threshold
Definition at line 251 of file MsgHandler.h.
Referenced by MsgHandler::aggregationThresholdReached(), MsgHandler::clear(), and MsgHandler::setAggregationThreshold().
|
staticprivateinherited |
Information whether a process information is printed to cout.
Definition at line 241 of file MsgHandler.h.
Referenced by MsgHandler::beginProcessMsg(), MsgHandler::endProcessMsg(), and MsgHandler::inform().
|
staticprivateinherited |
The instance to handle debug.
Definition at line 226 of file MsgHandler.h.
Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getDebugInstance(), and MsgHandler::removeRetrieverFromAllInstances().
|
staticprivateinherited |
The instance to handle errors.
Definition at line 232 of file MsgHandler.h.
Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getErrorInstance(), and MsgHandler::removeRetrieverFromAllInstances().
|
staticprivateinherited |
The possibly translated error prefix (mainly for speedup)
Definition at line 278 of file MsgHandler.h.
Referenced by MsgHandler::build(), and MsgHandler::setupI18n().
|
staticprivateinherited |
The function to call for new MsgHandlers, nullptr means use default constructor.
Definition at line 223 of file MsgHandler.h.
Referenced by MsgHandler::getMessageInstance(), MsgHandler::getWarningInstance(), and MsgHandler::setFactory().
|
staticprivateinherited |
The instance to handle glDebug.
Definition at line 229 of file MsgHandler.h.
Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getGLDebugInstance(), and MsgHandler::removeRetrieverFromAllInstances().
|
privateinherited |
storage for initial messages
Definition at line 260 of file MsgHandler.h.
Referenced by MsgHandler::clear(), MsgHandler::inform(), and MsgHandler::initOutputOptions().
|
private |
The lock for synchronizing all outputs using handlers of this class.
Definition at line 111 of file MsgHandlerSynchronized.h.
Referenced by addRetriever(), aggregationThresholdReached(), beginProcessMsg(), clear(), endProcessMsg(), inform(), and removeRetriever().
|
staticprivateinherited |
The instance to handle normal messages.
Definition at line 238 of file MsgHandler.h.
Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getMessageInstance(), and MsgHandler::removeRetrieverFromAllInstances().
|
privateinherited |
The list of retrievers that shall be informed about new messages or errors.
Definition at line 257 of file MsgHandler.h.
Referenced by MsgHandler::addRetriever(), MsgHandler::beginProcessMsg(), MsgHandler::endProcessMsg(), MsgHandler::inform(), MsgHandler::isRetriever(), MsgHandler::operator<<(), and MsgHandler::removeRetriever().
|
privateinherited |
The type of the instance.
Definition at line 245 of file MsgHandler.h.
Referenced by MsgHandler::build().
|
staticprivateinherited |
The instance to handle warnings.
Definition at line 235 of file MsgHandler.h.
Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getWarningInstance(), and MsgHandler::removeRetrieverFromAllInstances().
|
staticprivateinherited |
The possibly translated warning prefix (mainly for speedup)
Definition at line 281 of file MsgHandler.h.
Referenced by MsgHandler::build(), and MsgHandler::setupI18n().
|
privateinherited |
information whether an output occurred at all
Definition at line 248 of file MsgHandler.h.
Referenced by MsgHandler::beginProcessMsg(), MsgHandler::clear(), MsgHandler::endProcessMsg(), MsgHandler::inform(), and MsgHandler::wasInformed().
|
staticprivateinherited |
Flag to enable or disable GL specific debug output.
Definition at line 269 of file MsgHandler.h.
Referenced by MsgHandler::enableDebugGLMessages(), and MsgHandler::writeDebugGLMessages().
|
staticprivateinherited |
Flag to enable or disable debug output.
This value is used to show more internal information through warning messages about certain operations
Definition at line 266 of file MsgHandler.h.
Referenced by MsgHandler::enableDebugMessages(), and MsgHandler::writeDebugMessages().
|
staticprivateinherited |
Whether to prefix every message with the process id.
Definition at line 275 of file MsgHandler.h.
Referenced by MsgHandler::build(), and MsgHandler::initOutputOptions().
|
staticprivateinherited |
Whether to prefix every message with a time stamp.
Definition at line 272 of file MsgHandler.h.
Referenced by MsgHandler::build(), and MsgHandler::initOutputOptions().