HomeWaterLeaksDetection
FreeMemoryMeasurement.h
Go to the documentation of this file.
1 #ifndef UNTITLED_FREE_MEMORY_MEASUREMENT_H
2 #define UNTITLED_FREE_MEMORY_MEASUREMENT_H
3 
4 #ifdef __arm__
5  extern "C" char* sbrk(int incr);
6 #else // __ARM__
7  extern char *__brkval;
8 #endif // __arm__
9 
10 #include "Arduino.h"
11 #include "Setup.h"
12 
13 //====================debugging=========================
14 
15 // if debugging is enabled,
16 // include this file as well
17 #ifdef DEBUG
18 # include <ILoggable.h>
19 #endif
20 
21 //====================web server========================
22 
23 // if the webserver is enabled,
24 // include these files as well
25 #ifdef WEB_SERVER
26 # include <map>
27 # include <HTMLDataSource.h>
28 #endif
29 
30 //==================LCD display=========================
31 
32 // if the LCD display is enabled,
33 // include this file as well
34 #ifdef LCD_DISPLAY
35 # include <IDisplayable.h>
36 #endif
37 
38 //===========FreeMemoryMeasurement class================
39 
49  #ifdef DEBUG
50  : public ILoggable
51  #endif
52  #ifdef WEB_SERVER
53  # ifdef DEBUG
54  , public HTMLDataSource
55  # else
56  : public HTMLDataSource
57  # endif
58  #endif
59  #ifdef LCD_DISPLAY
60  #if defined(DEBUG) || defined(WEB_SERVER)
61  , public IDisplayable
62  # else
63  : public IDisplayable
64  # endif
65  #endif
66 {
67 //====================private data======================
68 private:
70 
71 //==================private methods=====================
72 private:
75 
78 
81 
84  int getFreeRAM() const;
85 
86 //==================public methods======================
87 public:
95 
96 //====================debugging=========================
97 #ifdef DEBUG
98  const String getLogDescription() const;
101 
104  const String getLogID() const;
105 #endif
106 
107 //==================LCD display=========================
108 #ifdef LCD_DISPLAY
109  const String getRow(int row) const override;
118 #endif
119 
120 //====================web server========================
121 #ifdef WEB_SERVER
122 private:
125  std::map<int, String (*)(const FreeMemoryMeasurement& freeMemoryMeasurement)> htmlData;
126 
127 public:
135  const String getHTMLData(const int id) const override;
136 
137 private:
141  friend String HTML_freeRAM(const FreeMemoryMeasurement& freeMemoryMeasurement);
142 #endif
143 };
144 
145 #endif
FreeMemoryMeasurement::instance
static FreeMemoryMeasurement * instance
the instance of the class
Definition: FreeMemoryMeasurement.h:69
FreeMemoryMeasurement::htmlData
std::map< int, String(*)(const FreeMemoryMeasurement &freeMemoryMeasurement)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition: FreeMemoryMeasurement.h:125
IDisplayable.h
FreeMemoryMeasurement::getRow
const String getRow(int row) const override
Returns the content of the row given as a parameter.
FreeMemoryMeasurement::FreeMemoryMeasurement
FreeMemoryMeasurement()
Constructor of the class.
Definition: FreeMemoryMeasurement.cpp:9
ILoggable.h
FreeMemoryMeasurement
Definition: FreeMemoryMeasurement.h:66
HTMLDataSource.h
Setup.h
__brkval
char * __brkval
FreeMemoryMeasurement::HTML_freeRAM
friend String HTML_freeRAM(const FreeMemoryMeasurement &freeMemoryMeasurement)
Associated function for returing amount of memory being used at the moment.
FreeMemoryMeasurement::FreeMemoryMeasurement
FreeMemoryMeasurement(FreeMemoryMeasurement const &)
Copy constructor of the class.
Definition: FreeMemoryMeasurement.h:77
FreeMemoryMeasurement::operator=
FreeMemoryMeasurement & operator=(FreeMemoryMeasurement const &)
Assignment operator of the class.
Definition: FreeMemoryMeasurement.h:80
FreeMemoryMeasurement::getInstance
static FreeMemoryMeasurement * getInstance()
Returns the instance of the class.
Definition: FreeMemoryMeasurement.cpp:15
ILoggable
Definition: ILoggable.h:13
IDisplayable
Definition: IDisplayable.h:12
HTMLDataSource
Definition: HTMLDataSource.h:15
FreeMemoryMeasurement::getHTMLData
const String getHTMLData(const int id) const override
Since this class is registered as a source of data for the HTML content, it needs return the appropri...
FreeMemoryMeasurement::getFreeRAM
int getFreeRAM() const
Return the amount of RAM currently being used.
Definition: FreeMemoryMeasurement.cpp:21