Просмотр исходного кода

dtss: use time step parameter of coordinator

Eric Ramat 2 лет назад
Родитель
Сommit
ea00e6ec18

+ 3 - 1
src/artis-star/kernel/dtss/Coordinator.hpp

@@ -58,7 +58,7 @@ public:
     _graph_manager(this, parameters, graph_parameters),
     _time_step(parameters.time_step) {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator() = default;
 
   GraphManager &get_graph_manager() { return _graph_manager; }
 
@@ -255,6 +255,8 @@ public:
     return type::_tn;
   }
 
+  const typename Time::type &time_step() const { return _time_step; }
+
 private:
   GraphManager _graph_manager;
   typename Time::type _time_step;

+ 13 - 15
src/artis-star/kernel/dtss/GraphManager.hpp

@@ -43,11 +43,11 @@ public:
   typedef GraphManager<Time, Parameters, GraphParameters> type;
 
   struct ModelPort {
-    common::Model <Time> *model;
+    common::Model<Time> *model;
     unsigned int port_index;
     type *graph_manager;
 
-    ModelPort(common::Model <Time> *model, unsigned int port_index)
+    ModelPort(common::Model<Time> *model, unsigned int port_index)
       : model(model),
         port_index(port_index),
         graph_manager(nullptr) {}
@@ -57,7 +57,7 @@ public:
     }
   };
 
-  GraphManager(common::Coordinator <Time> *coordinator,
+  GraphManager(common::Coordinator<Time> *coordinator,
                const Parameters & /* parameters */,
                const GraphParameters & /* graph_parameters */)
     :
@@ -75,7 +75,7 @@ public:
     return p;
   }
 
-  void dispatch_events(common::event::Bag <Time> bag, typename Time::type t) {
+  void dispatch_events(common::event::Bag<Time> bag, typename Time::type t) {
     for (auto &ymsg: bag) {
       typename common::Links<Time>::Result result_model = _link_list.find(
         ymsg.get_model(),
@@ -94,23 +94,21 @@ public:
     }
   }
 
-  virtual void
-  dispatch_events_to_parent(common::Node <Time> node, const common::event::Value &content,
-                            typename Time::type t) {
-    common::event::Bag <Time> ymessages;
+  virtual void dispatch_events_to_parent(common::Node<Time> node, const common::event::Value &content,
+                                         typename Time::type t) {
+    common::event::Bag<Time> ymessages;
 
     ymessages.push_back(common::event::ExternalEvent<Time>(node, content));
 
     if (common::GraphManager<Time>::_coordinator->get_parent()) {
-      dynamic_cast < common::Coordinator <Time> * >(common::GraphManager<Time>::_coordinator
-        ->get_parent())
-        ->dispatch_events(ymessages, t);
+      dynamic_cast < common::Coordinator<Time> * >(common::GraphManager<Time>::_coordinator
+        ->get_parent())->dispatch_events(ymessages, t);
     }
   }
 
   virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
 
-  void post_event(typename Time::type t, const common::event::ExternalEvent <Time> &event) {
+  void post_event(typename Time::type t, const common::event::ExternalEvent<Time> &event) {
     typename common::Links<Time>::Result result =
       _link_list.find(common::GraphManager<Time>::_coordinator,
                       event.port_index());
@@ -135,8 +133,8 @@ public:
   }
 
 private:
-  void add_link(common::Model <Time> *src_model, unsigned int src_port_index,
-                common::Model <Time> *dst_model, unsigned int dst_port_index) {
+  void add_link(common::Model<Time> *src_model, unsigned int src_port_index,
+                common::Model<Time> *dst_model, unsigned int dst_port_index) {
     assert((src_model != common::GraphManager<Time>::_coordinator and
             dst_model != common::GraphManager<Time>::_coordinator and
             src_model->exist_out_port(src_port_index) and
@@ -153,7 +151,7 @@ private:
     _link_list.add(src_model, src_port_index, dst_model, dst_port_index);
   }
 
-  common::Links <Time> _link_list;
+  common::Links<Time> _link_list;
 };
 
 } // namespace artis dtss

+ 2 - 2
src/artis-star/kernel/dtss/Simulator.hpp

@@ -64,12 +64,12 @@ class Simulator : public common::Simulator<Time> {
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public:
-  Simulator(const std::string &name, const Parameters &parameters)
+  Simulator(const std::string &name, const Parameters &parameters, const typename Time::type &time_step)
     :
     common::Model<Time>(name),
     common::Simulator<Time>(name),
     _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this)),
-    _time_step(parameters.time_step) {}
+    _time_step(time_step) {}
 
   ~Simulator() {}