29 #ifndef DILIGENT_CONNECTOR_MODEL_H 30 #define DILIGENT_CONNECTOR_MODEL_H 32 #include "connector_model_impl.h" 35 #include "connection_updater.h" 80 template <
typename ConnectionT >
88 bool has_delay =
true,
bool requires_symmetric =
false)
89 :
nest::GenericConnectorModel<ConnectionT>(name, is_primary, has_delay, requires_symmetric)
97 :
nest::GenericConnectorModel<ConnectionT>(other, name)
101 virtual nest::ConnectorBase*
add_connection(nest::Node& src, nest::Node& tgt, nest::ConnectorBase* conn,
102 nest::synindex syn_id,
double weight,
105 virtual nest::ConnectorBase*
add_connection(nest::Node& src, nest::Node& tgt, nest::ConnectorBase* conn,
106 nest::synindex syn_id, DictionaryDatum& d,
107 double weight,
double delay);
109 virtual nest::ConnectorBase*
delete_connection(nest::Node& tgt,
size_t target_thread,
110 nest::ConnectorBase* conn, nest::synindex syn_id);
112 virtual nest::ConnectorModel*
clone(std::string name)
const;
117 nest::ConnectorBase*
const conn,
const nest::synindex syn_id);
119 void register_connector(nest::ConnectorBase* new_conn, nest::ConnectorBase* old_conn, nest::index sender_gid,
120 size_t target_thread, nest::synindex syn_id);
122 nest::ConnectorBase*
get_hom_connector(nest::ConnectorBase* conn, nest::synindex syn_id);
143 template <
typename ConnectionT >
147 nest::ConnectorBase* conn,
148 nest::synindex syn_id,
152 nest::ConnectorBase* old_hom_conn =
get_hom_connector(nest::validate_pointer(conn), syn_id);
153 nest::ConnectorBase* new_conn = nest::GenericConnectorModel< ConnectionT >::add_connection(src, tgt, conn,
154 syn_id, delay, weight);
155 nest::ConnectorBase* new_hom_conn =
get_hom_connector(nest::validate_pointer(new_conn), syn_id);
156 register_connector(new_hom_conn, old_hom_conn, src.get_gid(), tgt.get_thread(), syn_id);
178 template <
typename ConnectionT >
182 nest::ConnectorBase* conn,
183 nest::synindex syn_id,
188 nest::ConnectorBase* old_hom_conn =
get_hom_connector(nest::validate_pointer(conn), syn_id);
189 nest::ConnectorBase* new_conn = nest::GenericConnectorModel< ConnectionT >::add_connection(src, tgt, conn, syn_id,
191 nest::ConnectorBase* new_hom_conn =
get_hom_connector(nest::validate_pointer(new_conn), syn_id);
192 register_connector(new_hom_conn, old_hom_conn, src.get_gid(), tgt.get_thread(), syn_id);
206 template <
typename ConnectionT >
209 size_t target_thread,
210 nest::ConnectorBase* conn,
211 nest::synindex syn_id)
213 nest::ConnectorBase* old_hom_conn =
get_hom_connector(nest::validate_pointer(conn), syn_id);
215 nest::ConnectorBase* new_hom_conn =
get_hom_connector(nest::validate_pointer(new_conn), syn_id);
216 register_connector(new_hom_conn, old_hom_conn, nest::invalid_index, tgt.get_thread(), syn_id);
223 template <
typename ConnectionT >
224 nest::ConnectorModel*
233 template <
typename ConnectionT >
235 nest::ConnectorBase* old_conn,
236 nest::index sender_gid,
237 size_t target_thread,
238 nest::synindex syn_id)
241 target_thread, syn_id);
262 template <
typename ConnectionT >
264 const size_t target_thread,
265 nest::ConnectorBase*
const conn,
266 const nest::synindex syn_id)
268 using nest::HetConnector;
269 using nest::vector_like;
270 using nest::pack_pointer;
275 vector_like< ConnectionT >* vc;
277 const bool b_has_primary = has_primary(conn);
278 const bool b_has_secondary = has_secondary(conn);
280 nest::ConnectorBase* conn_vp = validate_pointer(conn);
284 if (conn_vp->homogeneous_model())
286 assert(conn_vp->get_syn_id() == syn_id);
287 vc =
static_cast<vector_like< ConnectionT >*
> (conn_vp);
289 for (
size_t i = 0; i < vc->size(); i++)
291 ConnectionT* connection = &vc->at(i);
294 if ((connection->get_target(target_thread)->get_gid() == tgt.get_gid()) && connection->is_degenerated())
296 if (vc->get_num_connections() > 1)
297 conn_vp = &vc->erase(i);
306 conn_vp = pack_pointer(conn_vp, is_primary, !is_primary);
318 HetConnector* hc =
static_cast< HetConnector*
> (conn_vp);
320 for (
size_t i = 0; i < hc->size() && !found; i++)
324 if ((*hc)[ i ]->get_syn_id() == syn_id)
328 vector_like< ConnectionT >* vc =
329 static_cast< vector_like< ConnectionT >*
> ((*hc)[ i ]);
331 for (
size_t j = 0; j < vc->size(); j++)
333 ConnectionT* connection = &vc->at(j);
335 if ((connection->get_target(target_thread)->get_gid() == tgt.get_gid()) &&
336 connection->is_degenerated())
342 (*hc).erase((*hc).begin() + i);
348 conn_vp = (*hc)[ 0 ];
349 const bool is_primary =
350 kernel().model_manager.get_synapse_prototype(conn_vp->get_syn_id()).is_primary();
351 conn_vp = pack_pointer(conn_vp, is_primary, not is_primary);
355 conn_vp = pack_pointer(hc, b_has_primary, b_has_secondary);
360 (*hc)[ i ] = &vc->erase(j);
361 conn_vp = pack_pointer(hc, b_has_primary, b_has_secondary);
377 return nest::GenericConnectorModel< ConnectionT >::delete_connection(tgt, target_thread, conn, syn_id);
393 template <
typename ConnectionT >
395 nest::synindex syn_id)
401 else if (conn->homogeneous_model())
403 if (conn->get_syn_id() == syn_id)
409 nest::HetConnector* hc =
static_cast<nest::HetConnector*
> (conn);
410 for (
size_t i = 0; i < hc->size(); i++)
413 if ((*hc)[ i ]->get_syn_id() == syn_id)
436 template <
class ConnectionT>
440 (name, requires_symmetric);
DiligentConnectorModel(const std::string name, bool is_primary=true, bool has_delay=true, bool requires_symmetric=false)
Definition: diligent_connector_model.h:87
void register_connector(nest::ConnectorBase *new_conn, nest::ConnectorBase *old_conn, nest::index sender_gid, size_t target_thread, nest::synindex syn_id)
Definition: diligent_connector_model.h:234
virtual nest::ConnectorModel * clone(std::string name) const
Definition: diligent_connector_model.h:225
DiligentConnectorModel(const DiligentConnectorModel &other, const std::string name)
Definition: diligent_connector_model.h:96
Definition: poisson_dbl_exp_neuron.cpp:43
Connector model for diligent connections.
Definition: diligent_connector_model.h:81
void register_diligent_connection_model(const std::string &name, bool requires_symmetric=false)
Definition: diligent_connector_model.h:437
void register_connector(nest::ConnectorBase *new_conn, nest::ConnectorBase *old_conn, nest::index sender_gid, nest::thread th, nest::synindex syn_id)
Definition: connection_updater.cpp:160
virtual nest::ConnectorBase * delete_connection(nest::Node &tgt, size_t target_thread, nest::ConnectorBase *conn, nest::synindex syn_id)
Definition: diligent_connector_model.h:208
virtual nest::ConnectorBase * add_connection(nest::Node &src, nest::Node &tgt, nest::ConnectorBase *conn, nest::synindex syn_id, double weight, double delay)
Definition: diligent_connector_model.h:145
static ConnectionUpdateManager * instance()
Definition: connection_updater.cpp:312
nest::ConnectorBase * get_hom_connector(nest::ConnectorBase *conn, nest::synindex syn_id)
Definition: diligent_connector_model.h:394
nest::ConnectorBase * cleanup_delete_connection(nest::Node &tgt, const size_t target_thread, nest::ConnectorBase *const conn, const nest::synindex syn_id)
Cleanup and delete the given connection.
Definition: diligent_connector_model.h:263
Global namespace holding all classes of the SPORE NEST module.
Definition: circular_buffer.h:31