Eclipse SUMO - Simulation of Urban MObility
MsgHandlerSynchronized Class Reference

#include <MsgHandlerSynchronized.h>

Inheritance diagram for MsgHandlerSynchronized:
Collaboration diagram for MsgHandlerSynchronized:

Public Types

enum  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. More...
 
void beginProcessMsg (std::string msg, bool addType=true)
 Begins a process information. More...
 
void clear ()
 Clears information whether an error occurred 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...
 
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 >
MsgHandleroperator<< (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 cleanupOnEnd ()
 Removes pending handler. More...
 
static MsgHandlercreate (MsgType type)
 
static void enableDebugGLMessages (bool enable)
 enable/disable gl-debug messages More...
 
static void enableDebugMessages (bool enable)
 enable/disable debug messages More...
 
static MsgHandlergetDebugInstance ()
 Returns the instance to add debug to. More...
 
static MsgHandlergetErrorInstance ()
 Returns the instance to add errors to. More...
 
static MsgHandlergetGLDebugInstance ()
 Returns the instance to add GLdebug to. More...
 
static MsgHandlergetMessageInstance ()
 Returns the instance to add normal messages to. More...
 
static MsgHandlergetWarningInstance ()
 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)
 
template<typename T , typename... Targs>
void _informf (const char *format, T value, Targs... Fargs)
 adds a new formatted message More...
 
std::string build (const std::string &msg, bool addType)
 Builds the string which includes the mml-message type. More...
 
void setAggregationThreshold (const int thresh)
 

Private Types

typedef MsgHandler *(* Factory) (MsgType)
 

Private Member Functions

 MsgHandlerSynchronized (const MsgHandlerSynchronized &s)=delete
 invalid copy constructor More...
 
 MsgHandlerSynchronized (MsgType type)
 standard constructor More...
 
MsgHandlerSynchronizedoperator= (const MsgHandlerSynchronized &s)=delete
 invalid assignment operator More...
 
 ~MsgHandlerSynchronized ()
 destructor 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...
 
FXMutex myLock
 The lock for synchronizing all outputs using handlers of this class. 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 MsgHandlermyDebugInstance = nullptr
 The instance to handle debug. More...
 
static MsgHandlermyErrorInstance = 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 MsgHandlermyGLDebugInstance = nullptr
 The instance to handle glDebug. More...
 
static MsgHandlermyMessageInstance = nullptr
 The instance to handle normal messages. More...
 
static MsgHandlermyWarningInstance = nullptr
 The instance to handle warnings. More...
 
static bool myWriteDebugGLMessages
 
static bool myWriteDebugMessages
 Flag to enable or disable debug GL Functions. More...
 

Detailed Description

Member Typedef Documentation

◆ Factory

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

Definition at line 59 of file MsgHandler.h.

Member Enumeration Documentation

◆ MsgType

enum MsgHandler::MsgType
inherited

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 an debug.

MT_GLDEBUG 

The message is an debug.

Definition at line 45 of file MsgHandler.h.

Constructor & Destructor Documentation

◆ MsgHandlerSynchronized() [1/2]

MsgHandlerSynchronized::MsgHandlerSynchronized ( MsgType  type)
inlineprivate

standard constructor

Definition at line 98 of file MsgHandlerSynchronized.h.

Referenced by create().

◆ ~MsgHandlerSynchronized()

MsgHandlerSynchronized::~MsgHandlerSynchronized ( )
inlineprivate

destructor

Definition at line 103 of file MsgHandlerSynchronized.h.

◆ MsgHandlerSynchronized() [2/2]

MsgHandlerSynchronized::MsgHandlerSynchronized ( const MsgHandlerSynchronized s)
privatedelete

invalid copy constructor

Member Function Documentation

◆ _informf() [1/2]

void MsgHandler::_informf ( const char *  format)
inlineprotectedinherited

Definition at line 190 of file MsgHandler.h.

References MsgHandler::inform().

Referenced by MsgHandler::_informf(), and MsgHandler::informf().

◆ _informf() [2/2]

template<typename T , typename... Targs>
void MsgHandler::_informf ( const char *  format,
value,
Targs...  Fargs 
)
inlineprotectedinherited

adds a new formatted message

Definition at line 197 of file MsgHandler.h.

References MsgHandler::_informf().

◆ 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 85 of file MsgHandlerSynchronized.h.

References MsgHandler::addRetriever(), 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 67 of file MsgHandlerSynchronized.h.

References MsgHandler::beginProcessMsg(), and myLock.

◆ build()

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

◆ cleanupOnEnd()

void MsgHandler::cleanupOnEnd ( )
staticinherited

◆ clear()

void MsgHandlerSynchronized::clear ( )
inlinevirtual

Clears information whether an error occurred previously.

Reimplemented from MsgHandler.

Definition at line 79 of file MsgHandlerSynchronized.h.

References MsgHandler::clear(), and myLock.

◆ create()

static MsgHandler* MsgHandlerSynchronized::create ( MsgType  type)
inlinestatic

Definition at line 50 of file MsgHandlerSynchronized.h.

References MsgHandlerSynchronized().

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

◆ enableDebugGLMessages()

void MsgHandler::enableDebugGLMessages ( bool  enable)
staticinherited

enable/disable gl-debug messages

Definition at line 113 of file MsgHandler.cpp.

References MsgHandler::myWriteDebugGLMessages.

Referenced by GUIDialog_Options::InputBool::onCmdSetOption(), and GNELoadThread::run().

◆ enableDebugMessages()

void MsgHandler::enableDebugMessages ( bool  enable)
staticinherited

enable/disable debug messages

Definition at line 108 of file MsgHandler.cpp.

References MsgHandler::myWriteDebugMessages.

Referenced by GUIDialog_Options::InputBool::onCmdSetOption(), and GNELoadThread::run().

◆ endProcessMsg()

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

Ends a process information.

Reimplemented from MsgHandler.

Definition at line 73 of file MsgHandlerSynchronized.h.

References MsgHandler::endProcessMsg(), and myLock.

◆ getDebugInstance()

MsgHandler * MsgHandler::getDebugInstance ( )
staticinherited

◆ getErrorInstance()

◆ getGLDebugInstance()

MsgHandler * MsgHandler::getGLDebugInstance ( )
staticinherited

◆ 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 55 of file MsgHandlerSynchronized.h.

References MsgHandler::inform(), and myLock.

◆ informf()

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

◆ initOutputOptions()

◆ isRetriever()

bool MsgHandler::isRetriever ( OutputDevice retriever) const
inherited

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

Definition at line 191 of file MsgHandler.cpp.

References MsgHandler::myRetrievers.

Referenced by MsgHandler::addRetriever(), and OutputDevice::closeAll().

◆ 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::myRetrievers.

◆ operator=()

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

invalid assignment operator

◆ removeRetriever()

void MsgHandlerSynchronized::removeRetriever ( OutputDevice retriever)
inlinevirtual

Removes the retriever from the handler.

Reimplemented from MsgHandler.

Definition at line 91 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 197 of file MsgHandler.cpp.

References MsgHandler::myDebugInstance, MsgHandler::myErrorInstance, MsgHandler::myGLDebugInstance, MsgHandler::myMessageInstance, MsgHandler::myWarningInstance, and MsgHandler::removeRetriever().

Referenced by OutputDevice::close().

◆ setAggregationThreshold()

void MsgHandler::setAggregationThreshold ( const int  thresh)
inlineprotectedinherited

Definition at line 208 of file MsgHandler.h.

References MsgHandler::myAggregationThreshold.

Referenced by MsgHandler::initOutputOptions().

◆ setFactory()

static void MsgHandler::setFactory ( Factory  func)
inlinestaticinherited

Sets the factory function to use for new MsgHandlers.

Definition at line 63 of file MsgHandler.h.

References MsgHandler::cleanupOnEnd(), and MsgHandler::myFactory.

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

◆ wasInformed()

bool MsgHandler::wasInformed ( ) const
inherited

Returns the information whether any messages were added.

Definition at line 279 of file MsgHandler.cpp.

References MsgHandler::myWasInformed.

Referenced by NLBuilder::build(), ROLoader::openRoutes(), ROLoader::processRoutes(), and XMLSubSys::runParser().

◆ writeDebugGLMessages()

static bool MsgHandler::writeDebugGLMessages ( )
inlinestaticinherited

check whether to enable/disable gl-debug messages

Definition at line 96 of file MsgHandler.h.

References MsgHandler::myWriteDebugGLMessages.

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

◆ writeDebugMessages()

static bool MsgHandler::writeDebugMessages ( )
inlinestaticinherited

check whether to enable/disable debug messages

Definition at line 91 of file MsgHandler.h.

References MsgHandler::myWriteDebugMessages.

Field Documentation

◆ myAggregationCount

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

count for messages of the same type

Definition at line 251 of file MsgHandler.h.

Referenced by MsgHandler::clear(), and MsgHandler::informf().

◆ myAggregationThreshold

int MsgHandler::myAggregationThreshold
privateinherited

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

Definition at line 248 of file MsgHandler.h.

Referenced by MsgHandler::clear(), MsgHandler::informf(), and MsgHandler::setAggregationThreshold().

◆ myAmProcessingProcess

bool MsgHandler::myAmProcessingProcess = false
staticprivateinherited

Information whether a process information is printed to cout.

Definition at line 238 of file MsgHandler.h.

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

◆ myDebugInstance

MsgHandler * MsgHandler::myDebugInstance = nullptr
staticprivateinherited

The instance to handle debug.

Definition at line 223 of file MsgHandler.h.

Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getDebugInstance(), and MsgHandler::removeRetrieverFromAllInstances().

◆ myErrorInstance

MsgHandler * MsgHandler::myErrorInstance = nullptr
staticprivateinherited

The instance to handle errors.

Definition at line 229 of file MsgHandler.h.

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

◆ 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 MsgHandler::getMessageInstance(), MsgHandler::getWarningInstance(), and MsgHandler::setFactory().

◆ myGLDebugInstance

MsgHandler * MsgHandler::myGLDebugInstance = nullptr
staticprivateinherited

The instance to handle glDebug.

Definition at line 226 of file MsgHandler.h.

Referenced by MsgHandler::cleanupOnEnd(), MsgHandler::getGLDebugInstance(), and MsgHandler::removeRetrieverFromAllInstances().

◆ myLock

FXMutex MsgHandlerSynchronized::myLock
private

The lock for synchronizing all outputs using handlers of this class.

Definition at line 107 of file MsgHandlerSynchronized.h.

Referenced by addRetriever(), beginProcessMsg(), clear(), endProcessMsg(), inform(), and removeRetriever().

◆ myMessageInstance

MsgHandler * MsgHandler::myMessageInstance = nullptr
staticprivateinherited

The instance to handle normal messages.

Definition at line 235 of file MsgHandler.h.

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

◆ myRetrievers

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

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

Definition at line 254 of file MsgHandler.h.

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

◆ myType

MsgType MsgHandler::myType
privateinherited

The type of the instance.

Definition at line 242 of file MsgHandler.h.

Referenced by MsgHandler::build().

◆ myWarningInstance

MsgHandler * MsgHandler::myWarningInstance = nullptr
staticprivateinherited

The instance to handle warnings.

Definition at line 232 of file MsgHandler.h.

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

◆ myWasInformed

bool MsgHandler::myWasInformed
privateinherited

information whether an output occurred at all

Definition at line 245 of file MsgHandler.h.

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

◆ myWriteDebugGLMessages

bool MsgHandler::myWriteDebugGLMessages
staticprivateinherited

◆ myWriteDebugMessages

bool MsgHandler::myWriteDebugMessages
staticprivateinherited

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 267 of file MsgHandler.h.

Referenced by MsgHandler::enableDebugMessages(), and MsgHandler::writeDebugMessages().


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