state-observation 1.7.0
Loading...
Searching...
No Matches
logger.hpp
Go to the documentation of this file.
1#ifndef STATEOBSERVATIONLOGGER_H
2#define STATEOBSERVATIONLOGGER_H
3
4#include <map>
5#include <stdexcept>
6#include <string>
7#include <typeinfo>
8
9#include <state-observation/api.h>
11
12namespace stateObservation
13{
14namespace tools
15{
17{
18public:
20 virtual ~Logger();
21
25 template<typename T>
26 void record(const T * address, const std::string & filename = std::string(""));
27 template<typename T>
28 void record(const T & reference, const std::string & filename = std::string(""));
29
31 template<typename T>
32 void updateAddress(const void * oldAddress, const T * newAddress);
33
35 void setPath(const std::string & path);
36
38 template<typename T>
39 void push(const T & reference);
40
41 template<typename T>
42 void push(const T * address);
43
45 void push();
46
47 const IndexedMatrixArray & getRecord(const void * address) const;
48
50
52 void save(bool clear = false, bool append = false);
53
56
58 void clearLogs();
59
60protected:
61 struct log_s
62 {
63
65 std::string filename;
66 const std::type_info * type;
67
68 log_s(const std::string & newfilename) : type(0x0)
69 {
70 filename = newfilename;
71 }
72
73 template<typename T>
74 void setType()
75 {
76 type = &typeid(T);
77 }
78 };
79
80 typedef std::map<const void *, log_s> Tmap;
81 typedef std::pair<const void *, log_s> Tpair;
82
83 void update_(const Tmap::iterator & i);
84
85 std::string path_;
86 std::map<const void *, log_s> logs_;
88
89private:
90};
91} // namespace tools
92} // namespace stateObservation
93
94#include <state-observation/tools/logger.hxx>
95
96#endif // STATEOBSERVATIONLOGGER_H
Definition logger.hpp:17
IndexedMatrixArray & getRecord(const void *address)
std::map< const void *, log_s > logs_
Definition logger.hpp:86
void record(const T *address, const std::string &filename=std::string(""))
void push()
updates all the logs for all recorded variables
void push(const T &reference)
update the log with a new value of the reference
void setPath(const std::string &path)
set the Path for the log files, the filenames will be appended to this path
std::pair< const void *, log_s > Tpair
Definition logger.hpp:81
void update_(const Tmap::iterator &i)
void clearTracking()
clears all the tracking lists and delete all the logs
std::map< const void *, log_s > Tmap
Definition logger.hpp:80
void record(const T &reference, const std::string &filename=std::string(""))
void save(bool clear=false, bool append=false)
saves the log in a file
void clearLogs()
clears the logs but keeps the tracking including time indexation
void push(const T *address)
Matrix scalar_
Definition logger.hpp:87
std::string path_
Definition logger.hpp:85
const IndexedMatrixArray & getRecord(const void *address) const
void updateAddress(const void *oldAddress, const T *newAddress)
updates the address of a recorded variable with a new address
Definitions of types and some structures.
Definition bidim-elastic-inv-pendulum-dyn-sys.hpp:21
Eigen::MatrixXd Matrix
Dynamic sized Matrix.
Definition definitions.hpp:100
const std::type_info * type
Definition logger.hpp:66
void setType()
Definition logger.hpp:74
log_s(const std::string &newfilename)
Definition logger.hpp:68
std::string filename
Definition logger.hpp:65
IndexedMatrixArray array
Definition logger.hpp:64