Eclipse SUMO - Simulation of Urban MObility
MsgHandlerSynchronized.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2003-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Retrieves messages about the process and gives them further to output
17 /****************************************************************************/
18 #ifndef MsgHandlerSynchronized_h
19 #define MsgHandlerSynchronized_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #ifdef HAVE_FOX
28 #include <fx.h>
29 #endif
30 #include <string>
31 #include <vector>
32 #include <iostream>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class OutputDevice;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
49 public:
50  static MsgHandler* create(MsgType type) {
51  return new MsgHandlerSynchronized(type);
52  }
53 
55  void inform(std::string msg, bool addType = true) {
56  FXMutexLock locker(myLock);
57  MsgHandler::inform(msg, addType);
58  }
59 
67  void beginProcessMsg(std::string msg, bool addType = true) {
68  FXMutexLock locker(myLock);
69  MsgHandler::beginProcessMsg(msg, addType);
70  }
71 
73  void endProcessMsg(std::string msg) {
74  FXMutexLock locker(myLock);
76  }
77 
79  void clear() {
80  FXMutexLock locker(myLock);
82  }
83 
85  void addRetriever(OutputDevice* retriever) {
86  FXMutexLock locker(myLock);
87  MsgHandler::addRetriever(retriever);
88  }
89 
91  void removeRetriever(OutputDevice* retriever) {
92  FXMutexLock locker(myLock);
93  MsgHandler::removeRetriever(retriever);
94  }
95 
96 private:
99  MsgHandler(type), myLock(true) {
100  }
101 
104  }
105 
107  FXMutex myLock;
108 
109 private:
112 
115 };
116 
117 #endif
118 
119 /****************************************************************************/
MsgHandler::MsgType
MsgType
Definition: MsgHandler.h:45
MsgHandlerSynchronized
Definition: MsgHandlerSynchronized.h:48
MsgHandlerSynchronized::endProcessMsg
void endProcessMsg(std::string msg)
Ends a process information.
Definition: MsgHandlerSynchronized.h:73
MsgHandlerSynchronized::~MsgHandlerSynchronized
~MsgHandlerSynchronized()
destructor
Definition: MsgHandlerSynchronized.h:103
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MsgHandler.h
MsgHandlerSynchronized::MsgHandlerSynchronized
MsgHandlerSynchronized(MsgType type)
standard constructor
Definition: MsgHandlerSynchronized.h:98
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
MsgHandler::beginProcessMsg
virtual void beginProcessMsg(std::string msg, bool addType=true)
Begins a process information.
Definition: MsgHandler.cpp:135
MsgHandlerSynchronized::clear
void clear()
Clears information whether an error occurred previously.
Definition: MsgHandlerSynchronized.h:79
MsgHandlerSynchronized::addRetriever
void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
Definition: MsgHandlerSynchronized.h:85
MsgHandler::clear
virtual void clear()
Clears information whether an error occurred previously.
Definition: MsgHandler.cpp:160
MsgHandlerSynchronized::create
static MsgHandler * create(MsgType type)
Definition: MsgHandlerSynchronized.h:50
MsgHandler
Definition: MsgHandler.h:38
MsgHandlerSynchronized::inform
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandlerSynchronized.h:55
MsgHandler::endProcessMsg
virtual void endProcessMsg(std::string msg)
Ends a process information.
Definition: MsgHandler.cpp:148
MsgHandlerSynchronized::removeRetriever
void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
Definition: MsgHandlerSynchronized.h:91
MsgHandlerSynchronized::operator=
MsgHandlerSynchronized & operator=(const MsgHandlerSynchronized &s)=delete
invalid assignment operator
MsgHandler::addRetriever
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
Definition: MsgHandler.cpp:174
config.h
MsgHandlerSynchronized::myLock
FXMutex myLock
The lock for synchronizing all outputs using handlers of this class.
Definition: MsgHandlerSynchronized.h:107
MsgHandlerSynchronized::beginProcessMsg
void beginProcessMsg(std::string msg, bool addType=true)
Begins a process information.
Definition: MsgHandlerSynchronized.h:67
MsgHandler::removeRetriever
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
Definition: MsgHandler.cpp:182