|
@@ -42,6 +42,7 @@ namespace artis {
|
|
|
|
|
|
Observer(const common::Model<Time>* model)
|
|
|
:
|
|
|
+ _step(0),
|
|
|
_model(model) { }
|
|
|
|
|
|
virtual ~Observer()
|
|
@@ -69,12 +70,38 @@ namespace artis {
|
|
|
return v;
|
|
|
}
|
|
|
|
|
|
- const View<Time>& view(const std::string& name) const { return *_views.find(name)->second; }
|
|
|
+ const View<Time>& view(const std::string& name) const
|
|
|
+ {
|
|
|
+ return *_views.find(name)->second;
|
|
|
+ }
|
|
|
|
|
|
const Views& views() const { return _views; }
|
|
|
|
|
|
void init() { }
|
|
|
|
|
|
+ void observe(double t, double next_t)
|
|
|
+ {
|
|
|
+ if (_step == 0) {
|
|
|
+ observe(t);
|
|
|
+ } else {
|
|
|
+ double time = std::ceil(t / _step) * _step;
|
|
|
+
|
|
|
+ while (time < next_t) {
|
|
|
+ observe(time);
|
|
|
+ time += _step;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void switch_to_timed_observer(double step)
|
|
|
+ {
|
|
|
+
|
|
|
+ assert(step > 0);
|
|
|
+
|
|
|
+ _step = step;
|
|
|
+ }
|
|
|
+
|
|
|
+ private:
|
|
|
void observe(double t)
|
|
|
{
|
|
|
for (typename Views::iterator it = _views.begin(); it != _views.end();
|
|
@@ -83,7 +110,7 @@ namespace artis {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private:
|
|
|
+ double _step;
|
|
|
const common::Model<Time>* _model;
|
|
|
Views _views;
|
|
|
};
|