30#include <unordered_map>
59 std::make_unique<DummyBackend>());
126 template <
typename T>
130 std::lock_guard<std::recursive_mutex> lock(mutexForRegistry);
131 auto iterator = configuration.find(configurationIndex);
134 if (iterator == configuration.end())
136 if (!iterator->second.get(outValue))
154 template <
typename T>
158 std::lock_guard<std::recursive_mutex> lock(mutexForRegistry);
165 "Registry - Could not insert the default configuration");
184 template <
typename T>
187 std::lock_guard<std::recursive_mutex> lock(mutexForRegistry);
193 auto insert = configuration.insert({configurationIndex, entry});
195 insert.first->second = entry;
247 std::recursive_mutex mutexForRegistry;
248 std::unordered_map<ConfigurationId, EntryStructsUnion> configuration;
249 bool isArmed =
false;
250 std::vector<uint8_t> serializationVector;
251 std::unique_ptr<RegistryBackend> backend;
#define LOG_ERR(logger,...)
static PrintLogger getLogger(const string &name)
This is the front-end for the registry to store and load the configuration. Its methods are type unsa...
RegistryFrontend(std::unique_ptr< RegistryBackend > backend=std::make_unique< DummyBackend >())
Registry front end constructor. Initializes the configuration of the underlying objects and reserves ...
std::function< void(ConfigurationId, EntryStructsUnion &)> EntryFunc
RegistryError getUnsafe(const ConfigurationId configurationIndex, T &outValue)
Gets the value for a given configuration entry.
void forEach(const EntryFunc &predicate)
Executes immediately the predicate for each to the configuration applying the callback with the id an...
void disarm()
Enable set methods and memory allocations.
bool isEntryConfigured(const ConfigurationId configurationIndex)
Verify if there is an existing entry given its enum entry.
RegistryError start()
Start function to start frontend and other objects, such as ActiveObjects, needed to write to backend...
T getOrSetDefaultUnsafe(const ConfigurationId configurationIndex, T defaultValue)
Gets the value for a specified configuration entry. Otherwise returns default and try to set the defa...
RegistryError load()
Loads from the backend the configuration.
void clear()
Clear the configuration actually saved, resetting to empty configuration.
RegistryError save()
Saves the configuration to the backend.
void arm()
Disables the memory registry set and allocations. To be use when the rocket itself is armed and durin...
RegistryError setUnsafe(ConfigurationId configurationIndex, T value)
Sets the value for the configuration entry with the specified enum.
bool isEmpty()
Verify that the configuration is empty or exists some setted entries.
This file includes all the types the logdecoder script will decode.
RegistryError
RegistryError enumeration as return type.
@ INCORRECT_TYPE
The typeId and value type not correspond.
@ ENTRY_NOT_FOUND
Not found such entry.
@ ARMED
The registry is armed, the operation is not allowed.
Union data struct to be stored in the map. It does contain the enumeration index and the value of suc...
static EntryStructsUnion make(float value)
Set the Union object with its float value.