#include <Register.h>
|
| | Register (Register const &)=delete |
| | Deleted copy constructor to prevent unintended copying.
|
| |
| void | operator= (Register const &)=delete |
| | Deleted assignment operator to prevent unintended copying.
|
| |
| | Register () |
| | Constructs an empty Register.
|
| |
| bool | setRegister (const String &name, const T *values, size_t count) |
| | Sets or replaces a register with the given name and array of values.
|
| |
| bool | addToRegister (const String &name, const T &value) |
| | Adds a single value to an existing register or creates a new one.
|
| |
| bool | getRegisterValue (const String &name, size_t idx, T &outValue) const |
| | Retrieves a value from the register by name and index.
|
| |
| bool | setRegisterValue (const String &name, size_t idx, const T &value) |
| | Updates a value in the register at the specified index.
|
| |
| size_t | getRegisterLength (const String &name) const |
| | Gets the number of values in the specified register.
|
| |
| void | iterateRegisters (IteratorCallback callback) const |
| | Iterates through all registers and calls the callback function for each one.
|
| |
|
| virtual void | _processRegister (const String &name, const T &value) |
| | Hook method called when a register value is added or modified.
|
| |
◆ IteratorCallback
Function type used for iterating through registers.
The callback receives the register name and a pointer to its value array
◆ Register() [1/2]
Deleted copy constructor to prevent unintended copying.
◆ Register() [2/2]
◆ _processRegister()
template<typename T>
| virtual void uniot::Register< T >::_processRegister |
( |
const String & | name, |
|
|
const T & | value ) |
|
inlineprotectedvirtual |
Hook method called when a register value is added or modified.
This virtual method is intended to be overridden by derived classes to implement custom behavior when register values change. The base implementation does nothing.
- Parameters
-
| name | The name identifier of the register being modified |
| value | The value being set or added |
Reimplemented in uniot::GpioRegister.
◆ addToRegister()
template<typename T>
| bool uniot::Register< T >::addToRegister |
( |
const String & | name, |
|
|
const T & | value ) |
|
inline |
Adds a single value to an existing register or creates a new one.
If the register doesn't exist yet, it will be created with a default initial capacity. The method automatically handles dynamic resizing if the register's capacity is exceeded. After adding the value, the _processRegister hook is called to allow derived classes to perform additional processing.
- Parameters
-
| name | The name identifier for the register |
| value | The value to add to the register |
- Return values
-
| true | Value was added successfully |
| false | Memory allocation failed or register could not be created |
◆ getRegisterLength()
template<typename T>
| size_t uniot::Register< T >::getRegisterLength |
( |
const String & | name | ) |
const |
|
inline |
Gets the number of values in the specified register.
- Parameters
-
| name | The name identifier for the register |
- Return values
-
| size_t | The number of values in the register |
| 0 | The register doesn't exist or is empty |
◆ getRegisterValue()
template<typename T>
| bool uniot::Register< T >::getRegisterValue |
( |
const String & | name, |
|
|
size_t | idx, |
|
|
T & | outValue ) const |
|
inline |
Retrieves a value from the register by name and index.
Performs bounds checking to ensure the requested index is valid. The value is copied to the provided outValue reference if found.
- Parameters
-
| name | The name identifier for the register |
| idx | Zero-based index of the value within the register |
| outValue | Reference where the retrieved value will be stored |
- Return values
-
| true | Value was retrieved successfully |
| false | Register doesn't exist or index is out of bounds |
◆ iterateRegisters()
Iterates through all registers and calls the callback function for each one.
This method provides a way to access all registers without knowing their names in advance. The callback receives both the register name and a shared pointer to its array of values.
Example usage:
Serial.printf("Register %s has %d values\n", name.c_str(), values->size());
});
std::shared_ptr< T > SharedPointer
Type alias for std::shared_ptr with cleaner syntax.
Definition Common.h:160
- Parameters
-
| callback | The function to call for each register (nullptr callbacks are ignored) |
◆ operator=()
Deleted assignment operator to prevent unintended copying.
◆ setRegister()
template<typename T>
| bool uniot::Register< T >::setRegister |
( |
const String & | name, |
|
|
const T * | values, |
|
|
size_t | count ) |
|
inline |
Sets or replaces a register with the given name and array of values.
This method completely replaces any existing register with the same name. If a register with the given name exists, it will be removed before adding the new one. If count is 0, the register will be removed without creating a new one.
- Parameters
-
| name | The name identifier for the register |
| values | Pointer to an array of values to store |
| count | Number of values in the array |
- Return values
-
| true | Register was set successfully |
| false | Invalid parameters or memory allocation failed |
◆ setRegisterValue()
template<typename T>
| bool uniot::Register< T >::setRegisterValue |
( |
const String & | name, |
|
|
size_t | idx, |
|
|
const T & | value ) |
|
inline |
Updates a value in the register at the specified index.
Performs bounds checking to ensure the requested index is valid. After setting the value, the _processRegister hook is called to allow derived classes to perform additional processing.
- Parameters
-
| name | The name identifier for the register |
| idx | Zero-based index of the value to update |
| value | The new value to set |
- Return values
-
| true | Value was updated successfully |
| false | Register doesn't exist or index is out of bounds |
The documentation for this class was generated from the following file: