|
@@ -28,6 +28,9 @@
|
|
#include <artis/kernel/Internals.hpp>
|
|
#include <artis/kernel/Internals.hpp>
|
|
#include <artis/kernel/States.hpp>
|
|
#include <artis/kernel/States.hpp>
|
|
|
|
|
|
|
|
+#include <artis/utils/DateTime.hpp>
|
|
|
|
+#include <artis/utils/Trace.hpp>
|
|
|
|
+
|
|
#include <functional>
|
|
#include <functional>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
|
|
@@ -54,12 +57,40 @@ class AbstractCoupledModel : public AbstractModel < U, V >,
|
|
};
|
|
};
|
|
|
|
|
|
public:
|
|
public:
|
|
- AbstractCoupledModel()
|
|
|
|
|
|
+ AbstractCoupledModel(const type* parent = 0) : type(parent)
|
|
{ }
|
|
{ }
|
|
|
|
|
|
virtual ~AbstractCoupledModel()
|
|
virtual ~AbstractCoupledModel()
|
|
{ }
|
|
{ }
|
|
|
|
|
|
|
|
+ virtual void after(typename U::type t)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
+ utils::KERNEL)
|
|
|
|
+ << " - AFTER - "
|
|
|
|
+ << AbstractCoupledModel < T, U, V, W >::path(this);
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ virtual void before(typename U::type t)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
+ utils::KERNEL)
|
|
|
|
+ << " - BEFORE - "
|
|
|
|
+ << AbstractCoupledModel < T, U, V, W >::path(this);
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
virtual void build(const W& /* parameters */)
|
|
virtual void build(const W& /* parameters */)
|
|
{ }
|
|
{ }
|
|
|
|
|
|
@@ -166,6 +197,44 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ virtual std::string path_index(const AbstractModel < U, V >* child,
|
|
|
|
+ int& index) const
|
|
|
|
+ {
|
|
|
|
+ typename Setsubmodels::const_iterator it = setsubmodels.begin();
|
|
|
|
+ bool found = false;
|
|
|
|
+
|
|
|
|
+ index = -1;
|
|
|
|
+ while (not found and it != setsubmodels.end()) {
|
|
|
|
+ typename std::vector < type* >::const_iterator itm =
|
|
|
|
+ it->second.begin();
|
|
|
|
+
|
|
|
|
+ index = 0;
|
|
|
|
+ while (not found and itm != it->second.end()) {
|
|
|
|
+ found = *itm == child;
|
|
|
|
+ if (not found) {
|
|
|
|
+ ++index;
|
|
|
|
+ ++itm;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ index = found ? index : -1;
|
|
|
|
+ ++it;
|
|
|
|
+ }
|
|
|
|
+ if (type::parent) {
|
|
|
|
+ int i;
|
|
|
|
+ std::string p = type::parent->path_index(this, i);
|
|
|
|
+
|
|
|
|
+ if (i >= 0) {
|
|
|
|
+ return p +
|
|
|
|
+ "/[" + std::to_string(i) + "]" +
|
|
|
|
+ boost::core::demangle(typeid(*this).name());
|
|
|
|
+ } else {
|
|
|
|
+ return p + "/" + boost::core::demangle(typeid(*this).name());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return boost::core::demangle(typeid(*this).name());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
virtual void restore(const State < U >& state)
|
|
virtual void restore(const State < U >& state)
|
|
{
|
|
{
|
|
typename AbstractCoupledModel::Submodels::const_iterator it =
|
|
typename AbstractCoupledModel::Submodels::const_iterator it =
|
|
@@ -248,7 +317,10 @@ protected:
|
|
}
|
|
}
|
|
|
|
|
|
void submodel(unsigned int index, type* model)
|
|
void submodel(unsigned int index, type* model)
|
|
- { submodels[index] = model; }
|
|
|
|
|
|
+ {
|
|
|
|
+ submodels[index] = model;
|
|
|
|
+ model->set_parent(this);
|
|
|
|
+ }
|
|
|
|
|
|
void S(std::initializer_list < std::pair < unsigned int,
|
|
void S(std::initializer_list < std::pair < unsigned int,
|
|
type* > > models)
|
|
type* > > models)
|
|
@@ -257,6 +329,7 @@ protected:
|
|
type* > >::iterator it =
|
|
type* > >::iterator it =
|
|
models.begin(); it != models.end(); ++it) {
|
|
models.begin(); it != models.end(); ++it) {
|
|
submodels[it->first] = it->second;
|
|
submodels[it->first] = it->second;
|
|
|
|
+ it->second->set_parent(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -266,6 +339,7 @@ protected:
|
|
setsubmodels[index] = std::vector < type* >();
|
|
setsubmodels[index] = std::vector < type* >();
|
|
}
|
|
}
|
|
setsubmodels[index].push_back(model);
|
|
setsubmodels[index].push_back(model);
|
|
|
|
+ model->set_parent(this);
|
|
}
|
|
}
|
|
|
|
|
|
private:
|
|
private:
|