comp.lang.ada
 help / color / mirror / Atom feed
From: David Kristola <David95037@See-My.Sig>
Subject: Re: OO-Code for a state machine
Date: Sun, 24 Dec 2000 12:45:08 -0800
Date: 2000-12-24T12:45:08-08:00	[thread overview]
Message-ID: <01HW.B66BA0540192E8890541934C@news.pacbell.net> (raw)
In-Reply-To: 3A416FD9.C659BD5C@acm.org

On Wed, 20 Dec 2000 18:51:46 -0800, Charles Rapp wrote
(in message <3A416FD9.C659BD5C@acm.org>):

> Vincent,
> 
> There is SMC - The State Machine Compiler at http://smc.sourceforge.com.
> It takes a state machine description and generates either C++, Java or
> Tcl code which is based on the State pattern (for more on the State
> pattern, see the book "Design Patterns" by Gamma, Helm, Johnson and
> Vlissides, p. 310). However, SMC does not generate Ada code.
> 
> Vincent Smeets wrote:
>> 
>> Hallo,
>> 
>> For a long time, I have seen a posting from somebody who had a state
>> machine programmed with OO technics. It was a base which you could
>> extend with you own code to create you own state machine. Does somebody
>> know where I can find it?
>> 
>> Thanks,
>> Vincent
>> 
>> -- Vincent Smeets                 Competence Center Informatik GmbH
>> -- Tel. : +49-5931-805461         Postfach 1225
>> -- Fax  : +49-5931-805175         49702 Meppen, Germany
>> -- EMail: Vincent.Smeets@CCI.de   http://www.CCI.de/
>> -- PGP fingerprint: 53 1C 3B 6F B6 9A EB 83  B4 7E 25 08 78 BD 5C 2C
> 
> 

Vincent,

Below is the state class from one of my projects.  It is basically following
the "Design Patterns" State pattern mentioned by Charles.  I don't know if
this is what you are looking for, but pehaps it will help.  In this 
particular case, the session manager takes user input from sockets and 
dispatches that input to the appropriate Parse_Input routine.  Each session 
has a number of standard states to deal with establishing someone's identity, 
but then the user can (i should say "will be able to" since this part is not 
coded yet) select from a list of registered <fill in blank>.  Each one will 
have it's own parser state (to deal with the unique features).  Each one will 
register itself with a central entity during elaboration, providing an 
example object of that class, and some means of recognition.  That way, the 
new states can be used without recoding old states to transition to new ones.

   type State_Type is abstract new Ada.Finalization.Controlled with private;
   type State_Access_Type is access all State_Type'CLASS;

   procedure Parse_Input
      (State      : in out State_Type;
       Session    : in     Session_Access_Type;
       User_Input : in     String) is abstract;

   procedure Destroy
      (State : access State_Type) is abstract;

   procedure Create
      (Based_On : in     State_Type;
       Session  : in     Session_Access_Type;
       State    :    out State_Access_Type) is abstract;



-- 
--djk, keeper of arcane lore & trivial fluff
Home: David95036 plus 1 at america on-line
Spam: goto.hades@welovespam.com




  reply	other threads:[~2000-12-24 20:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-19 12:15 OO-Code for a state machine Vincent Smeets
2000-12-21  2:51 ` Charles Rapp
2000-12-24 20:45   ` David Kristola [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-12-19 14:28 Christoph Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox