OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
event.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2009 by Guido Kanschat
6 // Copyright (C) 2006-2014 by Energy Systems Design Laboratory, University of Alberta
7 //
8 // This software is distributed under the MIT License
9 // For more information, see the README file in /doc/LICENSE
10 //
11 // - Class: event.h
12 // - Description: This class implements notifications of applications
13 // - Developers: Guido Kanschat, Texas A&M University
14 // Valentin N. Zingan, University of Alberta
15 // Marc Secanell, University of Alberta
16 //
17 // ----------------------------------------------------------------------------
18 
19 #ifndef _FUEL_CELL_APPLICATION_CORE_EVENT_H_
20 #define _FUEL_CELL_APPLICATION_CORE_EVENT_H_
21 
22 #include <algorithm>
23 #include <fstream>
24 
25 namespace FuelCell
26 {
27 namespace ApplicationCore
28 {
29 
51 class Event
52 {
53 public:
54 
59  Event();
60 
72  static Event assign(const char* name);
73 
77  void all();
78 
82  void clear();
83 
89  bool test(const Event& other) const;
90 
95  bool any() const;
96 
100  Event& operator += (const Event& other);
101 
105  Event& operator -= (const Event& other);
106 
110  template<typename OS>
111  void print(OS& os) const;
112 
116  template<typename OS>
117  static void print_assigned(OS& os);
118 
119 private:
120 
128  bool all_true;
129 
133  std::vector<bool> flags;
134 
138  static std::vector<std::string> names;
139 };
140 
141 } // ApplicationCore
142 
143 } // FuelCell
144 
145 #endif
bool all_true
Sometimes, actions have to be taken by all means.
Definition: event.h:128
static std::vector< std::string > names
The actual list of names of events.
Definition: event.h:138
static void print_assigned(OS &os)
List the names to a stream.
Event & operator+=(const Event &other)
Add the flags of the other Event object.
void print(OS &os) const
List the flags to a stream.
Event()
Constructor, generating a clear Event object with all flags set to false.
void all()
Set all flags to true.
bool any() const
Return true if any event is set to true.
Event & operator-=(const Event &other)
Clear the flags of the other Event object.
std::vector< bool > flags
The actual list of events.
Definition: event.h:133
Objects of this kind are used to notify interior applications of changes provoked by an outer loop...
Definition: event.h:51
static Event assign(const char *name)
This function registers a new event type and assigns a unique identifier to it.
bool test(const Event &other) const
Test whether all the flags set to true in the other Event object are also set to true in this one...
void clear()
Set all flags to false.