#ifndef sOuC39DJVwHiStoyuZdritpuC5M #define sOuC39DJVwHiStoyuZdritpuC5M #include #include #include #include #include #include #include "pointers.hpp" #include "time.hpp" #include "type_set.hpp" /* methods common to all context's getptr() -> return an instance id */ namespace ContextImpl { using namespace boost; using namespace boost::mpl; // common context (internal) template struct CCtx : public TypeSet...> { CCtx(Ptr... ids) : TypeSet...>(std::move(ids)...) {} template typename Quant::instance_ptr_t getptr() { return this->template get>(); } }; /// SingleContext: stores a single quant w/o any relation template struct SingleContext : public CCtx { SingleContext(Ptr id) : CCtx(id) {} }; /// ContinuousContext: resembles the global <- neuron <- synapse hierarchy template struct ContinuousContext; template<> struct ContinuousContext : CCtx { ContinuousContext() : CCtx(Ptr()) {} explicit ContinuousContext(Ptr p) : CCtx(p) {} }; template<> struct ContinuousContext : CCtx { explicit ContinuousContext(Ptr p) : CCtx(p, Ptr()) {} }; template<> struct ContinuousContext : CCtx { explicit ContinuousContext(Ptr p) : CCtx(p, p.extractNeuron(), Ptr()) {} }; // common context with one discrete ptr (internal) template struct DCtx { DCtx(Ptr did, Ptr cid) : id(did), sub(cid) {} template typename Quant::instance_ptr_t getptr() { if (boost::is_same::value) { return FORCE_CONV(typename Quant::instance_ptr_t, id); }else{ return sub.getptr(); } } friend std::ostream& operator<< (std::ostream &os, DCtx val) { return os << val.id << ":" << val.sub; } Ptr id; ContinuousContext sub; }; /// DelieverContext: when a (discrete) event is delievered to a /// continuous quantity template struct DelieverContext : DCtx { DelieverContext(Ptr did, Ptr cid) : DCtx(did, cid) {} }; // HACK: allow Neuron to access Synapse on SpikeArrival; this only // works because SA is send with a zero delay, so synapse is already // evolved to current time template<> struct DelieverContext : DCtx { DelieverContext(boost::tuple, Ptr> t, Ptr) : DCtx(t.get<0>(), t.get<1>()) {} }; /// EmitContent: CQ emits event of class DQ template struct EmitContext : DCtx { EmitContext(Ptr cid, Ptr did) : DCtx(did, cid) {} }; } using ContextImpl::SingleContext; using ContextImpl::ContinuousContext; using ContextImpl::DelieverContext; using ContextImpl::EmitContext; #endif // sOuC39DJVwHiStoyuZdritpuC5M