RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::SystemMemoryInformation Class Reference

Data class that contains information about the system's memory and swap space, in Kilobytes. More...

#include <SystemMemoryInformation.h>

Public Member Functions

 SystemMemoryInformation ()
 Builds an empty SystemMemoryInformation with all fields zeroed. More...
 
 SystemMemoryInformation (const long systemMemoryTotalInKB, const long systemMemoryFreeInKB, const long systemMemoryAvailableInKB, const long systemSwapMemoryTotalInKB, const long systemSwapMemoryFreeInKB)
 Builds a SystemMemoryInformation from raw memory and swap figures, computing the derived percentages. More...
 
virtual ~SystemMemoryInformation ()=default
 Defaulted destructor. More...
 
std::string ToString () const
 Serializes the memory and swap figures and their derived percentages to a string. More...
 
long GetSystemMemoryTotalInKB () const
 Gets the total system memory, in KB. More...
 
long GetSystemMemoryFreeInKB () const
 Gets the free system memory, in KB. More...
 
long GetSystemMemoryAvailableInKB () const
 Gets the available system memory, in KB. More...
 
float GetAvailableMemoryPercent () const
 Gets the percent of system memory available. More...
 
long GetSystemSwapMemoryTotalInKB () const
 Gets the total swap memory, in KB. More...
 
long GetSystemSwapMemoryFreeInKB () const
 Gets the free swap memory, in KB. More...
 
float GetSwapMemoryUsedPercent () const
 Gets the percent of swap memory used. More...
 
void SetSystemMemoryTotalInKB (const long systemMemoryTotalInKB)
 Sets the total system memory (in KB) and recomputes the derived percentages. More...
 
void SetSystemMemoryFreeInKB (const long systemMemoryFreeInKB)
 Sets the free system memory, in KB. More...
 
void SetSystemMemoryAvailableInKB (const long systemMemoryAvailableInKB)
 Sets the available system memory (in KB) and recomputes the derived percentages. More...
 
void SetSystemSwapMemoryTotalInKB (const long systemSwapMemoryTotalInKB)
 Sets the total swap memory (in KB) and recomputes the derived percentages. More...
 
void SetSystemSwapMemoryFreeInKB (const long systemSwapMemoryFreeInKB)
 Sets the free swap memory (in KB) and recomputes the derived percentages. More...
 

Protected Member Functions

void CalculatePercentages ()
 Recomputes the available-memory percent and the used-swap percent from the current memory and swap figures. More...
 

Protected Attributes

long mySystemMemoryTotalInKB
 Total system memory, in KB. More...
 
long mySystemMemoryFreeInKB
 Free system memory, in KB. More...
 
long mySystemMemoryAvailableInKB
 Available system memory, in KB. More...
 
float myAvailableMemoryPercent
 Percent of system memory available (computed). More...
 
long mySystemSwapMemoryTotalInKB
 Total swap memory, in KB. More...
 
long mySystemSwapMemoryFreeInKB
 Free swap memory, in KB. More...
 
float mySwapMemoryUsedPercent
 Percent of swap memory used (computed). More...
 

Detailed Description

Data class that contains information about the system's memory and swap space, in Kilobytes.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ SystemMemoryInformation() [1/2]

RumPi::SystemMemoryInformation::SystemMemoryInformation ( )

Builds an empty SystemMemoryInformation with all fields zeroed.

Author
Eddie O'Hagan
Date
8/13/2026
SystemMemoryInformation()
Builds an empty SystemMemoryInformation with all fields zeroed.
Definition: SystemMemoryInformation.cpp:15

◆ SystemMemoryInformation() [2/2]

RumPi::SystemMemoryInformation::SystemMemoryInformation ( const long  systemMemoryTotalInKB,
const long  systemMemoryFreeInKB,
const long  systemMemoryAvailableInKB,
const long  systemSwapMemoryTotalInKB,
const long  systemSwapMemoryFreeInKB 
)

Builds a SystemMemoryInformation from raw memory and swap figures, computing the derived percentages.

Author
Eddie O'Hagan
Date
8/13/2026
SystemMemoryInformation info(4096000, 512000, 2048000, 1024000, 1024000);
Parameters
[in]systemMemoryTotalInKBTotal system memory, in KB.
[in]systemMemoryFreeInKBFree system memory, in KB.
[in]systemMemoryAvailableInKBAvailable system memory, in KB.
[in]systemSwapMemoryTotalInKBTotal swap memory, in KB.
[in]systemSwapMemoryFreeInKBFree swap memory, in KB.

◆ ~SystemMemoryInformation()

virtual RumPi::SystemMemoryInformation::~SystemMemoryInformation ( )
virtualdefault

Defaulted destructor.

Author
Eddie O'Hagan
Date
8/13/2026

Member Function Documentation

◆ CalculatePercentages()

void RumPi::SystemMemoryInformation::CalculatePercentages ( )
protected

Recomputes the available-memory percent and the used-swap percent from the current memory and swap figures.

Author
Eddie O'Hagan
Date
8/13/2026
//Called whenever a memory or swap field changes.

◆ GetAvailableMemoryPercent()

float RumPi::SystemMemoryInformation::GetAvailableMemoryPercent ( ) const

Gets the percent of system memory available.

Author
Eddie O'Hagan
Date
8/13/2026
float percent = info.GetAvailableMemoryPercent();
Returns
The available memory, as a percent.

◆ GetSwapMemoryUsedPercent()

float RumPi::SystemMemoryInformation::GetSwapMemoryUsedPercent ( ) const

Gets the percent of swap memory used.

Author
Eddie O'Hagan
Date
8/13/2026
float percent = info.GetSwapMemoryUsedPercent();
Returns
The used swap memory, as a percent.

◆ GetSystemMemoryAvailableInKB()

long RumPi::SystemMemoryInformation::GetSystemMemoryAvailableInKB ( ) const

Gets the available system memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
long available = info.GetSystemMemoryAvailableInKB();
Returns
The available system memory, in KB.

◆ GetSystemMemoryFreeInKB()

long RumPi::SystemMemoryInformation::GetSystemMemoryFreeInKB ( ) const

Gets the free system memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
long free = info.GetSystemMemoryFreeInKB();
Returns
The free system memory, in KB.

◆ GetSystemMemoryTotalInKB()

long RumPi::SystemMemoryInformation::GetSystemMemoryTotalInKB ( ) const

Gets the total system memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
long total = info.GetSystemMemoryTotalInKB();
Returns
The total system memory, in KB.

◆ GetSystemSwapMemoryFreeInKB()

long RumPi::SystemMemoryInformation::GetSystemSwapMemoryFreeInKB ( ) const

Gets the free swap memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
long swapFree = info.GetSystemSwapMemoryFreeInKB();
Returns
The free swap memory, in KB.

◆ GetSystemSwapMemoryTotalInKB()

long RumPi::SystemMemoryInformation::GetSystemSwapMemoryTotalInKB ( ) const

Gets the total swap memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
long swapTotal = info.GetSystemSwapMemoryTotalInKB();
Returns
The total swap memory, in KB.

◆ SetSystemMemoryAvailableInKB()

void RumPi::SystemMemoryInformation::SetSystemMemoryAvailableInKB ( const long  systemMemoryAvailableInKB)

Sets the available system memory (in KB) and recomputes the derived percentages.

Author
Eddie O'Hagan
Date
8/13/2026
info.SetSystemMemoryAvailableInKB(2048000);
Parameters
[in]systemMemoryAvailableInKBThe available system memory, in KB.

◆ SetSystemMemoryFreeInKB()

void RumPi::SystemMemoryInformation::SetSystemMemoryFreeInKB ( const long  systemMemoryFreeInKB)

Sets the free system memory, in KB.

Author
Eddie O'Hagan
Date
8/13/2026
info.SetSystemMemoryFreeInKB(512000);
Parameters
[in]systemMemoryFreeInKBThe free system memory, in KB.

◆ SetSystemMemoryTotalInKB()

void RumPi::SystemMemoryInformation::SetSystemMemoryTotalInKB ( const long  systemMemoryTotalInKB)

Sets the total system memory (in KB) and recomputes the derived percentages.

Author
Eddie O'Hagan
Date
8/13/2026
info.SetSystemMemoryTotalInKB(4096000);
Parameters
[in]systemMemoryTotalInKBThe total system memory, in KB.

◆ SetSystemSwapMemoryFreeInKB()

void RumPi::SystemMemoryInformation::SetSystemSwapMemoryFreeInKB ( const long  systemSwapMemoryFreeInKB)

Sets the free swap memory (in KB) and recomputes the derived percentages.

Author
Eddie O'Hagan
Date
8/13/2026
info.SetSystemSwapMemoryFreeInKB(512000);
Parameters
[in]systemSwapMemoryFreeInKBThe free swap memory, in KB.

◆ SetSystemSwapMemoryTotalInKB()

void RumPi::SystemMemoryInformation::SetSystemSwapMemoryTotalInKB ( const long  systemSwapMemoryTotalInKB)

Sets the total swap memory (in KB) and recomputes the derived percentages.

Author
Eddie O'Hagan
Date
8/13/2026
info.SetSystemSwapMemoryTotalInKB(1024000);
Parameters
[in]systemSwapMemoryTotalInKBThe total swap memory, in KB.

◆ ToString()

std::string RumPi::SystemMemoryInformation::ToString ( ) const

Serializes the memory and swap figures and their derived percentages to a string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = info.ToString();
Returns
A multi-line string describing the system memory information.

Member Data Documentation

◆ myAvailableMemoryPercent

float RumPi::SystemMemoryInformation::myAvailableMemoryPercent
protected

Percent of system memory available (computed).

◆ mySwapMemoryUsedPercent

float RumPi::SystemMemoryInformation::mySwapMemoryUsedPercent
protected

Percent of swap memory used (computed).

◆ mySystemMemoryAvailableInKB

long RumPi::SystemMemoryInformation::mySystemMemoryAvailableInKB
protected

Available system memory, in KB.

◆ mySystemMemoryFreeInKB

long RumPi::SystemMemoryInformation::mySystemMemoryFreeInKB
protected

Free system memory, in KB.

◆ mySystemMemoryTotalInKB

long RumPi::SystemMemoryInformation::mySystemMemoryTotalInKB
protected

Total system memory, in KB.

◆ mySystemSwapMemoryFreeInKB

long RumPi::SystemMemoryInformation::mySystemSwapMemoryFreeInKB
protected

Free swap memory, in KB.

◆ mySystemSwapMemoryTotalInKB

long RumPi::SystemMemoryInformation::mySystemSwapMemoryTotalInKB
protected

Total swap memory, in KB.


The documentation for this class was generated from the following files: