28#include <spdlog/spdlog.h>
45template <
typename SynapseType>
51 static void subscribe(
const typename core::Projection<SynapseType> &, knp::core::MessageEndpoint &) {}
60template <
template <
typename>
typename Rule,
typename SynapseType>
69 const typename core::Projection<knp::synapse_traits::STDP<Rule, SynapseType>> &p,
70 knp::core::MessageEndpoint &message_endpoint)
72 SPDLOG_TRACE(
"Subscribing method for the STDP projection {}...", std::string(p.get_uid()));
73 for (
const auto &[pop_uid, _] : p.get_shared_parameters().stdp_populations_)
75 SPDLOG_TRACE(
"Subscribing STDP projection {} to {}...", std::string(p.get_uid()), std::string(pop_uid));
76 if (pop_uid) message_endpoint.
subscribe<knp::core::messaging::SpikeMessage>(p.get_uid(), {pop_uid});
88template <
typename ProjectionContainer>
89void init(
const ProjectionContainer &projections, knp::core::MessageEndpoint &message_endpoint)
91 for (
const auto &p : projections)
93 const auto [pre_uid, post_uid, this_uid] = std::visit(
94 [&message_endpoint](
const auto &proj)
96 using T = std::decay_t<
decltype(proj)>;
98 return std::make_tuple(proj.get_presynaptic(), proj.get_postsynaptic(), proj.get_uid());
102 if (pre_uid) message_endpoint.
subscribe<knp::core::messaging::SpikeMessage>(this_uid, {pre_uid});
103 if (post_uid) message_endpoint.
subscribe<knp::core::messaging::SynapticImpactMessage>(post_uid, {this_uid});
Subscription< MessageType > & subscribe(const UID &receiver, const std::vector< UID > &senders)
Add a subscription to messages of the specified type from senders with given UIDs.
Message endpoint interface.
Common header for messaging.
Namespace for CPU backends.
void init(const ProjectionContainer &projections, knp::core::MessageEndpoint &message_endpoint)
Initialize backend.
General projection interface.
static void subscribe(const typename core::Projection< knp::synapse_traits::STDP< Rule, SynapseType > > &p, knp::core::MessageEndpoint &message_endpoint)
Subscribe projection to message endpoint.
static void subscribe(const typename core::Projection< SynapseType > &, knp::core::MessageEndpoint &)
Subscribe STDP projection to messages.