NEST main@caf0ae8
 
Loading...
Searching...
No Matches
target_data.h
Go to the documentation of this file.
1/*
2 * target_data.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#ifndef TARGET_DATA_H
24#define TARGET_DATA_H
25
26// C++ includes:
27#include <limits>
28
29// Includes from nestkernel:
30#include "nest_types.h"
31#include "static_assert.h"
32#include "target.h"
33
34namespace nest
35{
37{
38private:
39 unsigned int lcid_ : NUM_BITS_LCID;
40 unsigned int tid_ : NUM_BITS_TID;
41 unsigned int syn_id_ : NUM_BITS_SYN_ID;
42
43public:
44 // Members must be set explicitly -- no defaults
45
49 void set_lcid( const size_t lcid );
50
54 size_t get_lcid() const;
55
59 void set_tid( const size_t tid );
60
64 size_t get_tid() const;
65
69 void set_syn_id( const synindex syn_id );
70
74 synindex get_syn_id() const;
75};
76
79
80inline void
81TargetDataFields::set_lcid( const size_t lcid )
82{
83 lcid_ = lcid;
84}
85
86inline size_t
88{
89 return lcid_;
90}
91
92inline void
93TargetDataFields::set_tid( const size_t tid )
94{
95 tid_ = tid;
96}
97
98inline size_t
100{
101 return tid_;
102}
103
104inline void
106{
107 syn_id_ = syn_id;
108}
109
110inline synindex
112{
113 return syn_id_;
114}
115
117{
118private:
119 unsigned int recv_buffer_pos_;
120 unsigned char syn_id_;
121
122public:
123 // Members must be set explicitly -- no defaults
124 void set_recv_buffer_pos( const size_t pos );
125 size_t get_recv_buffer_pos() const;
126 void set_syn_id( const synindex syn_id );
127 synindex get_syn_id() const;
128};
129
132
133inline void
135{
136 assert( pos < std::numeric_limits< unsigned int >::max() );
137 recv_buffer_pos_ = pos;
138}
139
140inline size_t
145
146inline void
148{
149 assert( syn_id < std::numeric_limits< unsigned char >::max() );
150 syn_id_ = syn_id;
151}
152
153inline synindex
155{
156 return syn_id_;
157}
158
166
175{
176 // Members must be set explicitly -- no defaults
177 // Done this way to create large vector without preconstruction and to handle variant fields
178
179private:
180 static constexpr uint8_t NUM_BITS_LID = 19U;
181 static constexpr uint8_t NUM_BITS_MARKER = 2U;
182 static constexpr uint8_t NUM_BITS_IS_PRIMARY = 1U;
183
184 static constexpr int MAX_LID = generate_max_value( NUM_BITS_LID );
185
186 unsigned int source_lid_ : NUM_BITS_LID;
188 unsigned int source_tid_ : NUM_BITS_TID;
189 unsigned int marker_ : NUM_BITS_MARKER;
192
193public:
195 union
196 {
199 };
200
201 void reset_marker();
202 void set_complete_marker();
203 void set_end_marker();
204 void set_invalid_marker();
205 bool is_complete_marker() const;
206 bool is_end_marker() const;
207 bool is_invalid_marker() const;
208 void set_source_lid( const size_t source_lid );
209 void set_source_tid( const size_t source_tid );
210 size_t get_source_lid() const;
211 size_t get_source_tid() const;
212 void set_is_primary( const bool is_primary );
213 bool is_primary() const;
214};
215
217using success_target_data_size = StaticAssert< sizeof( TargetData ) == 12 >::success;
218
219inline void
224
225inline void
230
231inline void
236
237inline void
242
243inline bool
248
249inline bool
251{
252 return marker_ == TARGET_DATA_ID_END;
253}
254
255inline bool
260
261inline void
262TargetData::set_source_lid( const size_t source_lid )
263{
264 assert( source_lid < MAX_LID );
265 source_lid_ = source_lid;
266}
267
268inline void
269TargetData::set_source_tid( const size_t source_tid )
270{
271 assert( source_tid < MAX_TID );
272 source_tid_ = source_tid;
273}
274
275inline size_t
277{
278 return source_lid_;
279}
280
281inline size_t
283{
284 return source_tid_;
285}
286
287inline void
288TargetData::set_is_primary( const bool is_primary )
289{
291}
292
293inline bool
295{
296 return is_primary_;
297}
298} // namespace nest
299
300#endif /* #ifndef TARGET_DATA_H */
Definition target_data.h:117
unsigned int recv_buffer_pos_
Definition target_data.h:119
void set_recv_buffer_pos(const size_t pos)
Definition target_data.h:134
synindex get_syn_id() const
Definition target_data.h:154
unsigned char syn_id_
Definition target_data.h:120
size_t get_recv_buffer_pos() const
Definition target_data.h:141
void set_syn_id(const synindex syn_id)
Definition target_data.h:147
Definition target_data.h:37
void set_tid(const size_t tid)
Sets the target ID.
Definition target_data.h:93
size_t get_lcid() const
Returns the local connection ID.
Definition target_data.h:87
void set_syn_id(const synindex syn_id)
Sets the synapse-type ID.
Definition target_data.h:105
unsigned int syn_id_
Definition target_data.h:41
unsigned int tid_
Definition target_data.h:40
synindex get_syn_id() const
Returns the synapse-type ID.
Definition target_data.h:111
size_t get_tid() const
Returns the target ID.
Definition target_data.h:99
void set_lcid(const size_t lcid)
Sets the local connection ID.
Definition target_data.h:81
unsigned int lcid_
Definition target_data.h:39
Used to communicate part of the connection infrastructure from post- to presynaptic side.
Definition target_data.h:175
void reset_marker()
Definition target_data.h:220
static constexpr uint8_t NUM_BITS_MARKER
Definition target_data.h:181
unsigned int source_tid_
thread index of presynaptic neuron
Definition target_data.h:188
unsigned int marker_
Definition target_data.h:189
void set_complete_marker()
Definition target_data.h:226
void set_end_marker()
Definition target_data.h:232
bool is_invalid_marker() const
Definition target_data.h:256
SecondaryTargetDataFields secondary_data
Definition target_data.h:198
static constexpr int MAX_LID
Definition target_data.h:184
bool is_primary_
TargetData has TargetDataFields else SecondaryTargetDataFields.
Definition target_data.h:191
static constexpr uint8_t NUM_BITS_LID
Definition target_data.h:180
bool is_primary() const
Definition target_data.h:294
size_t get_source_tid() const
Definition target_data.h:282
TargetDataFields target_data
Definition target_data.h:197
void set_invalid_marker()
Definition target_data.h:238
bool is_end_marker() const
Definition target_data.h:250
void set_source_lid(const size_t source_lid)
Definition target_data.h:262
static constexpr uint8_t NUM_BITS_IS_PRIMARY
Definition target_data.h:182
bool is_complete_marker() const
Definition target_data.h:244
void set_is_primary(const bool is_primary)
Definition target_data.h:288
void set_source_tid(const size_t source_tid)
Definition target_data.h:269
unsigned int source_lid_
local id of presynaptic neuron
Definition target_data.h:186
size_t get_source_lid() const
Definition target_data.h:276
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
StaticAssert< sizeof(TargetData)==12 >::success success_target_data_size
check legal size
Definition target_data.h:217
constexpr uint8_t NUM_BITS_SYN_ID
Definition nest_types.h:77
constexpr uint8_t NUM_BITS_LCID
Definition nest_types.h:83
constexpr int64_t MAX_TID
Definition nest_types.h:95
constexpr uint8_t NUM_BITS_TID
Definition nest_types.h:76
StaticAssert< sizeof(SecondaryTargetDataFields)==8 >::success success_secondary_target_data_fields_size
check legal size
Definition target_data.h:131
StaticAssert< sizeof(TargetDataFields)==8 >::success success_target_data_fields_size
check legal size
Definition target_data.h:78
enum_status_target_data_id
Definition target_data.h:160
@ TARGET_DATA_ID_INVALID
Definition target_data.h:164
@ TARGET_DATA_ID_DEFAULT
Definition target_data.h:161
@ TARGET_DATA_ID_END
Definition target_data.h:163
@ TARGET_DATA_ID_COMPLETE
Definition target_data.h:162
constexpr uint64_t generate_max_value(const uint8_t num_bits)
Definition nest_types.h:66
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Compile time assertions.
Definition static_assert.h:47