OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
Objects of this kind are used to notify interior applications of changes provoked by an outer loop. More...
#include <event.h>
Public Member Functions | |
Event () | |
Constructor, generating a clear Event object with all flags set to false . More... | |
void | all () |
Set all flags to true . More... | |
void | clear () |
Set all flags to false . More... | |
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. More... | |
bool | any () const |
Return true if any event is set to true . More... | |
Event & | operator+= (const Event &other) |
Add the flags of the other Event object. More... | |
Event & | operator-= (const Event &other) |
Clear the flags of the other Event object. More... | |
template<typename OS > | |
void | print (OS &os) const |
List the flags to a stream. More... | |
Static Public Member Functions | |
static Event | assign (const char *name) |
This function registers a new event type and assigns a unique identifier to it. More... | |
template<typename OS > | |
static void | print_assigned (OS &os) |
List the names to a stream. More... | |
Private Attributes | |
bool | all_true |
Sometimes, actions have to be taken by all means. More... | |
std::vector< bool > | flags |
The actual list of events. More... | |
Static Private Attributes | |
static std::vector< std::string > | names |
The actual list of names of events. More... | |
Objects of this kind are used to notify interior applications of changes provoked by an outer loop.
They are handed to the application through ApplicationBase::notify() and it is up to the actual application how to handle them.
Event is organized as an extensible binary enumerator. Every class can add its own events using assign(). A typical code example is
class A { static Event event; };
Event A::event = Event::assign("Event for A");
FuelCell::ApplicationCore::Event::Event | ( | ) |
Constructor, generating a clear Event object with all flags set to false
.
void FuelCell::ApplicationCore::Event::all | ( | ) |
Set all flags to true
.
bool FuelCell::ApplicationCore::Event::any | ( | ) | const |
Return true
if any event is set to true
.
|
static |
This function registers a new event type and assigns a unique identifier to it.
All flags are set to false
. The flag for this new event type is set to true
. The result of this function should be stored for later use.
void FuelCell::ApplicationCore::Event::clear | ( | ) |
Set all flags to false
.
Add the flags of the other Event object.
Clear the flags of the other Event object.
void FuelCell::ApplicationCore::Event::print | ( | OS & | os | ) | const |
List the flags to a stream.
|
static |
List the names to a stream.
bool FuelCell::ApplicationCore::Event::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.
|
private |
Sometimes, actions have to be taken by all means.
Therefore, if this value is true, test() always returns true.
|
private |
The actual list of events.
|
staticprivate |
The actual list of names of events.