NEST  2.6.0,not_revisioned_source_dir@0
target_identifier.h
Go to the documentation of this file.
1 /*
2  * target_identifier.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #ifndef TARGET_IDENTIFIER_H
25 #define TARGET_IDENTIFIER_H
26 
31 #include "network.h"
32 
33 namespace nest
34 {
35 
46 {
47 
48 public:
49 
51  : target_(0),
52  rport_(0)
53  { }
54 
55 
57  : target_(t.target_),
58  rport_(t.rport_)
59  { }
60 
61 
63  {
64  // Do nothing if called on synapse prototype
65  if ( target_ != 0 )
66  {
67  def<long>(d, names::rport, rport_);
68  def<long>(d, names::target, target_->get_gid());
69  }
70  }
71 
72  Node *get_target_ptr(thread) const { return target_; }
73 
74  rport get_rport() const { return rport_; }
75 
77 
78  void set_rport(rport rprt) { rport_ = rprt; }
79 
80  private:
81 
84 
85 };
86 
87 
98 {
99 
100 public:
101 
104  { }
105 
106 
108  : target_(t.target_)
109  { }
110 
111 
113  {
114  // Do nothing if called on synapse prototype
115  if ( target_ != invalid_targetindex )
116  {
117  def<long>(d, names::rport, 0);
118  def<long>(d, names::target, target_);
119  }
120  }
121 
123  {
126  }
127 
128  rport get_rport() const { return 0; }
129 
130  void set_target(Node *target);
131 
132  void set_rport(rport rprt)
133  {
134  if (rprt != 0)
135  throw IllegalConnection("Only rport==0 allowed for HPC synpases. Use normal synapse models instead."
136  "See Kunkel et al, Front Neuroinform 8:78 (2014), Sec 3.3.2.");
137  }
138 
139  private:
141 };
142 
143 inline
145 {
147 
148  index target_lid = target->get_thread_lid();
149  if (target_lid > max_targetindex)
150  throw IllegalConnection(String::compose("HPC synapses support at most %1 nodes per thread. "
151  "See Kunkel et al, Front Neuroinform 8:78 (2014), Sec 3.3.2.",
153  );
154  target_ = target_lid;
155 }
156 
157 
158 } // namespace nest
159 
160 
161 #endif
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
void set_target(Node *target)
Definition: target_identifier.h:144
const index max_targetindex
Definition: nest.h:125
index get_gid() const
Return global Network ID.
Definition: node.h:753
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
targetindex target_
Target node.
Definition: target_identifier.h:140
Node * get_target_ptr(thread t) const
Definition: target_identifier.h:122
To be thrown if a connection is not possible.
Definition: exceptions.h:317
rport get_rport() const
Definition: target_identifier.h:128
Class providing compact (hpc) target identified by index.
Definition: target_identifier.h:97
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Node * get_target_ptr(thread) const
Definition: target_identifier.h:72
assert(pNet!=0)
TargetIdentifierPtrRport()
Definition: target_identifier.h:50
index get_thread_lid() const
get thread local index
Definition: node.h:857
TargetIdentifierPtrRport(const TargetIdentifierPtrRport &t)
Definition: target_identifier.h:56
unsigned short targetindex
Unsigned short type for compact target representation.
Definition: nest.h:123
void ensure_valid_thread_local_ids()
Ensure that all nodes in the network have valid thread-local IDs.
Definition: network.h:679
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
Declarations for class Network.
void set_rport(rport rprt)
Definition: target_identifier.h:132
const Name rport("receptor")
Connection parameters.
Definition: nest_names.h:251
void set_rport(rport rprt)
Definition: target_identifier.h:78
void get_status(DictionaryDatum &d) const
Definition: target_identifier.h:62
static Network & get_network()
Return a reference to the network managed by nestmodule.
Definition: nestmodule.h:497
Node * target_
Target node.
Definition: target_identifier.h:82
rport rport_
Receiver port at the target node.
Definition: target_identifier.h:83
TargetIdentifierIndex(const TargetIdentifierIndex &t)
Definition: target_identifier.h:107
Class providing classic target identified information with target pointer and rport.
Definition: target_identifier.h:45
rport get_rport() const
Definition: target_identifier.h:74
Base class for all NEST network objects.
Definition: node.h:96
Node * thread_lid_to_node(thread t, targetindex thread_local_id) const
Definition: network.h:900
void get_status(DictionaryDatum &d) const
Definition: target_identifier.h:112
TargetIdentifierIndex()
Definition: target_identifier.h:102
int_t thread
Thread index type.
Definition: nest.h:133
void set_target(Node *target)
Definition: target_identifier.h:76
const targetindex invalid_targetindex
Definition: nest.h:124