Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MsgHandlerSynchronized Class Reference

#include <MsgHandlerSynchronized.h>

Inheritance diagram for MsgHandlerSynchronized:
[legend]
Collaboration diagram for MsgHandlerSynchronized:
[legend]

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.
int getAggregationThreshold () const
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>
MsgHandleroperator<< (const T &t)
 Generic output operator.
void removeRetriever (OutputDevice *retriever)
 Removes the retriever from the handler.
void setAggregationThreshold (const int thresh)
bool wasInformed () const
 Returns the information whether any messages were added.

Static Public Member Functions

static void cleanupOnEnd ()
 Removes pending handler.
static MsgHandlercreate (MsgType type)
static void enableDebugGLMessages (bool enable)
 enable/disable gl-debug messages
static void enableDebugMessages (bool enable)
 enable/disable debug messages
static MsgHandlergetErrorInstance ()
 Returns the instance to add errors to.
static MsgHandlergetMessageInstance ()
 Returns the instance to add normal messages to.
static MsgHandlergetWarningInstance ()
 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 () const

Private Types

typedef MsgHandler *(* Factory) (MsgType)

Private Member Functions

 MsgHandlerSynchronized (const MsgHandlerSynchronized &s)=delete
 invalid copy constructor
 MsgHandlerSynchronized (MsgType type)
 standard constructor
MsgHandlerSynchronizedoperator= (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 MsgHandlermyErrorInstance = 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 MsgHandlermyMessageInstance = nullptr
 The instance to handle normal messages.
static MsgHandlermyWarningInstance = 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.

Detailed Description

Member Typedef Documentation

◆ Factory

typedef MsgHandler *(* MsgHandler::Factory) (MsgType)
privateinherited

Definition at line 60 of file MsgHandler.h.

Member Enumeration Documentation

◆ MsgType

enum class MsgHandler::MsgType
stronginherited

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.

MT_DEBUG 

The message is debug output.

MT_GLDEBUG 

The message is GL debug output.

Definition at line 46 of file MsgHandler.h.

Constructor & Destructor Documentation

◆ MsgHandlerSynchronized() [1/2]

MsgHandlerSynchronized::MsgHandlerSynchronized ( MsgType type)
inlineprivate

standard constructor

Definition at line 102 of file MsgHandlerSynchronized.h.

References MsgHandler::MsgHandler(), and myLock.

Referenced by create(), MsgHandlerSynchronized(), and operator=().

Here is the caller graph for this function:

◆ ~MsgHandlerSynchronized()

MsgHandlerSynchronized::~MsgHandlerSynchronized ( )
inlineprivate

destructor

Definition at line 107 of file MsgHandlerSynchronized.h.

◆ MsgHandlerSynchronized() [2/2]

MsgHandlerSynchronized::MsgHandlerSynchronized ( const MsgHandlerSynchronized & s)
privatedelete

invalid copy constructor

References MsgHandlerSynchronized().

Member Function Documentation

◆ addRetriever()

void MsgHandlerSynchronized::addRetriever ( OutputDevice * retriever)
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.

◆ aggregationThresholdReached()

bool MsgHandlerSynchronized::aggregationThresholdReached ( const std::string & format)
inlineprotectedvirtual

Reimplemented from MsgHandler.

Definition at line 95 of file MsgHandlerSynchronized.h.

References MsgHandler::aggregationThresholdReached(), and myLock.

◆ beginProcessMsg()

void MsgHandlerSynchronized::beginProcessMsg ( std::string msg,
bool addType = true )
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.

◆ build()

std::string MsgHandler::build ( const std::string & msg,
bool addType )
inlineprotectedinherited

Builds the string which includes the mml-message type.

Definition at line 177 of file MsgHandler.h.

References buildProcessIdPrefix(), StringUtils::isoTimeString(), MT_DEBUG, MT_ERROR, MT_GLDEBUG, MT_MESSAGE, MT_WARNING, myErrorPrefix, myType, myWarningPrefix, myWriteProcessId, and myWriteTimestamps.

Referenced by beginProcessMsg(), and inform().

Here is the caller graph for this function:

◆ buildProcessIdPrefix()

std::string MsgHandler::buildProcessIdPrefix ( ) const
protectedinherited

Definition at line 347 of file MsgHandler.cpp.

Referenced by build().

Here is the caller graph for this function:

◆ cleanupOnEnd()

void MsgHandler::cleanupOnEnd ( )
staticinherited

Removes pending handler.

Definition at line 336 of file MsgHandler.cpp.

References myErrorInstance, myMessageInstance, and myWarningInstance.

Referenced by SystemFrame::close(), GUIRunThread::deleteSim(), main(), and setFactory().

Here is the caller graph for this function:

◆ clear()

void MsgHandlerSynchronized::clear ( bool resetInformed = true)
inlinevirtual

Clears information whether an error occurred previously.

Reimplemented from MsgHandler.

Definition at line 77 of file MsgHandlerSynchronized.h.

References MsgHandler::clear(), and myLock.

◆ create()

MsgHandler * MsgHandlerSynchronized::create ( MsgType type)
inlinestatic

Definition at line 48 of file MsgHandlerSynchronized.h.

References MsgHandler::MsgHandler(), and MsgHandlerSynchronized().

Referenced by NLBuilder::init(), and main().

Here is the caller graph for this function:

◆ enableDebugGLMessages()

void MsgHandler::enableDebugGLMessages ( bool enable)
staticinherited

enable/disable gl-debug messages

Definition at line 103 of file MsgHandler.cpp.

References myWriteDebugGLMessages.

Referenced by GNEOptionsEditorRow::OptionBool::onCmdSetOption(), and GNELoadThread::run().

Here is the caller graph for this function:

◆ enableDebugMessages()

void MsgHandler::enableDebugMessages ( bool enable)
staticinherited

enable/disable debug messages

Definition at line 98 of file MsgHandler.cpp.

References myWriteDebugMessages.

Referenced by GNEOptionsEditorRow::OptionBool::onCmdSetOption(), and GNELoadThread::run().

Here is the caller graph for this function:

◆ endProcessMsg()

void MsgHandlerSynchronized::endProcessMsg ( std::string msg)
inlinevirtual

Ends a process information.

Reimplemented from MsgHandler.

Definition at line 71 of file MsgHandlerSynchronized.h.

References MsgHandler::endProcessMsg(), and myLock.

◆ endProcessMsg2()

void MsgHandler::endProcessMsg2 ( bool success,
long duration = -1 )
virtualinherited

Ends a process information with predefined messages.

Definition at line 166 of file MsgHandler.cpp.

References endProcessMsg(), TL, TLF, and toString().

◆ getAggregationThreshold()

int MsgHandler::getAggregationThreshold ( ) const
inlineinherited

Definition at line 168 of file MsgHandler.h.

References myAggregationThreshold.

Referenced by GUINet::loadEdgeData().

Here is the caller graph for this function:

◆ getErrorInstance()

◆ getMessageInstance()

◆ getWarningInstance()

◆ inform()

void MsgHandlerSynchronized::inform ( std::string msg,
bool addType = true )
inlinevirtual

adds a new error to the list

Reimplemented from MsgHandler.

Definition at line 53 of file MsgHandlerSynchronized.h.

References MsgHandler::inform(), and myLock.

◆ informf()

template<typename T, typename... Targs>
void MsgHandler::informf ( const std::string & format,
T value,
Targs... Fargs )
inlineinherited

adds a new formatted message

Definition at line 116 of file MsgHandler.h.

References aggregationThresholdReached(), StringUtils::format(), inform(), and invalid_return< std::string >::value.

Referenced by RORoute::isPermitted(), and RORoute::isValid().

Here is the caller graph for this function:

◆ initOutputOptions()

void MsgHandler::initOutputOptions ( )
staticinherited

init output options

Definition at line 293 of file MsgHandler.cpp.

References addRetriever(), OptionsCont::getBool(), OutputDevice::getDevice(), getErrorInstance(), OptionsCont::getInt(), getMessageInstance(), OptionsCont::getOptions(), OptionsCont::getString(), getWarningInstance(), OptionsCont::isSet(), myInitialMessages, myWriteProcessId, myWriteTimestamps, removeRetriever(), and setAggregationThreshold().

Referenced by NLBuilder::init(), main(), main(), GNELoadThread::run(), and GUILoadThread::run().

Here is the caller graph for this function:

◆ insertLineBreaks()

std::string MsgHandler::insertLineBreaks ( std::string msg,
int lineWidth )
staticinherited

reformats a long string to contain newline after a certain line length in px (depending on the current font)

Definition at line 109 of file MsgHandler.cpp.

◆ isRetriever()

bool MsgHandler::isRetriever ( OutputDevice * retriever) const
inherited

Returns whether the given output device retrieves messages from the handler.

Definition at line 233 of file MsgHandler.cpp.

References myRetrievers.

Referenced by addRetriever().

Here is the caller graph for this function:

◆ operator<<()

template<class T>
MsgHandler & MsgHandler::operator<< ( const T & t)
inlineinherited

Generic output operator.

Returns
The MsgHandler for further processing

Definition at line 156 of file MsgHandler.h.

References MsgHandler(), and myRetrievers.

◆ operator=()

MsgHandlerSynchronized & MsgHandlerSynchronized::operator= ( const MsgHandlerSynchronized & s)
privatedelete

invalid assignment operator

References MsgHandlerSynchronized().

◆ removeRetriever()

void MsgHandlerSynchronized::removeRetriever ( OutputDevice * retriever)
inlinevirtual

Removes the retriever from the handler.

Reimplemented from MsgHandler.

Definition at line 89 of file MsgHandlerSynchronized.h.

References myLock, and MsgHandler::removeRetriever().

◆ removeRetrieverFromAllInstances()

void MsgHandler::removeRetrieverFromAllInstances ( OutputDevice * out)
staticinherited

ensure that that given output device is no longer used as retriever by any instance

Definition at line 239 of file MsgHandler.cpp.

References myErrorInstance, myMessageInstance, and myWarningInstance.

Referenced by OutputDevice::close().

Here is the caller graph for this function:

◆ setAggregationThreshold()

void MsgHandler::setAggregationThreshold ( const int thresh)
inlineinherited

Definition at line 164 of file MsgHandler.h.

References myAggregationThreshold.

Referenced by initOutputOptions(), and GUINet::loadEdgeData().

Here is the caller graph for this function:

◆ setFactory()

void MsgHandler::setFactory ( Factory func)
inlinestaticinherited

Sets the factory function to use for new MsgHandlers.

Definition at line 64 of file MsgHandler.h.

References cleanupOnEnd(), and myFactory.

Referenced by NLBuilder::init(), and main().

Here is the caller graph for this function:

◆ setupI18n()

void MsgHandler::setupI18n ( const std::string & locale = "")
staticinherited

set up gettext stuff

Definition at line 253 of file MsgHandler.cpp.

References gLocaleInitialized, myErrorPrefix, myWarningPrefix, TL, UNUSED_PARAMETER, WRITE_WARNING, and WRITE_WARNINGF.

Referenced by OptionsCont::processMetaOptions().

Here is the caller graph for this function:

◆ wasInformed()

bool MsgHandler::wasInformed ( ) const
inherited

Returns the information whether any messages were added.

Definition at line 375 of file MsgHandler.cpp.

References myWasInformed.

Referenced by clear(), and XMLSubSys::runParser().

Here is the caller graph for this function:

◆ writeDebugGLMessages()

bool MsgHandler::writeDebugGLMessages ( )
inlinestaticinherited

check whether to enable/disable gl-debug messages

Definition at line 91 of file MsgHandler.h.

References myWriteDebugGLMessages.

Referenced by SUMORTree::addAdditionalGLObject(), and SUMORTree::removeAdditionalGLObject().

Here is the caller graph for this function:

◆ writeDebugMessages()

bool MsgHandler::writeDebugMessages ( )
inlinestaticinherited

check whether to enable/disable debug messages

Definition at line 86 of file MsgHandler.h.

References myWriteDebugMessages.

Field Documentation

◆ myAggregationCount

std::map<const std::string, int> MsgHandler::myAggregationCount
privateinherited

count for messages of the same type

Definition at line 245 of file MsgHandler.h.

Referenced by aggregationThresholdReached(), and clear().

◆ myAggregationThreshold

int MsgHandler::myAggregationThreshold
privateinherited

do not output more messages of the same type if the count exceeds this threshold

Definition at line 242 of file MsgHandler.h.

Referenced by aggregationThresholdReached(), clear(), getAggregationThreshold(), MsgHandler(), and setAggregationThreshold().

◆ myAmProcessingProcess

bool MsgHandler::myAmProcessingProcess = false
staticprivateinherited

Information whether a process information is printed to cout.

Definition at line 232 of file MsgHandler.h.

Referenced by beginProcessMsg(), endProcessMsg(), and inform().

◆ myErrorInstance

MsgHandler * MsgHandler::myErrorInstance = nullptr
staticprivateinherited

The instance to handle errors.

Definition at line 223 of file MsgHandler.h.

Referenced by cleanupOnEnd(), getErrorInstance(), and removeRetrieverFromAllInstances().

◆ myErrorPrefix

std::string MsgHandler::myErrorPrefix = "Error: "
staticprivateinherited

The possibly translated error prefix (mainly for speedup).

Definition at line 269 of file MsgHandler.h.

Referenced by build(), and setupI18n().

◆ myFactory

MsgHandler::Factory MsgHandler::myFactory = nullptr
staticprivateinherited

The function to call for new MsgHandlers, nullptr means use default constructor.

Definition at line 220 of file MsgHandler.h.

Referenced by getMessageInstance(), getWarningInstance(), and setFactory().

◆ myInitialMessages

std::vector<std::string> MsgHandler::myInitialMessages
privateinherited

storage for initial messages

Definition at line 251 of file MsgHandler.h.

Referenced by clear(), inform(), and initOutputOptions().

◆ myLock

FXMutex MsgHandlerSynchronized::myLock
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(), MsgHandlerSynchronized(), and removeRetriever().

◆ myMessageInstance

MsgHandler * MsgHandler::myMessageInstance = nullptr
staticprivateinherited

The instance to handle normal messages.

Definition at line 229 of file MsgHandler.h.

Referenced by cleanupOnEnd(), getMessageInstance(), and removeRetrieverFromAllInstances().

◆ myRetrievers

std::vector<OutputDevice*> MsgHandler::myRetrievers
privateinherited

The list of retrievers that shall be informed about new messages or errors.

Definition at line 248 of file MsgHandler.h.

Referenced by addRetriever(), beginProcessMsg(), endProcessMsg(), inform(), isRetriever(), operator<<(), and removeRetriever().

◆ myType

MsgType MsgHandler::myType
privateinherited

The type of the instance.

Definition at line 236 of file MsgHandler.h.

Referenced by build(), and MsgHandler().

◆ myWarningInstance

MsgHandler * MsgHandler::myWarningInstance = nullptr
staticprivateinherited

The instance to handle warnings.

Definition at line 226 of file MsgHandler.h.

Referenced by cleanupOnEnd(), getWarningInstance(), and removeRetrieverFromAllInstances().

◆ myWarningPrefix

std::string MsgHandler::myWarningPrefix = "Warning: "
staticprivateinherited

The possibly translated warning prefix (mainly for speedup).

Definition at line 272 of file MsgHandler.h.

Referenced by build(), and setupI18n().

◆ myWasInformed

bool MsgHandler::myWasInformed
privateinherited

information whether an output occurred at all

Definition at line 239 of file MsgHandler.h.

Referenced by beginProcessMsg(), clear(), endProcessMsg(), inform(), MsgHandler(), and wasInformed().

◆ myWriteDebugGLMessages

bool MsgHandler::myWriteDebugGLMessages = false
staticprivateinherited

Flag to enable or disable GL specific debug output.

Definition at line 260 of file MsgHandler.h.

Referenced by enableDebugGLMessages(), and writeDebugGLMessages().

◆ myWriteDebugMessages

bool MsgHandler::myWriteDebugMessages = false
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 257 of file MsgHandler.h.

Referenced by enableDebugMessages(), and writeDebugMessages().

◆ myWriteProcessId

bool MsgHandler::myWriteProcessId = false
staticprivateinherited

Whether to prefix every message with the process id.

Definition at line 266 of file MsgHandler.h.

Referenced by build(), and initOutputOptions().

◆ myWriteTimestamps

bool MsgHandler::myWriteTimestamps = false
staticprivateinherited

Whether to prefix every message with a time stamp.

Definition at line 263 of file MsgHandler.h.

Referenced by build(), and initOutputOptions().


The documentation for this class was generated from the following file: