/* * DNN - Data News Network * * by Stephane Chatty * * Copyright 1993-1995 * Centre d'Etudes de la Navigation Aerienne (CENA) * * Behaviours. * * $Id$ * $CurLog$ */ #ifndef DnnBehaviour_H_ #define DnnBehaviour_H_ #include "cplus_bugs.h" #include "ccu/Automaton.h" class DnnEvent; // en cours de developpement. template class DnnStateOf; template class DnnActionOf : public CcuBaseLink { protected: T& Object; void (T::*Action) (DnnStateOf*, DnnStateOf*, DnnEvent*); void Fire (CcuBaseState* f, CcuBaseState* t, CcuToken* k) { if (Action) (Object.*Action) ((DnnStateOf*) f, (DnnStateOf*) t, (DnnEvent*) k);} public: DnnActionOf (DnnStateOf* s, DnnEventType* k, T& o, void (T::*a) (DnnStateOf*, DnnStateOf*, DnnEvent*)) : CcuBaseLink (s), Object (o), Action (a) {} ~DnnActionOf () {} }; #if 0 /* future version of States: they create reactions associated to their links when entered. */ class DnnSuperState : public CcuBaseState { protected: CcuListOf Criteria; void In (); void Out (); public: DnnSuperState (const char* n, CcuAutomaton& b) : CcuBaseState (n, b) {} ~DnnSuperState (); void CreateLink (DnnSuperState*, DnnCriterion*); }; template class DnnStateOf : public CcuBaseState { protected: void In () {} void Out () {} public: DnnStateOf (const char* n, DnnBehaviourOf& b) : CcuBaseState (n, b) {} ~DnnStateOf () {} void CreateLink (DnnStateOf* to, DnnEventType* k, T& o, void (T::*a) (DnnStateOf*, DnnStateOf*, DnnEvent*)) { CcuHashCellOf * c = Links.Add (k); c->SetInfo (new DnnActionOf (to, k, o, a)); } }; template class DnnBehaviourOf : public CcuBaseAutomaton { protected: static CcuKey* GetEventType (CcuToken*); public: DnnBehaviourOf () : CcuBaseAutomaton (&GetEventType) {} ~DnnBehaviourOf () {} DnnStateOf* CreateState (const char* n) { DnnStateOf* s = new DnnStateOf (n, *this); AllStates.Append (s); return s; } }; template CcuKey* DnnBehaviourOf :: GetEventType (CcuToken* t) { DnnEvent* e = (DnnEvent*) t; return (CcuKey*) e->GetType (); } // tentative du 20/11/95 template class DnnInteractionOf : public CcuAutomIter { DnnInteractionOf (DnnBehaviourOf& b) : CcuAutomIter (b) {} }; #endif #endif /* DnnBehaviour_H_ */