Orxonox  0.0.5 Codename: Arcturus
OutputListener.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
36 #ifndef _OutputListener_H__
37 #define _OutputListener_H__
38 
39 #include "util/UtilPrereqs.h"
40 
41 #include <vector>
42 
43 #include "OutputDefinitions.h"
44 
45 namespace orxonox
46 {
50  // See below the class declaration for a more detailed description.
52  {
53  public:
54  OutputListener(bool bRegister = true);
55  virtual ~OutputListener();
56 
57  void registerListener(AdditionalContextListener* listener);
58  void unregisterListener(AdditionalContextListener* listener);
59 
60  void setLevelMax(OutputLevel max);
61  void setLevelRange(OutputLevel min, OutputLevel max);
62  void setLevelMask(OutputLevel mask);
63 
64  void setAdditionalContextsLevelMax(OutputLevel max);
65  void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max);
66  void setAdditionalContextsLevelMask(OutputLevel mask);
67 
68  virtual void setAdditionalContextsMask(OutputContextMask mask);
69 
71  inline OutputLevel getLevelMask() const
72  { return this->levelMask_; }
75  { return this->additionalContextsMask_; }
78  { return this->additionalContextsLevelMask_; }
79 
80  virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
81 
83  virtual void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
84  { if (this->acceptsOutput(level, context)) this->output(level, context, lines); }
85 
86  protected:
88  virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) = 0;
89 
90  inline const std::vector<AdditionalContextListener*>& getListeners() const
91  { return this->listeners_; }
92 
93  private:
94  std::vector<AdditionalContextListener*> listeners_;
95 
99  };
100 
180 }
181 
182 #endif /* _OutputListener_H__ */
#define _UtilExport
Definition: UtilPrereqs.h:60
std::vector< AdditionalContextListener * > listeners_
List of all registered additional context listeners.
Definition: OutputListener.h:94
Stores all information about a context.
Definition: OutputDefinitions.h:112
OutputLevel levelMask_
Mask of accepted output levels, independent of contexts.
Definition: OutputListener.h:96
virtual void unfilteredOutput(OutputLevel level, const OutputContextContainer &context, const std::vector< std::string > &lines)
Called by OutputManager for each line of output, checks if this listener actually accepts this output...
Definition: OutputListener.h:83
OutputLevel
Output levels define type and importance of an output message.
Definition: OutputDefinitions.h:84
Defines output levels and output contexts.
AdditionalContextListener is an interface which is used to notify OutputManager about additional cont...
Definition: AdditionalContextListener.h:49
OutputLevel additionalContextsLevelMask_
Mask of accepted output levels of the additional contexts.
Definition: OutputListener.h:98
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
OutputContextMask additionalContextsMask_
Mask of accepted additional contexts.
Definition: OutputListener.h:97
Shared library macros, enums, constants and forward declarations for the util library ...
OutputListener is an interface which is used to receive output of a certain level and context from Ou...
Definition: OutputListener.h:51
const std::vector< AdditionalContextListener * > & getListeners() const
Definition: OutputListener.h:90
OutputLevel getAdditionalContextsLevelMask() const
Returns the additional contexts level mask.
Definition: OutputListener.h:77
OutputContextMask getAdditionalContextsMask() const
Returns the additional contexts mask.
Definition: OutputListener.h:74
uint64_t OutputContextMask
Used to store the context masks. Each bit defines a context.
Definition: OutputDefinitions.h:108
OutputLevel getLevelMask() const
Returns the level mask.
Definition: OutputListener.h:71