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


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