SUMO - Simulation of Urban MObility
MsgHandler Class Reference

#include <MsgHandler.h>

Collaboration diagram for MsgHandler:
Collaboration graph

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 >
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 assignLock (AbstractMutex *lock)
 Sets the lock to use The lock will not be deleted. More...
 
static void cleanupOnEnd ()
 Removes pending handler. More...
 
static MsgHandlergetErrorInstance ()
 Returns the instance to add errors 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 ()
 

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)
 
MsgHandleroperator= (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 MsgHandlermyErrorInstance = 0
 The instance to handle errors. More...
 
static AbstractMutexmyLock = 0
 The lock if any has to be used The lock will not be deleted. More...
 
static MsgHandlermyMessageInstance = 0
 The instance to handle normal messages. More...
 
static MsgHandlermyWarningInstance = 0
 The instance to handle warnings. More...
 

Detailed Description

MsgHandler

Definition at line 53 of file MsgHandler.h.

Member Typedef Documentation

typedef std::vector<OutputDevice*> MsgHandler::RetrieverVector
private

Definition of the list of retrievers to inform.

Definition at line 182 of file MsgHandler.h.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

MsgHandler::MsgHandler ( MsgType  type)
private

standard constructor

Definition at line 258 of file MsgHandler.cpp.

References addRetriever(), OutputDevice::getDevice(), and MT_MESSAGE.

Referenced by build(), getErrorInstance(), getMessageInstance(), and getWarningInstance().

MsgHandler::~MsgHandler ( )
private

destructor

Definition at line 268 of file MsgHandler.cpp.

Referenced by build().

MsgHandler::MsgHandler ( const MsgHandler s)
private

invalid copy constructor

Member Function Documentation

void MsgHandler::addRetriever ( OutputDevice retriever)
void MsgHandler::assignLock ( AbstractMutex lock)
static

Sets the lock to use The lock will not be deleted.

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

References build(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().

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

Builds the string which includes the mml-message type.

Definition at line 131 of file MsgHandler.h.

References MsgHandler(), MT_ERROR, MT_MESSAGE, MT_WARNING, myType, and ~MsgHandler().

Referenced by beginProcessMsg(), and inform().

void MsgHandler::cleanupOnEnd ( )
static
void MsgHandler::clear ( )

Clears information whether an error occured previously.

Definition at line 149 of file MsgHandler.cpp.

References AbstractMutex::lock(), myLock, myWasInformed, and AbstractMutex::unlock().

Referenced by loadJTRDefinitions(), main(), NBLoadedTLDef::myCompute(), GNELoadThread::run(), and GUILoadThread::run().

void MsgHandler::endProcessMsg ( std::string  msg)
void MsgHandler::inform ( std::string  msg,
bool  addType = true 
)

adds a new error to the list

Definition at line 89 of file MsgHandler.cpp.

References build(), getMessageInstance(), inform(), AbstractMutex::lock(), myAmProcessingProcess, myLock, myRetrievers, myWasInformed, and AbstractMutex::unlock().

Referenced by RORouteHandler::addStop(), RORouteHandler::closeFlow(), RORouteHandler::closeRoute(), RORouteHandler::closeRouteDistribution(), RORouteHandler::closeVehicle(), RORouteHandler::closeVehicleTypeDistribution(), ROJTRRouter::compute(), DijkstraRouterTT< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), DijkstraRouterEffort< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), CHRouter< E, V, PF >::compute(), RONet::computeRoute(), inform(), GUIRunThread::init(), main(), GUIRunThread::makeStep(), NIXMLConnectionsHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), PCLoaderOSM::RelationsHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), RORouteHandler::openRoute(), RORouteHandler::openRouteDistribution(), NIXMLConnectionsHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RORouteHandler::parseEdges(), RORouteHandler::parseFromViaTo(), NIXMLConnectionsHandler::parseLaneBound(), SUMORouteHandler::parseStop(), RORouteDef::preComputeCurrentRoute(), RORouteDef::repairCurrentRoute(), RORouteHandler::routePedestrian(), GUILoadThread::run(), and TraCIServer::TraCIServer().

bool MsgHandler::isRetriever ( OutputDevice retriever) const

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

Definition at line 191 of file MsgHandler.cpp.

References myRetrievers.

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

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

Generic output operator.

Returns
The MsgHandler for further processing

Definition at line 121 of file MsgHandler.h.

References myRetrievers.

MsgHandler& MsgHandler::operator= ( const MsgHandler s)
private

invalid assignment operator

bool MsgHandler::wasInformed ( ) const

Returns the information whether any messages were added.

Definition at line 273 of file MsgHandler.cpp.

References myWasInformed.

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

Field Documentation

bool MsgHandler::myAmProcessingProcess = false
staticprivate

Information whether a process information is printed to cout.

Definition at line 168 of file MsgHandler.h.

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

MsgHandler * MsgHandler::myErrorInstance = 0
staticprivate

The instance to handle errors.

Definition at line 159 of file MsgHandler.h.

Referenced by cleanupOnEnd(), and getErrorInstance().

AbstractMutex * MsgHandler::myLock = 0
staticprivate

The lock if any has to be used The lock will not be deleted.

Definition at line 172 of file MsgHandler.h.

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

MsgHandler * MsgHandler::myMessageInstance = 0
staticprivate

The instance to handle normal messages.

Definition at line 165 of file MsgHandler.h.

Referenced by cleanupOnEnd(), and getMessageInstance().

RetrieverVector MsgHandler::myRetrievers
private

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

Definition at line 185 of file MsgHandler.h.

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

MsgType MsgHandler::myType
private

The type of the instance.

Definition at line 176 of file MsgHandler.h.

Referenced by build().

MsgHandler * MsgHandler::myWarningInstance = 0
staticprivate

The instance to handle warnings.

Definition at line 162 of file MsgHandler.h.

Referenced by cleanupOnEnd(), and getWarningInstance().

bool MsgHandler::myWasInformed
private

information wehther an error occured at all

Definition at line 179 of file MsgHandler.h.

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


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