FSMstate.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*-
00002  *
00003  *  Base class for finite state machine states
00004  *
00005  *  Copyright (C) 2007, 2010, Austin Robot Technology
00006  *
00007  *  License: Modified BSD Software License Agreement
00008  *
00009  *  $Id: FSMstate.h 435 2010-08-20 15:24:22Z jack.oquin $
00010  *
00011  *  Author: Jack O'Quin
00012  */
00013 
00014 #ifndef __FSM_STATE_H__
00015 #define __FSM_STATE_H__
00016 
00017 class FSMstate
00018 {
00019 public:
00020 
00021   // States in this base class are just for example.  State values are
00022   // overloaded for each real FSM definition.  Since state_t in the
00023   // subclasses differs from this, methods with state_t parameters
00024   // cannot be inherited from FSMstate.
00025   typedef enum
00026     {
00027       Start,                            // starting state
00028       Final,                            // final state
00029       N_states                          // total number of states
00030     } state_t;
00031 
00032   // return name of each state as a C string
00033   const char *Name(void)
00034   {
00035     static const char *state_name[N_states] =
00036       {
00037         "Start",
00038         "Final",
00039       };
00040     return state_name[state];
00041   }
00042 
00043   FSMstate()
00044   {
00045     this->state = Start;
00046   }
00047 
00048   ~FSMstate();
00049 
00050   void operator=(const FSMstate &newval)
00051   {
00052     this->state = newval.state;
00053   }
00054 
00055   bool operator==(const FSMstate &compare)
00056   {
00057     return (int) this->state == (int) compare.state;
00058   }
00059 
00060   bool operator!=(const FSMstate &compare)
00061   {
00062     return (int) this->state != (int) compare.state;
00063   }
00064 
00065 private:
00066 
00067   state_t state;                        // current state
00068 };
00069 
00070 #endif // __FSM_STATE_H__


art_nav
Author(s): Austin Robot Technology, Jack O'Quin
autogenerated on Fri Jan 3 2014 11:08:43