Cypress  1.0
C++ Spiking Neural Network Simulation Framework
network_base_objects.hpp
Go to the documentation of this file.
1 /*
2  * Cypress -- C++ Spiking Neural Network Simulation Framework
3  * Copyright (C) 2016 Andreas Stöckel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
31 #pragma once
32 
33 #ifndef CYPRESS_CORE_NETWORK_BASE_OBJECTS_HPP
34 #define CYPRESS_CORE_NETWORK_BASE_OBJECTS_HPP
35 
38 
39 namespace cypress {
40 
41 /*
42  * Forward declarations
43  */
44 class PopulationBase;
45 class PopulationViewBase;
46 class NeuronBase;
47 struct Accessor;
48 
54  : public PopulationMixin<PopulationBase, Accessor>,
55  public IterableMixin<PopulationBase, NeuronBase, Accessor>,
56  public ViewableMixin<PopulationBase, PopulationViewBase, Accessor>,
57  public DataMixin<PopulationBase, Accessor, NeuronParameters,
58  NeuronSignals>,
59 
60  public ConnectableMixin<PopulationBase, Accessor> {
61 private:
62  NetworkBase m_network;
63  PopulationIndex m_pid;
64 
65 public:
67  using IterableMixin::operator();
68  using ViewableMixin::operator();
69 
79  : m_network(network), m_pid(pid)
80  {
81  }
82 
89  NetworkBase network() const { return m_network; }
90 
96  PopulationIndex pid() const { return m_pid; }
97 };
98 
104  : public IterableMixin<PopulationViewBase, NeuronBase, Accessor>,
105  public ViewableMixin<PopulationViewBase, PopulationViewBase, Accessor>,
106  public DataMixin<PopulationViewBase, Accessor, NeuronParameters,
107  NeuronSignals>,
108  public ConnectableMixin<PopulationViewBase, Accessor> {
109 private:
110  NetworkBase m_network;
111  PopulationIndex m_pid;
112  NeuronIndex m_nid0;
113  NeuronIndex m_nid1;
114 
115 public:
116  using IterableMixin::operator();
117  using ViewableMixin::operator();
118 
133  NeuronIndex nid0, NeuronIndex nid1)
134  : m_network(network), m_pid(pid), m_nid0(nid0), m_nid1(nid1)
135  {
136  }
137 
144  NetworkBase network() const { return m_network; }
145 
151  PopulationIndex pid() const { return m_pid; }
152 
156  NeuronIndex nid_begin() const { return m_nid0; }
157 
162  NeuronIndex nid_end() const { return m_nid1; }
163 };
164 
170  : public NeuronMixin<NeuronBase>,
171  public IterableMixin<NeuronBase, NeuronBase, Accessor>,
172  public ViewableMixin<NeuronBase, PopulationViewBase, Accessor>,
173  public DataMixin<NeuronBase, Accessor, NeuronParameters,
174  NeuronSignals>,
175  public ConnectableMixin<NeuronBase, Accessor> {
176 private:
177  NetworkBase m_network;
178  PopulationIndex m_pid;
179  NeuronIndex m_nid;
180 
181 public:
182  using IterableMixin::operator();
183  using ViewableMixin::operator();
184 
193  template <typename Parent>
194  NeuronBase(const Parent &parent, NeuronIndex nid)
195  : m_network(parent.network()), m_pid(parent.pid()), m_nid(nid)
196  {
197  }
198 
202  const NeuronType &type() const { return m_network[m_pid].type(); }
203 
207  NetworkBase network() const { return NetworkBase(m_network); }
208 
216  {
217  return PopulationBase(m_network, m_pid);
218  }
219 
223  PopulationIndex pid() const { return m_pid; }
224 
230  NeuronIndex nid() const { return m_nid; }
231 };
232 
241 struct Accessor {
242  static NeuronIndex begin(const PopulationBase &) { return 0; }
243  static NeuronIndex end(const PopulationBase &pop) { return pop.size(); }
244  static PopulationIndex pid(const PopulationBase &pop) { return pop.pid(); }
245  static NetworkBase network(const PopulationBase &pop)
246  {
247  return pop.network();
248  }
249 
251  {
252  return view.nid_begin();
253  }
254  static NeuronIndex end(const PopulationViewBase &view)
255  {
256  return view.nid_end();
257  }
259  {
260  return view.pid();
261  }
263  {
264  return view.network();
265  }
266 
267  static NeuronIndex begin(const NeuronBase &neuron) { return neuron.nid(); }
268  static NeuronIndex end(const NeuronBase &neuron)
269  {
270  return neuron.nid() + 1;
271  }
272  static PopulationIndex pid(const NeuronBase &neuron)
273  {
274  return neuron.pid();
275  }
276  static NetworkBase network(const NeuronBase &neuron)
277  {
278  return neuron.network();
279  }
280 };
281 }
282 
283 #endif /* CYPRESS_CORE_NETWORK_BASE_OBJECTS_HPP */
Definition: neurons_base.hpp:54
static NeuronIndex end(const PopulationViewBase &view)
Definition: network_base_objects.hpp:254
static NetworkBase network(const PopulationViewBase &view)
Definition: network_base_objects.hpp:262
PopulationBase(const NetworkBase &network, PopulationIndex pid)
Definition: network_base_objects.hpp:78
Definition: network_base.hpp:67
static PopulationIndex pid(const PopulationBase &pop)
Definition: network_base_objects.hpp:244
Definition: network_base_objects.hpp:103
Definition: network_base_objects.hpp:241
int32_t NeuronIndex
Definition: types.hpp:74
Definition: network_base.hpp:64
NeuronIndex nid_end() const
Definition: network_base_objects.hpp:162
Definition: network_base.hpp:70
static NeuronIndex end(const NeuronBase &neuron)
Definition: network_base_objects.hpp:268
Definition: network_mixins.hpp:103
PopulationBase population() const
Definition: network_base_objects.hpp:215
static NeuronIndex begin(const NeuronBase &neuron)
Definition: network_base_objects.hpp:267
static NeuronIndex end(const PopulationBase &pop)
Definition: network_base_objects.hpp:243
PopulationIndex pid() const
Definition: network_base_objects.hpp:151
PopulationIndex pid() const
Definition: network_base_objects.hpp:96
NeuronIndex nid() const
Definition: network_base_objects.hpp:230
Definition: network_base_objects.hpp:169
NetworkBase network() const
Definition: network_base_objects.hpp:89
static PopulationIndex pid(const PopulationViewBase &view)
Definition: network_base_objects.hpp:258
PopulationViewBase(const NetworkBase &network, PopulationIndex pid, NeuronIndex nid0, NeuronIndex nid1)
Definition: network_base_objects.hpp:132
size_t size() const
Definition: network_mixins.hpp:81
Definition: network_base.hpp:116
NeuronIndex nid_begin() const
Definition: network_base_objects.hpp:156
Definition: network_base_objects.hpp:53
static NetworkBase network(const NeuronBase &neuron)
Definition: network_base_objects.hpp:276
NetworkBase network() const
Definition: network_base_objects.hpp:207
static NeuronIndex begin(const PopulationBase &)
Definition: network_base_objects.hpp:242
NeuronBase(const Parent &parent, NeuronIndex nid)
Definition: network_base_objects.hpp:194
Definition: brainscales_lib.hpp:39
static NeuronIndex begin(const PopulationViewBase &view)
Definition: network_base_objects.hpp:250
PopulationIndex pid() const
Definition: network_base_objects.hpp:223
NetworkBase network() const
Definition: network_base_objects.hpp:144
Definition: network_mixins.hpp:363
Definition: network_mixins.hpp:268
const NeuronType & type() const
Definition: network_base_objects.hpp:202
int32_t PopulationIndex
Definition: types.hpp:75
static PopulationIndex pid(const NeuronBase &neuron)
Definition: network_base_objects.hpp:272
static NetworkBase network(const PopulationBase &pop)
Definition: network_base_objects.hpp:245