From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,41c25f37e08ff152 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-24 12:44:52 PST Path: supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cyclone0.chicago.il.ameritech.net!cyclone-sf.pbi.net!206.13.28.33!news.pacbell.net.POSTED!not-for-mail From: David Kristola Organization: heaps of stacks MIME-Version: 1.0 User-Agent: Hogwasher 2.0 (Macintosh) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <01HW.B66BA0540192E8890541934C@news.pacbell.net> Subject: Re: OO-Code for a state machine Newsgroups: comp.lang.ada References: <3A3F5157.1A806A7A@CCI.de> <3A416FD9.C659BD5C@acm.org> Date: Sun, 24 Dec 2000 12:45:08 -0800 NNTP-Posting-Host: 63.194.212.92 X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 977690692 63.194.212.92 (Sun, 24 Dec 2000 12:44:52 PST) NNTP-Posting-Date: Sun, 24 Dec 2000 12:44:52 PST Xref: supernews.google.com comp.lang.ada:3389 Date: 2000-12-24T12:45:08-08:00 List-Id: 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 . 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