1 #ifndef STATE_MACHINE_CLASS
2 #define STATE_MACHINE_CLASS
23 class state_machine_override_array;
24 class state_machine_state_array;
83 int last()
const {
return _last; }
86 int trigger()
const {
return _trig; }
143 state_machine_override_array *_overrides;
145 int duration_index(
int current,
int next)
const;
200 bool valid()
const {
return _valid; }
212 OKAY = basis::common::OKAY,
215 DEFINE_OUTCOME(OVERLAPPING_RANGES, -50,
"The ranges overlap for two "
216 "transitions from a state"),
217 DEFINE_OUTCOME(UNREACHABLE, -51,
"There is an unreachable state in the map")
314 state_machine_state_array *_state_list;
317 bool check_overlapping(
int &examine);
322 bool check_reachability(
int &examine);
325 int state_index(
int state_id)
const;
328 int transition_index(
int state_index,
int next,
int &start);
Provides a dynamically resizable ASCII character string.
Outcomes describe the state of completion for an operation.
Monitors objects with multiple states and the transitions between states.
void override_timing(int current, int next, int duration)
modifies the recorded timing for timed transitions.
virtual int update()
this is the main implementation function provided by derived classes.
int trigger() const
returns the trigger that caused this state.
basis::astring get_name() const
retrieves the object's current name.
int current() const
returns the current state.
void set_state(int new_current, int new_last, int trigger, transition_types type)
sets the current state to "new_current" and the previous state to "new_last".
timely::time_stamp start() const
start time for the current state.
bool timed() const
returns true if the last transition was a timed type.
int last() const
returns the last active state.
DEFINE_CLASS_NAME("state_machine")
bool simple() const
returns true if the last transition was a simple type.
bool ranged() const
returns true if the last transition was a ranged type.
state_machine()
sets up the machine in a blank state.
int duration_override(int current, int next) const
reports if there's a duration override for a timed transition.
void set_name(const basis::astring &name)
sets the name to be printed in any debugging information for "this".
state_machine & operator=(const state_machine &to_copy)
assigns this to a copy of the machine provided in "to_copy".
friend class transition_map
manager buddy object.
The transition_map manages state machines and causes state changes to occur.
bool add_range_transition(int current, int next, int low, int high)
adds a transition that listens to triggers in the pulse() method.
bool time_slice(state_machine &m)
bool set_start(int starting_state)
assigns a state as the first state.
virtual ~transition_map()
bool add_simple_transition(int current, int next)
adds a transition between "current" and "next".
bool make_transition(state_machine &m, int next)
changes the state to the "next" listed for "m" given the current state.
bool pulse(state_machine &m, int trigger)
applies a "trigger" to possibly cause a range transition.
bool valid() const
returns true if the transition_map is valid and ready for operation.
bool reset(state_machine &m)
void reconfigure()
puts the transition_map back into an unvalidated state.
int states() const
returns the current number of states.
bool add_state(int state_number)
registers a legal state in the transition_map.
DEFINE_CLASS_NAME("transition_map")
basis::outcome validate(int &examine)
checks to that all required transition conditions are satisfied.
bool add_timed_transition(int current, int next, int duration)
adds a transition that occurs after a timeout with no other activity.
Represents a point in time relative to the operating system startup time.