GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
analogueRecorder.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Standard C++ includes
4 #include <fstream>
5 #include <initializer_list>
6 #include <string>
7 #include <vector>
8 
9 //----------------------------------------------------------------------------
10 // AnalogueRecorder
11 //----------------------------------------------------------------------------
12 template<typename T>
14 {
15 public:
16  AnalogueRecorder(const std::string &filename, std::initializer_list<T*> variables, unsigned int popSize, const std::string &delimiter=" ")
17  : m_Stream(filename), m_Variables(variables), m_PopSize(popSize), m_Delimiter(delimiter)
18  {
19  // Set precision
20  m_Stream.precision(16);
21  }
22  AnalogueRecorder(const std::string &filename, T *variable, unsigned int popSize, const std::string &delimiter=" ")
23  : AnalogueRecorder(filename, {variable}, popSize, delimiter)
24  {
25  }
26 
27  void record(double t)
28  {
29  m_Stream << t << m_Delimiter;
30 
31  for(auto *v : m_Variables) {
32  for(unsigned int i = 0; i < m_PopSize; i++) {
33  m_Stream << v[i] << m_Delimiter;
34  }
35  }
36  m_Stream << std::endl;
37  }
38 
39 private:
40 
41  //----------------------------------------------------------------------------
42  // Members
43  //----------------------------------------------------------------------------
44  std::ofstream m_Stream;
45  std::vector<T*> m_Variables;
46  const unsigned int m_PopSize;
47  const std::string m_Delimiter;
48 };
AnalogueRecorder(const std::string &filename, T *variable, unsigned int popSize, const std::string &delimiter=" ")
Definition: analogueRecorder.h:22
AnalogueRecorder(const std::string &filename, std::initializer_list< T *> variables, unsigned int popSize, const std::string &delimiter=" ")
Definition: analogueRecorder.h:16
Definition: analogueRecorder.h:13
void record(double t)
Definition: analogueRecorder.h:27