#ifndef Vaz5kkzRinGGCeloVow8grqZI1c #define Vaz5kkzRinGGCeloVow8grqZI1c // HINT: simple schema, based on the fact the this PLA changes only // props it does not depend on (read from) #include #include #include #include "context.hpp" #include "template_helpers.hpp" #include "time.hpp" namespace PLA_Generate_Impl { using namespace boost; using namespace boost::mpl; // local state // general case: no action (and zero storage) template struct LocalState { template inline void process(PropComp &, Context, Time, MI &, MQ &) {} template inline void commit(PropComp &, Context, Time) {} }; // matching case: get/set the value to local storage template struct LocalState { typename Prop::type val; template inline void process(PropComp &pc, Context context, Time time, MI &indices, MQ &queues) { // calc new val and store locally // TODO: check generation of discrete properties ContinuousProperty_Generate:: eval(pc, context, time, val, indices, queues); } template inline void commit(PropComp &pc, Context context, Time time) { // HINT: caller has to check if we should commit typedef typename Prop::quant Quant; Ptr dst(context.template getptr()); PLA_Set pla_set(time, dst, val); // TODO: omit time if Prop is discrete pc.call(pla_set); } }; // generate action template struct PLA_Generate { // action types & consts typedef Void result_t; template struct local_state_t : LocalState, is_same >::value> { typedef ContextProp prop; static const bool write = doWriteResults; }; typedef EmitContext context_t; // action state & constructor context_t context; Time time; result_t result; MI &indices; MQ &queues; PLA_Generate(Time time, context_t context, MI &indices, MQ &queues) : context(context), time(time), indices(indices), queues(queues) {} // action methods template inline void pre(PropComp &pc, LocalData &, LocalState &state) { // if we have the correct quantity (and ought to write to it) typedef typename LocalState::prop Prop; typedef typename Prop::quant Quant; if ( (is_same::value and ContinuousProperty_Generate ::changesValue) or (is_same::value and state.write)) state.process(pc, context, time, indices, queues); } template inline void post(PropComp &pc, _LocalData &data, LocalState &state) { typedef typename LocalState::prop Prop; typedef typename Prop::quant Quant; if ( (is_same::value and ContinuousProperty_Generate ::changesValue) or (is_same::value and state.write)) state.commit(pc, context, time); // ... store new value and time } private: PLA_Generate(); }; } using PLA_Generate_Impl::PLA_Generate; #endif // Vaz5kkzRinGGCeloVow8grqZI1c