This repository was archived by the owner on Jul 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAPI.h
More file actions
96 lines (86 loc) · 4.09 KB
/
Copy pathAPI.h
File metadata and controls
96 lines (86 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*! **************************************************************************
* @file API.h
* @author K. Zarebski
* @date 2021-10-03
* @brief File containing classes and methods for broadcasting ROS status data
*
* The classes and methods within this file are used to access variable values
* from within the ROS Interface, this information is then dumped so it can be
* accessed externally.
****************************************************************************/
#ifndef APIH
#define APIH
//---------------------------------------------------------------------------
#include "System.hpp"
#include "System.IniFiles.hpp"
#include <map>
/*! **************************************************************************
* @class API
* @brief a class which handles the fetching of information from the ROS
* interface via pointers to variables of interest
*
* The API class dumps variables of interest from ROS interface instance to an
* INI file so the metadata can be read by an external program
****************************************************************************/
class API
{
private:
AnsiString file_path_;
std::map<AnsiString, AnsiString*> metadata_str_;
std::map<AnsiString, bool*> metadata_bool_;
std::map<AnsiString, int*> metadata_int_;
public:
/*! ******************************************************************
* @brief construct an API object using creating the given INI file
*
* @param file_name path of INI file to save collected data to
*********************************************************************/
API(const AnsiString& file_name);
/*! ******************************************************************
* @brief add pointer to string variable to monitor value
*
* Adds the specified string variable to be tracked, storing a pointer
* to access the value within a mapping.
*
* @param label key to save recorded information under
* @param data pointer to string variable to track
*********************************************************************/
void add_metadata_str(const AnsiString& label, AnsiString* data);
/*! ******************************************************************
* @brief add pointer to boolean variable to monitor value
*
* Adds the specified boolean variable to be tracked, storing a pointer
* to access the value within a mapping.
*
* @param label key to save recorded information under
* @param data pointer to boolean variable to track
*********************************************************************/
void add_metadata_bool(const AnsiString& label, bool* data);
/*! ******************************************************************
* @brief add pointer to integer variable to monitor value
*
* Adds the specified integer variable to be tracked, storing a pointer
* to access the value within a mapping.
*
* @param label key to save recorded information under
* @param data pointer to integer variable to track
*********************************************************************/
void add_metadata_int(const AnsiString& label, int* data);
/*! ******************************************************************
* @brief save currently recorded status data to INI file
*
* Iterates through all metadata mappings saving the results to the
* INI file specified during definition.
*
*********************************************************************/
void dump();
/*! ******************************************************************
* @brief destructor which clears INI file when program is terminated
*
* When ROS is closed the destructor additionally clears all keys
* within the INI file except the 'running' status which is set to 0
*
*********************************************************************/
~API();
};
#endif