Ryan's District
November 22, 2008, 03:40:47 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Ryan's District Lottery: Claim your ticket or check
Jackpot details  
 
   Home   Help Search Chat Calendar Chess Shop Login Register  
Digg This!
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: c++ tips - Finite state machines and inheritance  (Read 2510 times)
0 Members and 1 Guest are viewing this topic.
ben2ong2
Quality Poster
Paid
Hero Member
*****

Reputation: 17
Offline Offline

Gender: Male
Posts: 2374
9976.80 RD$

View Inventory
Send Money to ben2ong2

View Profile Awards
« on: October 07, 2006, 03:08:13 AM »

PROBLEM: aissa@bnr.ca (Al Issa)

I am looking for some information regarding implementing a Finite State
Machine base class in C++. There seems to be some innate problems with
inheriting from FSMs.


RESPONSE: rmartin@rcmcon.com (Robert Martin), 21 Jun 93

There are indeed problems with inheriting from FSMs.  However, you can
decompose an FSM into two component parts, one of which CAN support
derivation.

When an FSM receives an event, it undergoes a transition.  Associated
with every transition is a set of behaviors.  If we gather all the
behaviors into a class, then this class harbors all the functionality
of the FSM with none of the sequencing or control.  I call this class
the Context.  The Context of a finite state machine can be extended
through inheritance. 

The other part of an FSM is the control element.  This can be created
as a single inheritance hierarchy; a base class for all the states
which has virtual functions for all the events.  Each state is
supported by its own derivation from the base state, and all the
virtual event functions are overridden. 

Inheriting anything from these classes which implement the control
element of the FSM is pretty meaningless.  But there is very little
code withing these classes.  They represent the "wiring" which
controls the sequencing of the execution of the behaviors within the
context.

New FSMs can be created from old ones by derivation, IF the context
and control are separated.  The context can be extended with new
capabilities, and then given a new set of control elements.

I have a simple yacc/lex program for DOS and UNIX which converts a
simple textual representation of a State/Transition table into a set
of classes which obey the above model.  Anyone interested, just drop
me a line and I'll email it to you.

[ I have the latest. -adc ]

Logged

You are not allowed to view links.
Register or Login
Free Paid Survey & Home Business Resources.

You are not allowed to view links.
Register or Login
Free Article Directory | Quality Content
Ryan's District
« on: October 07, 2006, 03:08:13 AM »

 Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Archive - WAP2 - WAP - imode
Sponsors: RAYAN.tv
-

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 1.312 seconds with 31 queries.

Google visited last this page Yesterday at 07:51:28 AM