From: <mk...@us...> - 2003-09-07 16:46:00
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Include In directory sc8-pr-cvs1:/tmp/cvs-serv6186 Modified Files: System.h Log Message: Index: System.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Include/System.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** System.h 7 Sep 2003 16:40:37 -0000 1.1 --- System.h 7 Sep 2003 16:45:55 -0000 1.2 *************** *** 167,227 **** - // interface event visitors - - class EventVisitor: public SystemVisitor { - bool m_handled; - public: - typedef simdata::Ref<EventVisitor> Ref; - EventVisitor(): m_handled(false) {} - bool handled() const { return m_handled; } - void apply(System &system) { - if (m_handled) return; - m_handled = check(system); - if (!m_handled) traverse(system); - } - protected: - virtual bool check(System &system) = 0; - }; - - - class OnCommandVisitor: public EventVisitor { - std::string const &m_id; - int m_x, m_y; - public: - OnCommandVisitor(std::string const &id, int x, int y): - EventVisitor(), m_id(id), m_x(x), m_y(y) {} - protected: - bool check(System &system) { - return system.onCommand(m_id, m_x, m_y); - } - }; - - - class OnAxisVisitor: public EventVisitor { - std::string const &m_id; - double m_value; - public: - OnAxisVisitor(std::string const &id, double value): - EventVisitor(), m_id(id), m_value(value) {} - protected: - bool check(System &system) { - return system.onAxis(m_id, m_value); - } - }; - - - class OnMotionVisitor: public EventVisitor { - std::string const &m_id; - int m_x, m_y, m_dx, m_dy; - public: - OnMotionVisitor(std::string const &id, int x, int y, int dx, int dy): - EventVisitor(), m_id(id), m_x(x), m_y(y), m_dx(dx), m_dy(dy) {} - protected: - virtual bool check(System &system) { - return system.onMotion(m_id, m_x, m_y, m_dx, m_dy); - } - }; - class Model: public System { --- 167,177 ---- + /** Base class for detailed vehicle models. + * + * Model classes serve as the root node of System trees. The + * model defines a data bus shared by all systems it contains, + * and serves as the external interface of the composite system. + */ class Model: public System { *************** *** 284,286 **** --- 234,293 ---- } + + + // interface event visitors + + class EventVisitor: public SystemVisitor { + bool m_handled; + public: + typedef simdata::Ref<EventVisitor> Ref; + EventVisitor(): m_handled(false) {} + bool handled() const { return m_handled; } + void apply(System &system) { + if (m_handled) return; + m_handled = check(system); + if (!m_handled) traverse(system); + } + protected: + virtual bool check(System &system) = 0; + }; + + + class OnCommandVisitor: public EventVisitor { + std::string const &m_id; + int m_x, m_y; + public: + OnCommandVisitor(std::string const &id, int x, int y): + EventVisitor(), m_id(id), m_x(x), m_y(y) {} + protected: + bool check(System &system) { + return system.onCommand(m_id, m_x, m_y); + } + }; + + + class OnAxisVisitor: public EventVisitor { + std::string const &m_id; + double m_value; + public: + OnAxisVisitor(std::string const &id, double value): + EventVisitor(), m_id(id), m_value(value) {} + protected: + bool check(System &system) { + return system.onAxis(m_id, m_value); + } + }; + + + class OnMotionVisitor: public EventVisitor { + std::string const &m_id; + int m_x, m_y, m_dx, m_dy; + public: + OnMotionVisitor(std::string const &id, int x, int y, int dx, int dy): + EventVisitor(), m_id(id), m_x(x), m_y(y), m_dx(dx), m_dy(dy) {} + protected: + virtual bool check(System &system) { + return system.onMotion(m_id, m_x, m_y, m_dx, m_dy); + } + }; |