HomeWaterLeaksDetection
FreeMemoryMeasurement Class Reference

#include <FreeMemoryMeasurement.h>

Public Member Functions

const String getRow (int row) const override
 Returns the content of the row given as a parameter. More...
 
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 appropriate value according to the id given as a parameter. More...
 

Static Public Member Functions

static FreeMemoryMeasurementgetInstance ()
 Returns the instance of the class. More...
 

Private Member Functions

 FreeMemoryMeasurement ()
 Constructor of the class. More...
 
 FreeMemoryMeasurement (FreeMemoryMeasurement const &)
 Copy constructor of the class. More...
 
FreeMemoryMeasurementoperator= (FreeMemoryMeasurement const &)
 Assignment operator of the class. More...
 
int getFreeRAM () const
 Return the amount of RAM currently being used. More...
 

Private Attributes

std::map< int, String(*)(const FreeMemoryMeasurement &freeMemoryMeasurement)> htmlData
 A map of different values (keys) and their associated functions which returns the appropriate values. More...
 

Static Private Attributes

static FreeMemoryMeasurementinstance = NULL
 the instance of the class More...
 

Friends

String HTML_freeRAM (const FreeMemoryMeasurement &freeMemoryMeasurement)
 Associated function for returing amount of memory being used at the moment. More...
 

Additional Inherited Members

- Static Public Attributes inherited from HTMLDataSource
static const String UNDEFINED_DATA = String("UNDEFINED")
 string "UNDEFINED" More...
 

Detailed Description

Author
silhavyj A17B0362P

This class provides information about the current use of the the SRAM memory. The particular value depends on the moment the method is called as the system might be performing different memory-consuming tasks. This information is used as an indication what the device is not running out of memory.

Definition at line 48 of file FreeMemoryMeasurement.h.

Constructor & Destructor Documentation

◆ FreeMemoryMeasurement() [1/2]

FreeMemoryMeasurement::FreeMemoryMeasurement ( )
private

Constructor of the class.

Definition at line 9 of file FreeMemoryMeasurement.cpp.

9  {
10  #ifdef WEB_SERVER
11  htmlData[16] = &HTML_freeRAM;
12  #endif
13 }

References HTML_freeRAM, and htmlData.

Referenced by getInstance().

◆ FreeMemoryMeasurement() [2/2]

FreeMemoryMeasurement::FreeMemoryMeasurement ( FreeMemoryMeasurement const &  )
inlineprivate

Copy constructor of the class.

Definition at line 77 of file FreeMemoryMeasurement.h.

77 {};

Member Function Documentation

◆ getFreeRAM()

int FreeMemoryMeasurement::getFreeRAM ( ) const
private

Return the amount of RAM currently being used.

Returns
the amount of RAM being used at the moment

Definition at line 21 of file FreeMemoryMeasurement.cpp.

21  {
22  char top;
23  #ifdef __arm__
24  return &top - reinterpret_cast<char*>(sbrk(0));
25  #elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
26  return &top - __brkval;
27  #else // __arm__
28  return __brkval ? &top - __brkval : &top - __malloc_heap_start;
29  #endif // __arm__
30 }

References __brkval.

◆ getHTMLData()

const String FreeMemoryMeasurement::getHTMLData ( const int  id) const
overridevirtual

Since this class is registered as a source of data for the HTML content, it needs return the appropriate value according to the id given as a parameter.

Parameters
id- the id of the piece of data
Returns
If the class holds this piece of information, it will return it. Otherwise, "UNDEFINED" will be returned.

Implements HTMLDataSource.

◆ getInstance()

FreeMemoryMeasurement * FreeMemoryMeasurement::getInstance ( )
static

Returns the instance of the class.

If the instance has not been created, it will create it and then return it.

Returns
the instance of the class

Definition at line 15 of file FreeMemoryMeasurement.cpp.

15  {
16  if (instance == NULL)
18  return instance;
19 }

References FreeMemoryMeasurement(), and instance.

Referenced by setup().

◆ getRow()

const String FreeMemoryMeasurement::getRow ( int  row) const
overridevirtual

Returns the content of the row given as a parameter.

This class represents one page on the LCD display. Each of the 4 rows has different content identified by the number of the row.

Parameters
rownumber of the row
Returns
content to be displayed on that row of the LCD

Implements IDisplayable.

◆ operator=()

FreeMemoryMeasurement& FreeMemoryMeasurement::operator= ( FreeMemoryMeasurement const &  )
inlineprivate

Assignment operator of the class.

Definition at line 80 of file FreeMemoryMeasurement.h.

80 { return *this; }

Friends And Related Function Documentation

◆ HTML_freeRAM

String HTML_freeRAM ( const FreeMemoryMeasurement freeMemoryMeasurement)
friend

Associated function for returing amount of memory being used at the moment.

Parameters
freeMemoryMeasurement- the instance of the FreeMemoryMeasurement class
Returns
the memory usage [B]

Referenced by FreeMemoryMeasurement().

Member Data Documentation

◆ htmlData

std::map<int, String (*)(const FreeMemoryMeasurement& freeMemoryMeasurement)> FreeMemoryMeasurement::htmlData
private

A map of different values (keys) and their associated functions which returns the appropriate values.

Definition at line 125 of file FreeMemoryMeasurement.h.

Referenced by FreeMemoryMeasurement().

◆ instance

FreeMemoryMeasurement * FreeMemoryMeasurement::instance = NULL
staticprivate

the instance of the class

Definition at line 69 of file FreeMemoryMeasurement.h.

Referenced by getInstance().


The documentation for this class was generated from the following files:
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
FreeMemoryMeasurement::FreeMemoryMeasurement
FreeMemoryMeasurement()
Constructor of the class.
Definition: FreeMemoryMeasurement.cpp:9
__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.