NEST main@caf0ae8
 
Loading...
Searching...
No Matches
source.h
Go to the documentation of this file.
1/*
2 * source.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 SOURCE_H
24#define SOURCE_H
25
26// C++ include
27#include <cassert>
28
29// Includes from nestkernel:
30#include "nest_types.h"
31
32namespace nest
33{
34
40class Source
41{
42private:
44 bool processed_ : 1;
46 bool primary_ : 1;
47 bool disabled_ : 1;
48
49public:
50 Source();
51 explicit Source( const size_t node_id, const bool primary );
52
56 size_t get_node_id() const;
57
58 void set_processed( const bool processed );
59 bool is_processed() const;
60
64 void set_primary( const bool primary );
65
69 bool is_primary() const;
70
74 void disable();
75
79 bool is_disabled() const;
80
81 friend bool operator<( const Source& lhs, const Source& rhs );
82 friend bool operator>( const Source& lhs, const Source& rhs );
83 friend bool operator==( const Source& lhs, const Source& rhs );
84};
85
87 : node_id_( 0 )
88 , processed_( false )
89 , primary_( true )
90 , disabled_( false )
91{
92}
93
94inline Source::Source( const size_t node_id, const bool is_primary )
95 : node_id_( node_id )
96 , processed_( false )
97 , primary_( is_primary )
98 , disabled_( false )
99{
100 assert( node_id <= MAX_NODE_ID );
101}
102
103inline size_t
105{
106 return node_id_;
107}
108
109inline void
110Source::set_processed( const bool processed )
111{
112 processed_ = processed;
113}
114
115inline bool
117{
118 return processed_;
119}
120
121inline void
122Source::set_primary( const bool primary )
123{
124 primary_ = primary;
125}
126
127inline bool
129{
130 return primary_;
131}
132
133inline void
135{
136 disabled_ = true;
137}
138
139inline bool
141{
142 return disabled_;
143}
144
145inline bool
146operator<( const Source& lhs, const Source& rhs )
147{
148 return ( lhs.node_id_ < rhs.node_id_ );
149}
150
151inline bool
152operator>( const Source& lhs, const Source& rhs )
153{
154 return operator<( rhs, lhs );
155}
156
157inline bool
158operator==( const Source& lhs, const Source& rhs )
159{
160 return ( lhs.node_id_ == rhs.node_id_ );
161}
162
163} // namespace nest
164
165#endif /* #ifndef SOURCE_H */
Stores the node ID of a presynaptic neuron and the number of local targets, along with a flag,...
Definition source.h:41
bool is_disabled() const
Returns whether Source is disabled.
Definition source.h:140
bool disabled_
connection has been disabled
Definition source.h:47
Source()
Definition source.h:86
friend bool operator>(const Source &lhs, const Source &rhs)
Definition source.h:152
bool primary_
source of primary connection
Definition source.h:46
size_t get_node_id() const
Returns this Source's node ID.
Definition source.h:104
void disable()
Disables Source.
Definition source.h:134
bool is_processed() const
Definition source.h:116
void set_processed(const bool processed)
Definition source.h:110
bool processed_
whether this target has already been moved to the MPI buffer
Definition source.h:44
friend bool operator<(const Source &lhs, const Source &rhs)
Definition source.h:146
void set_primary(const bool primary)
Sets whether Source is primary.
Definition source.h:122
bool is_primary() const
Returns whether Source is primary.
Definition source.h:128
friend bool operator==(const Source &lhs, const Source &rhs)
Definition source.h:158
size_t node_id_
node ID of source
Definition source.h:43
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
constexpr uint64_t MAX_NODE_ID
Definition nest_types.h:98
bool operator<(const histentry_extended &he, double t)
Definition histentry.h:67
bool operator>(const Time &t1, const Time &t2)
Definition nest_time.h:572
bool operator==(const Time &t1, const Time &t2)
Definition nest_time.h:554
constexpr uint8_t NUM_BITS_NODE_ID
Definition nest_types.h:89