summaryrefslogtreecommitdiff
path: root/core/pla_initbycopy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/pla_initbycopy.hpp')
-rw-r--r--core/pla_initbycopy.hpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/core/pla_initbycopy.hpp b/core/pla_initbycopy.hpp
new file mode 100644
index 0000000..7fe6334
--- /dev/null
+++ b/core/pla_initbycopy.hpp
@@ -0,0 +1,70 @@
+#ifndef IsIx5LlrtRM4hjuaHq11FAgirk
+#define IsIx5LlrtRM4hjuaHq11FAgirk
+
+#include <assert.h>
+
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/if.hpp>
+
+#include "template_helpers.hpp"
+#include "time.hpp"
+#include "quant_types.hpp"
+
+#include "model.hpp" // for Weight
+
+namespace PLA_InitByCopy_Impl {
+
+using namespace boost;
+using namespace boost::mpl;
+
+template<typename Prop, typename QuantClass = typename Prop::quant::class_t>
+struct Action {
+ template<typename Data>
+ void operator() (Data &, Time) {} // NOOP on discrete quants
+};
+
+template<typename Prop>
+struct Action<Prop, ContinuousPropertyClass> {
+ typedef typename Prop::quant Quant;
+
+ template<typename Data>
+ void operator() (Data &data, Time time) {
+ PropertyInstance<Prop, true> src;
+ typedef typename if_<is_same<Quant, Global>,
+ uint8_t,
+ typename Prop::instance_ptr_t::ptr_t
+ >::type ptr_t;
+ assert(time <= src.data.timeLimit); // we do not want to cause addCheckpoint()
+ for (ptr_t i = 0; i < Prop::instance_ptr_t::numInstances(); i++)
+ data.data.set(src.data.getTime(time, i), i, src.data.getValue(time, i));
+ }
+};
+
+struct PLA_InitByCopy {
+ // action types & consts
+ typedef Void result_t;
+ template<typename ContextProp, bool _doWriteResults> struct local_state_t
+ : Action<ContextProp> {};
+
+ // action state
+ result_t result;
+ Time time;
+
+ PLA_InitByCopy(Time time) : time(time) {}
+
+ // action methods
+ template<typename _PC, typename ContextData, typename LocalState>
+ inline void pre(_PC &, ContextData &data, LocalState &action) {
+ action(data, time);
+ }
+
+ template<typename _PC, typename _Data, typename _LocalState>
+ inline void post(_PC &, _Data &, _LocalState &) { }
+};
+
+} // namespace PLA_InitByCopy_Impl
+
+using PLA_InitByCopy_Impl::PLA_InitByCopy;
+
+#endif // IsIx5LlrtRM4hjuaHq11FAgirk
contact: Jan Huwald // Impressum