The Sparta Modeling Framework
|
The State class for watching transition between enum states. More...
#include <State.hpp>
Classes | |
class | Marker |
Class that will mark the state for transition. More... | |
class | Monitor |
Monitor a particular State value and allow the user to determine a full state change. More... | |
Public Types | |
typedef MetaDataT * | MetaDataTPtr |
A peeter to the MetaData. | |
typedef std::conditional<!std::is_same< EnumT, bool >::value, typenameutils::Enum< EnumT >::Value, BoolEnum >::type | EnumTValueType |
Convert the EnumT to a EnumT::Value or BoolEnum type. | |
typedef std::conditional<!std::is_same< EnumT, bool >::value, EnumT, BoolEnum::BoolValue >::type | EnumType |
If EnumT is not an actual enum, we need to use. | |
Public Member Functions | |
State (const EnumTValueType &initial_value=EnumType::__FIRST) | |
Construct a State class. | |
State (const State &other) | |
Copy Constructor for State. | |
State & | operator= (const State &)=delete |
Deleting default assignment operator to prevent copies. | |
virtual | ~State () |
Virtual destructor. | |
const EnumTValueType & | getValue () const |
Get the current value of the state. | |
const EnumType & | getEnumValue () const |
Scheduler::Tick | getTimeInState () const |
void | setValue (const EnumTValueType &val) |
Set a new enum value explicit and fire observers. | |
void | reset () |
Reset this State class. | |
void | reset (const EnumTValueType &val) |
Reset this State class to the given value. | |
void | operator= (const EnumTValueType &val) |
Assign a new state. | |
bool | operator== (const EnumTValueType &rhs_val) const |
bool | operator!= (const EnumTValueType &rhs_val) const |
Marker * | newMarker (const EnumTValueType &val) |
Get a new marker for the enum type. | |
uint32_t | numMarks (const EnumTValueType &val) const |
Get the number of marks for the enum type. | |
uint32_t | numMarkers (const EnumTValueType &val) const |
Get the number of markers for the enum type. | |
bool | complete (const EnumTValueType &val) const |
For a particular value, have all the marks been made. | |
void | setMarkedThreshold (const EnumTValueType &val, uint32_t thresh) |
Set the marker set threshold for the given state value. | |
bool | isSet (const EnumTValueType &val=BoolEnum::BoolValue::TRUE) const |
Determine if the State was ever set to value val. | |
bool | isClear (const EnumTValueType &val=BoolEnum::BoolValue::TRUE) const |
Determine if the State value is clear (never set) | |
void | observe (const EnumTValueType &val, const ScheduleableHandle &ev_hand) |
Observe this state, specifically, when it transitions to the given enum val. | |
void | withdraw (const EnumTValueType &val, const ScheduleableHandle &ev_hand) |
withdraw event from this state | |
void | release (const EnumTValueType &val) |
void | attachMonitor (const EnumTValueType &val, Monitor *mon) |
Attach a Monitor to a state value. | |
void | detachMonitor (const EnumTValueType &val, Monitor *mon) |
Decouple a monitor from a state value. | |
Friends | |
class | MarkerSet |
The State class for watching transition between enum states.
The State classes are intended to encapsulate Object state values (typically in an enum) such that state changes can be observed by other objects – i.e. via the GoF observer design pattern.
State which must be jointly updated by several objects before changing is implemented via state markers. For instance, if a State consists of a READY state in its enum declaration, and there are two rules for a READY state transition, each rule is represented by a State<EnumT>::Marker, which must be set before the state can transition to READY.
The State class supports observation of an enum type from one value to another, but the State is exclusive – it can ONLY be only value at a time.
State classes take two template parameters: the Enum type (enum class or just standard enum) and the anticapted maximum number of markers that will be requested – default is 13. Because the State class is in the critical path for most performance modeling applications, use of STL types is discouraged.
typedef std::conditional<!std::is_same<EnumT,bool>::value,typenameutils::Enum<EnumT>::Value,BoolEnum>::type sparta::State< EnumT, MetaDataT, MAX_MARKERS >::EnumTValueType |
typedef std::conditional<!std::is_same<EnumT,bool>::value,EnumT,BoolEnum::BoolValue>::type sparta::State< EnumT, MetaDataT, MAX_MARKERS >::EnumType |
typedef MetaDataT* sparta::State< EnumT, MetaDataT, MAX_MARKERS >::MetaDataTPtr |
|
inline |
Construct a State class.
initial_value | The initial value; __FIRST is not given |
|
inline |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
This methods returns the amount of time in Scheduler Ticks, this sparta::State instance has been residing in its current state. Requires StateTracking to be enabled.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Observe this state, specifically, when it transitions to the given enum val.
val | The value to observe |
ev_hand | The Scheduleable to schedule when the observation is made |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
withdraw event from this state
val | The value to observe |
ev_hand | The Scheduleable that needs to be withdrawn |
|
friend |