Update of /cvsroot/csp/APPLICATIONS/CSPSim/Include
In directory sc8-pr-cvs1:/tmp/cvs-serv31976/Include
Modified Files:
Tag: systems
System.h
Log Message:
Index: System.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Include/System.h,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C2 -d -r1.3.2.2 -r1.3.2.3
*** System.h 29 Sep 2003 06:46:11 -0000 1.3.2.2
--- System.h 11 Oct 2003 06:43:15 -0000 1.3.2.3
***************
*** 32,35 ****
--- 32,36 ----
#include <SynchronousUpdate.h>
#include <InputInterface.h>
+
#include <SimData/Object.h>
#include <SimData/InterfaceRegistry.h>
***************
*** 214,353 ****
SIMDATA_VISITABLE(SystemVisitor);
};
-
-
-
- class PhysicsModel;
- class Controller;
- class DataRecorder;
-
- /** Base class for detailed vehicle models.
- *
- * Systems 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 SystemsModel: public System {
-
- Bus::Ref m_Bus;
-
- bool m_Bound;
-
- virtual void setModel(SystemsModel *) {}
-
- class FindSystemByNameVisitor: public simdata::FindVisitor<System,SystemVisitor> {
- std::string m_Name;
- public:
- FindSystemByNameVisitor(std::string const &name):
- simdata::FindVisitor<System,SystemVisitor>(), m_Name(name) {}
- virtual bool match(System &s) { return s.getName() == m_Name; }
- };
-
- class EventVisitor: public SystemVisitor {
- bool m_handled;
- MapEvent m_event;
- public:
- typedef simdata::Ref<EventVisitor> Ref;
- EventVisitor(MapEvent const &event): m_handled(false), m_event(event) {}
- bool handled() const { return m_handled; }
- void apply(System &system) {
- if (m_handled) return;
- m_handled = system.onMapEvent(m_event);
- if (!m_handled) traverse(system);
- }
- void apply(SystemsModel &model) { traverse(model); }
- };
-
- class InfoVisitor: public SystemVisitor {
- InfoList &m_info;
- public:
- InfoVisitor(InfoList &info): m_info(info) {}
- void apply(System &system) { system.getInfo(m_info); traverse(system); }
- void apply(SystemsModel &model) { traverse(model); }
- };
-
- simdata::Link<PhysicsModel> m_PhysicsModel;
- simdata::Link<Controller> m_Controller;
-
- protected:
- virtual ~SystemsModel() { }
-
- public:
-
- typedef simdata::Ref<SystemsModel> Ref;
-
- SIMDATA_OBJECT(SystemsModel, 0, 0)
-
- EXTEND_SIMDATA_XML_INTERFACE(SystemsModel, System)
- SIMDATA_XML("physics_model", SystemsModel::m_PhysicsModel, false)
- SIMDATA_XML("controller", SystemsModel::m_Controller, false)
- END_SIMDATA_XML_INTERFACE
-
- /** Initialize from an existing model.
- *
- * This method is called when a new model is bound to a vehicle,
- * allowing relevant state data from the old model to be preserved.
- *
- * @param other The previous model (may be NULL).
- */
- virtual void init(SystemsModel::Ref other) {}
-
- bool canBeAdded() const { return false; }
-
- template<typename T>
- void publish(std::string const &name, T const &value) {
- assert(!m_Bound);
- m_Bus->registerLocalDataChannel(name, value);
- }
-
- Bus::Ref getBus() const {
- assert(m_Bus.valid());
- return m_Bus;
- }
-
- virtual void postCreate();
- virtual void serialize(simdata::Archive &archive);
-
- simdata::Ref<PhysicsModel> getPhysicsModel() const;
-
- simdata::Ref<Controller> getController() const;
-
- void setDataRecorder(DataRecorder*);
-
- virtual void getInfo(InfoList &info);
-
- System::Ref getSystem(std::string const &name, bool required = true) {
- simdata::Ref< simdata::FindVisitor<System,SystemVisitor> > visitor;
- visitor = accept(new FindSystemByNameVisitor(name));
- System::Ref found = visitor->getNode();
- if (!found) {
- assert(!required);
- return 0;
- }
- return found;
- }
-
- void bindSystems() {
- assert(!m_Bound);
- BindVisitor::Ref binder = new BindVisitor(m_Bus.get());
- accept(binder);
- m_Bound = true;
- }
-
- SystemsModel(): m_Bound(false) {
- m_Model = this;
- m_Bus = new Bus("MODEL_BUS");
- }
-
- virtual bool onMapEvent(MapEvent const &event) {
- EventVisitor::Ref visitor = accept(new EventVisitor(event));
- return visitor->handled();
- }
-
- virtual void registerChannels(Bus *bus) {}
- virtual void importChannels(Bus *bus) {}
-
- SIMDATA_VISITABLE(SystemVisitor);
- };
-
--- 215,218 ----
|