diff options
Diffstat (limited to 'core/continuous_property.hpp')
-rw-r--r-- | core/continuous_property.hpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/core/continuous_property.hpp b/core/continuous_property.hpp new file mode 100644 index 0000000..bed37cf --- /dev/null +++ b/core/continuous_property.hpp @@ -0,0 +1,93 @@ +#ifndef H3OuNUuw3KK0wmZozXqMmrvzz3M +#define H3OuNUuw3KK0wmZozXqMmrvzz3M + +#include <inttypes.h> +#include <boost/mpl/bool.hpp> + +#include "context.hpp" +#include "index_global.hpp" +#include "index_spike.hpp" +#include "index_spike_arrival.hpp" +#include "pointers.hpp" +#include "quant_types.hpp" +#include "time.hpp" + +//////////////////////////////////////////////////////////////////////////////// +// event related actions +//////////////////////////////////////////////////////////////////////////////// + +// evolve in time - default case: value remains the same +template<typename PropComp, typename Prop, typename Quant, typename Context> +struct ContinuousProperty_Evolve { + static inline typename Prop::type eval + (PropComp &, Context context, Time t, Time dt); +}; + +// apply an incoming event - default case: do not send anything +template<typename PropComp, typename Prop, typename Quant, typename EventQuant, + typename Context, typename IntentMap, typename Transaction> +struct ContinuousProperty_Apply { + static inline void eval(PropComp &, Context, Time, IntentMap &, Transaction &) {} +}; + +// apply an incoming event: do we change the prop val at all? +template<typename Prop, typename SrcQ> +struct ContinuousProperty_ApplyChangesProp : boost::mpl::bool_<false> {}; + +// generate an outgoing event - default case: generate nothing +template<typename Prop, typename Quant, typename EventQuant> +struct ContinuousProperty_Generate { + template<typename PropComp, typename Context, typename MQ, typename MI> + static inline void eval(PropComp &, Context, Time, typename Prop::type &, + MI &, MQ &) {} + static const bool changesValue = false; +}; + +//////////////////////////////////////////////////////////////////////////////// +// definition helpers +//////////////////////////////////////////////////////////////////////////////// + +#define GEN_CP(Quant, nameT, nameS, ValueType, InitialVal) \ +struct nameT { \ + typedef ValueType type; \ + typedef Quant quant; \ + typedef Quant::instance_ptr_t instance_ptr_t; \ + \ + static const ValueType initialValue; \ + static const uint32_t size = sizeof(ValueType); \ + static const char* const name; \ +}; \ + \ +const char* const nameT::name = nameS; \ +const ValueType nameT::initialValue{InitialVal}; + +#define GEN_CPL_EVOLVE(nameT) \ +template<typename PropComp, typename Context> \ +struct ContinuousProperty_Evolve<PropComp, nameT, nameT::quant, Context> { \ + inline static nameT::type eval(PropComp &pc, Context context, Time t, Time td) + +#define GEN_CP_EVOLVE(nameT, ReturnVal) \ +GEN_CPL_EVOLVE(nameT) { \ + return ReturnVal; \ + } \ +}; + +#define GEN_CP_APPLY(Property, EventQuant, ChangeProp) \ +template<> \ +struct ContinuousProperty_ApplyChangesProp<Property, EventQuant> \ + : boost::mpl::bool_<ChangeProp> {}; \ + \ +template<typename PropComp, typename Quant, typename Context, typename IntentMap, typename Transaction> \ +struct ContinuousProperty_Apply<PropComp, Property, Quant, EventQuant, Context, IntentMap, Transaction> { \ + typedef boost::mpl::bool_<ChangeProp> changeProp_t; \ + static inline void eval(PropComp &pc, Context context, Time t, IntentMap &intent, Transaction &transaction) + +#define GEN_CP_GENERATE(CQ, DQ, Prop) \ +template<> \ +struct ContinuousProperty_Generate<Prop, CQ, DQ> { \ + static const bool changesValue = true; \ + template<typename PropComp, typename Context, typename MQ, typename MI> \ + static inline void eval(PropComp &pc, Context context, Time t, \ + Prop::type &value, MI &indices, MQ &queues) + +#endif // H3OuNUuw3KK0wmZozXqMmrvzz3M |