Skyward boardcore
|
This is the front-end for the registry to store and load the configuration. Its methods are type unsafe since the type is determined by the entry setted. It does check the data types but its job is mainly the one of get and set for the given ConfigurationId, the value of the entry. It also exposes methods for go into a "safe" state during armed state / flight. Finally there are methods to visit the entire configuration (forEach). More...
#include <RegistryFrontend.h>
Public Types | |
using | EntryFunc = std::function<void(ConfigurationId, EntryStructsUnion&)> |
Public Member Functions | |
RegistryFrontend (std::unique_ptr< RegistryBackend > backend=std::make_unique< DummyBackend >()) | |
Registry front end constructor. Initializes the configuration of the underlying objects and reserves 1KB for the vectors and map data structures. | |
RegistryError | start () |
Start function to start frontend and other objects, such as ActiveObjects, needed to write to backend, and the backend itself. | |
void | arm () |
Disables the memory registry set and allocations. To be use when the rocket itself is armed and during flight. | |
void | disarm () |
Enable set methods and memory allocations. | |
void | forEach (const EntryFunc &predicate) |
Executes immediately the predicate for each to the configuration applying the callback with the id and EntryStructsUnion union as parameter for each configured entry in the configuration. | |
bool | isEntryConfigured (const ConfigurationId configurationIndex) |
Verify if there is an existing entry given its enum entry. | |
bool | isEmpty () |
Verify that the configuration is empty or exists some setted entries. | |
template<typename T > | |
RegistryError | getUnsafe (const ConfigurationId configurationIndex, T &outValue) |
Gets the value for a given configuration entry. | |
template<typename T > | |
T | getOrSetDefaultUnsafe (const ConfigurationId configurationIndex, T defaultValue) |
Gets the value for a specified configuration entry. Otherwise returns default and try to set the default value. | |
template<typename T > | |
RegistryError | setUnsafe (ConfigurationId configurationIndex, T value) |
Sets the value for the configuration entry with the specified enum. | |
RegistryError | load () |
Loads from the backend the configuration. | |
RegistryError | save () |
Saves the configuration to the backend. | |
void | clear () |
Clear the configuration actually saved, resetting to empty configuration. | |
This is the front-end for the registry to store and load the configuration. Its methods are type unsafe since the type is determined by the entry setted. It does check the data types but its job is mainly the one of get and set for the given ConfigurationId, the value of the entry. It also exposes methods for go into a "safe" state during armed state / flight. Finally there are methods to visit the entire configuration (forEach).
Definition at line 48 of file RegistryFrontend.h.
using Boardcore::RegistryFrontend::EntryFunc = std::function<void(ConfigurationId, EntryStructsUnion&)> |
Definition at line 51 of file RegistryFrontend.h.
Boardcore::RegistryFrontend::RegistryFrontend | ( | std::unique_ptr< RegistryBackend > | backend = std::make_unique<DummyBackend>() | ) |
Registry front end constructor. Initializes the configuration of the underlying objects and reserves 1KB for the vectors and map data structures.
Definition at line 27 of file RegistryFrontend.cpp.
void Boardcore::RegistryFrontend::arm | ( | ) |
Disables the memory registry set and allocations. To be use when the rocket itself is armed and during flight.
Definition at line 44 of file RegistryFrontend.cpp.
void Boardcore::RegistryFrontend::clear | ( | ) |
Clear the configuration actually saved, resetting to empty configuration.
Definition at line 108 of file RegistryFrontend.cpp.
void Boardcore::RegistryFrontend::disarm | ( | ) |
Enable set methods and memory allocations.
Definition at line 50 of file RegistryFrontend.cpp.
void Boardcore::RegistryFrontend::forEach | ( | const EntryFunc & | predicate | ) |
Executes immediately the predicate for each to the configuration applying the callback with the id and EntryStructsUnion union as parameter for each configured entry in the configuration.
predicate | The predicate function to execute for each configuration entry |
Definition at line 56 of file RegistryFrontend.cpp.
|
inline |
Gets the value for a specified configuration entry. Otherwise returns default and try to set the default value.
T | The value data type to be returned and eventually set. |
configurationIndex | Identifies the configuration entry with its enumeration value |
defaultValue | The default value to be returned and set (eventually) in case of non-existing configuration entry |
Definition at line 155 of file RegistryFrontend.h.
|
inline |
Gets the value for a given configuration entry.
T | The value data type for such configuration entry |
configurationIndex | Identifies the configuration entry with its enumeration value |
outValue | the specified configuration entry value |
Checks that the value type corresponds to the set type and finds the entry
Definition at line 127 of file RegistryFrontend.h.
bool Boardcore::RegistryFrontend::isEmpty | ( | ) |
Verify that the configuration is empty or exists some setted entries.
Definition at line 84 of file RegistryFrontend.cpp.
bool Boardcore::RegistryFrontend::isEntryConfigured | ( | const ConfigurationId | configurationIndex | ) |
Verify if there is an existing entry given its enum entry.
configurationIndex | The configuration entry ID for which we verify the entry is configured. |
Definition at line 76 of file RegistryFrontend.cpp.
RegistryError Boardcore::RegistryFrontend::load | ( | ) |
Loads from the backend the configuration.
Definition at line 63 of file RegistryFrontend.cpp.
RegistryError Boardcore::RegistryFrontend::save | ( | ) |
Saves the configuration to the backend.
Definition at line 90 of file RegistryFrontend.cpp.
|
inline |
Sets the value for the configuration entry with the specified enum.
T | The configuration value datatype |
configurationIndex | The ID of the configuration entry to set |
value | The value to be set for the specified configuration entry |
Definition at line 185 of file RegistryFrontend.h.
RegistryError Boardcore::RegistryFrontend::start | ( | ) |
Start function to start frontend and other objects, such as ActiveObjects, needed to write to backend, and the backend itself.
Definition at line 35 of file RegistryFrontend.cpp.