NEST main@caf0ae8
 
Loading...
Searching...
No Matches
connection_label.h
Go to the documentation of this file.
1/*
2 * connection_label.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 CONNECTION_LABEL_H
24#define CONNECTION_LABEL_H
25
26#include "nest_names.h"
27
28namespace nest
29{
30class ConnectorModel;
31
38const static long UNLABELED_CONNECTION = -1;
39
52template < typename ConnectionT >
53class ConnectionLabel : public ConnectionT
54{
55public:
57
61 void get_status( Dictionary& d ) const;
62
69 void set_status( const Dictionary& d, ConnectorModel& cm );
70
71 long get_label() const;
72
73private:
74 long label_;
75};
76
77template < typename ConnectionT >
83
84template < typename ConnectionT >
85void
87{
88 ConnectionT::get_status( d );
89 d[ names::synapse_label ] = label_;
90 // override names::size_of from ConnectionT,
91 // as the size from ConnectionLabel< ConnectionT > is
92 // one long larger
93 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
94}
95
96template < typename ConnectionT >
97void
99{
100 long lbl;
101 if ( d.update_integer_value( names::synapse_label, lbl ) )
102 {
103 if ( lbl >= 0 )
104 {
105 label_ = lbl;
106 }
107 else
108 {
109 throw BadProperty( "Connection label must not be negative." );
110 }
111 }
112 ConnectionT::set_status( d, cm );
113}
114
115template < typename ConnectionT >
116inline long
118{
119 return label_;
120}
121
122
123} // namespace nest
124
125
126#endif /* CONNECTION_LABEL_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
The class ConnectionLabel enables synapse model to be labeled by a positive integer.
Definition connection_label.h:54
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition connection_label.h:98
long label_
Definition connection_label.h:74
long get_label() const
Definition connection_label.h:117
ConnectionLabel()
Definition connection_label.h:78
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition connection_label.h:86
Definition connector_model.h:69
const std::string synapse_label("synapse_label")
const std::string size_of("sizeof")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38