NEST main@caf0ae8
 
Loading...
Searching...
No Matches
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 "compose.hpp"
32#include "kernel_manager.h"
33
34namespace nest
35{
36
48{
49
50public:
52 : target_( nullptr )
53 , rport_( 0 )
54 {
55 }
56
57
60
61
62 void
64 {
65 // Do nothing if called on synapse prototype
66 if ( target_ )
67 {
68 d[ names::rport ] = static_cast< long >( rport_ );
69 d[ names::target ] = static_cast< long >( target_->get_node_id() );
70 }
71 }
72
73 Node*
74 get_target_ptr( const size_t ) const
75 {
76 return target_;
77 }
78
79 size_t
80 get_rport() const
81 {
82 return rport_;
83 }
84
85 void
86 set_target( Node* target )
87 {
88 target_ = target;
89 }
90
91 void
92 set_rport( size_t rprt )
93 {
94 rport_ = rprt;
95 }
96
97private:
99 size_t rport_;
100};
101
102
113{
114
115public:
120
123
124 void
126 {
127 // Do nothing if called on synapse prototype
129 {
130 d[ names::rport ] = 0;
131 d[ names::target ] = target_;
132 }
133 }
134
135 Node*
136 get_target_ptr( const size_t tid ) const
137 {
138 assert( target_ != invalid_targetindex );
140 }
141
142 size_t
143 get_rport() const
144 {
145 return 0;
146 }
147
148 void set_target( Node* target );
149
150 void
151 set_rport( size_t rprt )
152 {
153 if ( rprt != 0 )
154 {
155 throw IllegalConnection(
156 "Only rport==0 allowed for HPC synapses. Use normal synapse models "
157 "instead. See Kunkel et al, Front Neuroinform 8:78 (2014), Sec "
158 "3.3.2." );
159 }
160 }
161
162private:
164};
165
166inline void
168{
169 assert( kernel().node_manager.thread_local_data_is_up_to_date() );
170
171 size_t target_lid = target->get_thread_lid();
172 if ( target_lid > max_targetindex )
173 {
174 throw IllegalConnection(
175 String::compose( "HPC synapses support at most %1 nodes per thread. "
176 "See Kunkel et al, Front Neuroinform 8:78 (2014), Sec 3.3.2.",
177 max_targetindex ) );
178 }
179 target_ = target_lid;
180}
181
182
183} // namespace nest
184
185
186#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
To be thrown if a connection is not possible.
Definition exceptions.h:490
Node * thread_lid_to_node(size_t t, targetindex thread_local_id) const
Return node on thread t with given local node id.
Definition node_manager.h:376
Base class for all NEST network objects.
Definition node.h:99
size_t get_node_id() const
Return global Network ID.
Definition node.h:1200
Class providing compact (hpc) target identified by index.
Definition target_identifier.h:113
TargetIdentifierIndex & operator=(const TargetIdentifierIndex &t)=default
void get_status(Dictionary &d) const
Definition target_identifier.h:125
Node * get_target_ptr(const size_t tid) const
Definition target_identifier.h:136
void set_target(Node *target)
Definition target_identifier.h:167
size_t get_rport() const
Definition target_identifier.h:143
targetindex target_
Target node.
Definition target_identifier.h:163
void set_rport(size_t rprt)
Definition target_identifier.h:151
TargetIdentifierIndex(const TargetIdentifierIndex &t)=default
TargetIdentifierIndex()
Definition target_identifier.h:116
Class providing classic target identified information with target pointer and rport.
Definition target_identifier.h:48
void set_rport(size_t rprt)
Definition target_identifier.h:92
TargetIdentifierPtrRport()
Definition target_identifier.h:51
TargetIdentifierPtrRport & operator=(const TargetIdentifierPtrRport &t)=default
size_t rport_
Receiver port at the target node.
Definition target_identifier.h:99
Node * get_target_ptr(const size_t) const
Definition target_identifier.h:74
void set_target(Node *target)
Definition target_identifier.h:86
Node * target_
Target node.
Definition target_identifier.h:98
void get_status(Dictionary &d) const
Definition target_identifier.h:63
TargetIdentifierPtrRport(const TargetIdentifierPtrRport &t)=default
size_t get_rport() const
Definition target_identifier.h:80
NodeManager node_manager
Definition kernel_manager.h:245
const std::string target("target")
const std::string rport("receptor")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311
unsigned short targetindex
Unsigned short type for compact target representation.
Definition nest_types.h:124
constexpr targetindex invalid_targetindex
Definition nest_types.h:125