tracing_node.h
1 /*
2  * This file is part of SPORE.
3  *
4  * Copyright (C) 2016, the SPORE team (see AUTHORS).
5  *
6  * SPORE is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * SPORE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPORE. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * For more information see: https://github.com/IGITUGraz/spore-nest-module
20  *
21  * File: tracing_node.h
22  * Author: Kappel
23  *
24  * Created on November 3, 2016, 2:07 PM
25  */
26 
27 #ifndef TRACING_NODE_H
28 #define TRACING_NODE_H
29 
30 #include <vector>
31 #include <deque>
32 
33 #include "nest.h"
34 #include "event.h"
35 #include "node.h"
36 
37 #include "circular_buffer.h"
38 #include "connection_updater.h"
39 
40 
41 namespace spore
42 {
43 
52 class TracingNode : public nest::Node
53 {
54 public:
56  typedef size_t trace_id;
57 
58  TracingNode();
59  virtual ~TracingNode();
60 
61  virtual void get_status(DictionaryDatum& d) const;
62  virtual void set_status(const DictionaryDatum& d);
63 
64  void get_trace_status(DictionaryDatum& d) const;
65 
81  inline
82  const_iterator get_trace(nest::delay steps, trace_id id) const
83  {
84  assert(id < traces_.size());
85  return traces_[id].get(steps);
86  };
87 
96  inline
97  const_iterator get_trace(nest::Time const& time, trace_id id) const
98  {
99  return get_trace(time.get_steps(), id);
100  };
101 
105  inline
106  size_t get_num_traces() const
107  {
108  return traces_.size();
109  };
110 
111 protected:
112  void init_traces(size_t num_traces);
113 
122  void set_trace(nest::delay steps, double v, trace_id id = 0)
123  {
124  assert(id < traces_.size());
125  traces_[id][steps] = v;
126  }
127 
128 private:
129  std::vector< CircularBuffer<double> > traces_;
130 };
131 
132 }
133 
134 #endif
virtual ~TracingNode()
Definition: tracing_node.cpp:49
TracingNode()
Definition: tracing_node.cpp:41
Base class to all nodes that record traces.
Definition: tracing_node.h:52
const_iterator get_trace(nest::Time const &time, trace_id id) const
Definition: tracing_node.h:97
void init_traces(size_t num_traces)
Definition: tracing_node.cpp:56
Constant iterator class.
Definition: circular_buffer.h:49
size_t get_num_traces() const
Definition: tracing_node.h:106
virtual void set_status(const DictionaryDatum &d)
Definition: tracing_node.cpp:70
Global namespace holding all classes of the SPORE NEST module.
Definition: circular_buffer.h:31
void set_trace(nest::delay steps, double v, trace_id id=0)
Definition: tracing_node.h:122
void get_trace_status(DictionaryDatum &d) const
Definition: tracing_node.cpp:84
virtual void get_status(DictionaryDatum &d) const
Definition: tracing_node.cpp:77
const_iterator get_trace(nest::delay steps, trace_id id) const
Access the trace of id at time step step.
Definition: tracing_node.h:82