Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MsgHandlerSynchronized.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2003-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// Retrieves messages about the process and gives them further to output
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#ifdef HAVE_FOX
26#include "fxheader.h"
27#endif
28#include <string>
29#include <vector>
30#include <iostream>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class OutputDevice;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
47public:
48 static MsgHandler* create(MsgType type) {
49 return new MsgHandlerSynchronized(type);
50 }
51
53 void inform(std::string msg, bool addType = true) {
54 FXMutexLock locker(myLock);
55 MsgHandler::inform(msg, addType);
56 }
57
65 void beginProcessMsg(std::string msg, bool addType = true) {
66 FXMutexLock locker(myLock);
67 MsgHandler::beginProcessMsg(msg, addType);
68 }
69
71 void endProcessMsg(std::string msg) {
72 FXMutexLock locker(myLock);
74 }
75
77 void clear(bool resetInformed = true) {
78 FXMutexLock locker(myLock);
79 MsgHandler::clear(resetInformed);
80 }
81
83 void addRetriever(OutputDevice* retriever) {
84 FXMutexLock locker(myLock);
85 MsgHandler::addRetriever(retriever);
86 }
87
89 void removeRetriever(OutputDevice* retriever) {
90 FXMutexLock locker(myLock);
92 }
93
94protected:
95 bool aggregationThresholdReached(const std::string& format) {
96 FXMutexLock locker(myLock);
98 }
99
100private:
103 MsgHandler(type), myLock(true) {
104 }
105
109
111 FXMutex myLock;
112
113private:
116
119};
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
virtual void endProcessMsg(std::string msg)
Ends a process information.
virtual bool aggregationThresholdReached(const std::string &format)
Definition MsgHandler.h:207
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
virtual void beginProcessMsg(std::string msg, bool addType=true)
Begins a process information.
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
bool aggregationThresholdReached(const std::string &format)
void endProcessMsg(std::string msg)
Ends a process information.
void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
static MsgHandler * create(MsgType type)
void clear(bool resetInformed=true)
Clears information whether an error occurred previously.
MsgHandlerSynchronized(MsgType type)
standard constructor
void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
void inform(std::string msg, bool addType=true)
adds a new error to the list
void beginProcessMsg(std::string msg, bool addType=true)
Begins a process information.
MsgHandlerSynchronized & operator=(const MsgHandlerSynchronized &s)=delete
invalid assignment operator
FXMutex myLock
The lock for synchronizing all outputs using handlers of this class.
MsgHandlerSynchronized(const MsgHandlerSynchronized &s)=delete
invalid copy constructor
Static storage of an output device and its base (abstract) implementation.