Newsgroups: comp.object
From: mar...@jpmvrealtime.com (Martin Vuille)
Date: Sun, 03 Sep 2000 01:31:33 GMT
Local: Sat, Sep 2 2000 9:31 pm
Subject: Re: Applying the State pattern
In article <39B10DE2.7C88D...@acm.org>, r...@acm.org wrote: This is not how I had interpreted the GoF's description of the >According to the state pattern, a class interacts with the state map via >a Context class. Since your classes differ on in behavior (they have >different FSMs), you *can* use inheritance and each derived class will >contain a different FSM context: > class BaseClass > class DerivedClass1 : public BaseClass > DerivedClass1() > // If you want to issue a transition, then ... >DerivedClass2 will be similar. State pattern. In my mind, DerivedClass1 _is_ the Context Class, i.e. the class that the rest of the system sees and uses. I don't see what benefit is provided by the FSMContext1 class above. >Regarding your second question, if the FSMs are different, then you will It may not make sense in terms of an IS-A relationship, but what I'm >need to create two different FSM context classes and all the concrete >states. I know there is the idea regarding have one FSM inherit and >extend a base FSM but I that idea does not make sense to me. really after is a mechanism for reusing the implementation of a class that is implemented as an FSMs. What I have come up with so far is to define a vector Each derived Context class' constructor would populate the list By using the Template pattern on the Context class for the methods I haven't yet figured out how the concrete states would refer Only thing is, this is anything but elegant, or easily comprehensible. MV Martin Vuille | Real-time and | Software & Firmware Contracting You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||