Spike
Loading...
Searching...
No Matches
TimeFrame.h
1#ifndef SPIKE_TIMEFRAME_H
2#define SPIKE_TIMEFRAME_H
3
4#include <cassert>
5#include <string>
6#include <vector>
7
8namespace Spike {
9
13class TimeFrame {
14private:
15 double t_0;
16 double t_end;
17 double dt;
18 std::vector<double> t;
19
20public:
25 explicit TimeFrame(const std::string &input_file);
26
33 TimeFrame(double t_0, double t_end, double dt);
34
38 void calculate_times();
39
44 [[nodiscard]] double get_t_0() const { return t_0; };
45
50 [[nodiscard]] double get_t_end() const { return t_end; };
51
56 [[nodiscard]] double get_dt() const { return dt; };
57
62 [[nodiscard]] size_t get_size() const { return t.size(); };
63
68 [[nodiscard]] double get_time(size_t i) const { return t[i]; };
69
74 [[nodiscard]] const std::vector<double> &get_times() const { return t; };
75
82 friend std::ostream &operator<<(std::ostream &out, const TimeFrame &tf);
83};
84
85} // namespace Spike
86
87#endif // SPIKE_TIMEFRAME_H
A time frame with discrete time steps.
Definition TimeFrame.h:13
const std::vector< double > & get_times() const
Returns the times vector.
Definition TimeFrame.h:74
void calculate_times()
Calculates the discretized times.
Definition TimeFrame.cpp:44
double get_t_0() const
Returns the start time.
Definition TimeFrame.h:44
double get_t_end() const
Returns the end time.
Definition TimeFrame.h:50
double get_dt() const
Returns the time step.
Definition TimeFrame.h:56
TimeFrame(const std::string &input_file)
Constructs a time frame from a .ini file.
Definition TimeFrame.cpp:23
size_t get_size() const
Returns the size of the time frame.
Definition TimeFrame.h:62
friend std::ostream & operator<<(std::ostream &out, const TimeFrame &tf)
Overloads the operator << so we can print time frame.
Definition TimeFrame.cpp:51
double get_time(size_t i) const
Returns the time at index i.
Definition TimeFrame.h:68