EepromSecureData
CRC-controlled EEPROM memory storage
Loading...
Searching...
No Matches
EepromSecureData< T >

CRC-controlled EEPROM memory storage template class. More...

#include <EepromSecureData.h>

Collaboration diagram for EepromSecureData< T >:

Public Member Functions

 EepromSecureData (EepromSecureBackend backend=EepromSecureBackend::Auto, bool crcEnabled=true)
 Construct a new Eeprom Secure Data object.
 
 EepromSecureData (const T &data, EepromSecureBackend backend=EepromSecureBackend::Auto, bool crcEnabled=true)
 Construct a new Eeprom Secure Data object with initial data.
 
 ~EepromSecureData ()
 Destroy the Eeprom Secure Data object.
 
bool save ()
 Save data to EEPROM memory with CRC.
 
bool load (const T &defaultData=T())
 Load data from EEPROM memory with CRC check.
 
void setCrcEnabled (bool enabled)
 Enable or disable CRC checks on save/load.
 
bool crcEnabled () const
 Check whether CRC checks are enabled.
 
EepromSecureBackend backend () const
 Get resolved storage backend used by this instance.
 
uint16_t size () const
 Get the size of the object with CRC.
 
T & data ()
 Get the data object.
 
const T & data () const
 Get the data object as const.
 
 operator T& ()
 Overloaded cast operator to T &.
 
 operator const T & () const
 Overloaded cast operator to const T &.
 
T * operator& ()
 Overloaded cast operator to T *.
 
const T * operator& () const
 Overloaded cast operator to const T.
 
T & operator= (const T &t)
 Overloaded assignment operator from T.
 
EepromSecureDataoperator= (const EepromSecureData &rhs)
 Overloaded assignment operator from EepromSecureData.
 
bool operator== (const EepromSecureData &rhs) const
 Overloaded equality operator.
 
bool operator!= (const EepromSecureData &rhs) const
 Overloaded not-equality operator.
 

Detailed Description

template<class T>
class EepromSecureData< T >

CRC-controlled EEPROM memory storage template class.

Template Parameters
Tdata type

Definition at line 27 of file EepromSecureData.h.

Constructor & Destructor Documentation

◆ EepromSecureData() [1/2]

template<class T >
EepromSecureData< T >::EepromSecureData ( EepromSecureBackend  backend = EepromSecureBackend::Auto,
bool  crcEnabled = true 
)
inline

Construct a new Eeprom Secure Data object.

EEPROM memory is allocated automatically, EepromBase::counter is updated with the size of the object

Definition at line 35 of file EepromSecureData.h.

References EepromSecureData< T >::size().

Here is the call graph for this function:

◆ EepromSecureData() [2/2]

template<class T >
EepromSecureData< T >::EepromSecureData ( const T &  data,
EepromSecureBackend  backend = EepromSecureBackend::Auto,
bool  crcEnabled = true 
)
inline

Construct a new Eeprom Secure Data object with initial data.

Parameters
datainitial data

Definition at line 46 of file EepromSecureData.h.

References EepromSecureData< T >::data().

Here is the call graph for this function:

◆ ~EepromSecureData()

template<class T >
EepromSecureData< T >::~EepromSecureData ( )
inline

Destroy the Eeprom Secure Data object.

EEPROM memory is saved automatically

Definition at line 56 of file EepromSecureData.h.

References EepromSecureData< T >::save().

Here is the call graph for this function:

Member Function Documentation

◆ backend()

template<class T >
EepromSecureBackend EepromSecureData< T >::backend ( ) const
inline

Get resolved storage backend used by this instance.

Returns
active backend (after Auto resolution)

Definition at line 142 of file EepromSecureData.h.

◆ crcEnabled()

template<class T >
bool EepromSecureData< T >::crcEnabled ( ) const
inline

Check whether CRC checks are enabled.

Returns
true if CRC checks are enabled

Definition at line 133 of file EepromSecureData.h.

◆ data() [1/2]

template<class T >
T & EepromSecureData< T >::data ( )
inline

Get the data object.

Definition at line 156 of file EepromSecureData.h.

Referenced by EepromSecureData< T >::EepromSecureData().

◆ data() [2/2]

template<class T >
const T & EepromSecureData< T >::data ( ) const
inline

Get the data object as const.

Definition at line 163 of file EepromSecureData.h.

◆ load()

template<class T >
bool EepromSecureData< T >::load ( const T &  defaultData = T())
inline

Load data from EEPROM memory with CRC check.

Parameters
defaultDatadefault data if CRC check failed
Returns
true if CRC check passed, data restored from EEPROM memory
false if CRC check failed, data restored from defaultData

Definition at line 86 of file EepromSecureData.h.

References EepromSecureData< T >::save().

Here is the call graph for this function:

◆ operator const T &()

template<class T >
EepromSecureData< T >::operator const T & ( ) const
inline

Overloaded cast operator to const T &.

Returns
the data object

Definition at line 181 of file EepromSecureData.h.

◆ operator T&()

template<class T >
EepromSecureData< T >::operator T& ( )
inline

Overloaded cast operator to T &.

Returns
the data object

Definition at line 172 of file EepromSecureData.h.

◆ operator!=()

template<class T >
bool EepromSecureData< T >::operator!= ( const EepromSecureData< T > &  rhs) const
inline

Overloaded not-equality operator.

Definition at line 230 of file EepromSecureData.h.

◆ operator&() [1/2]

template<class T >
T * EepromSecureData< T >::operator& ( )
inline

Overloaded cast operator to T *.

Returns
pointer to the data object

Definition at line 190 of file EepromSecureData.h.

◆ operator&() [2/2]

template<class T >
const T * EepromSecureData< T >::operator& ( ) const
inline

Overloaded cast operator to const T.

Returns
pointer to the data object

Definition at line 199 of file EepromSecureData.h.

◆ operator=() [1/2]

template<class T >
EepromSecureData & EepromSecureData< T >::operator= ( const EepromSecureData< T > &  rhs)
inline

Overloaded assignment operator from EepromSecureData.

Definition at line 215 of file EepromSecureData.h.

◆ operator=() [2/2]

template<class T >
T & EepromSecureData< T >::operator= ( const T &  t)
inline

Overloaded assignment operator from T.

Definition at line 206 of file EepromSecureData.h.

◆ operator==()

template<class T >
bool EepromSecureData< T >::operator== ( const EepromSecureData< T > &  rhs) const
inline

Overloaded equality operator.

Definition at line 223 of file EepromSecureData.h.

◆ save()

template<class T >
bool EepromSecureData< T >::save ( )
inline

Save data to EEPROM memory with CRC.

Returns
true

Definition at line 65 of file EepromSecureData.h.

Referenced by EepromSecureData< T >::load(), and EepromSecureData< T >::~EepromSecureData().

◆ setCrcEnabled()

template<class T >
void EepromSecureData< T >::setCrcEnabled ( bool  enabled)
inline

Enable or disable CRC checks on save/load.

Parameters
enabledtrue to use CRC, false to bypass CRC validation

Definition at line 124 of file EepromSecureData.h.

◆ size()

template<class T >
uint16_t EepromSecureData< T >::size ( ) const
inline

Get the size of the object with CRC.

Definition at line 149 of file EepromSecureData.h.

Referenced by EepromSecureData< T >::EepromSecureData().