#ifndef j9bZiR9W7dKz17gTUOtW1xODHdA #define j9bZiR9W7dKz17gTUOtW1xODHdA #include #include #include "context.hpp" #include "continuous_property.hpp" #include "property_instance.hpp" #include "property_list.hpp" #include "quant_types.hpp" #include "template_helpers.hpp" // worker template forward decl template struct PLA_Get_Impl; // PLA template template> struct PLA_Get { // action consts typedef typename Prop::type result_t; template struct local_state_t { typedef ContextProp prop; }; // action parameters typedef typename Prop::instance_ptr_t instance_t; typedef typename boost::mpl::if_, Time, Void>::type time_t; Context ctx; time_t time; result_t result; PLA_Get(time_t time, Context ctx) : ctx(ctx), time(time) {} PLA_Get(Context ctx) : ctx(ctx) { BOOST_STATIC_ASSERT((boost::is_same::value)); } // action methods template inline void pre(_PropComp &pc, _ContextData &data, _LocalState &state) { } template inline void post(PC &pc, ContextData &data, LocalState &state) { BOOST_MPL_ASSERT(( PL_Contains, Prop> )); PLA_Get_Impl ::eval(pc, data, ctx, time, result); } }; // worker template implementation // * do nothing at the wrong type template struct PLA_Get_Impl { template> static inline void eval(PC &, Data &, Context, typename PLA_Get::time_t, typename Prop::type &) { } }; // * store pointer to the data structure at the correct type template struct PLA_Get_Impl { template> static inline void eval(PC &pc, Data &data, Context ctx, typename PLA_Get::time_t time, typename Prop::type &fold_state) { Time oldTime = data.data.getTime(time, ctx.template getptr()()); assert(oldTime <= time); // we can not jump backward if (oldTime < time) { Time dt = time - oldTime; fold_state = ContinuousProperty_Evolve ::eval(pc, ctx, oldTime, dt); }else{ fold_state = data.data.getValue(time, ctx.template getptr()()); } } }; template struct PLA_Get_Impl { template> static inline void eval(PC &, Data &data, Context ctx, typename PLA_Get::time_t, typename Prop::type &fold_state) { fold_state = data.data(ctx.template getptr()()); } }; #endif // j9bZiR9W7dKz17gTUOtW1xODHdA