added local parameter handler
This commit is contained in:
@@ -31,7 +31,8 @@ class LocalParameterHandler : public NVMParameterBase {
|
||||
ReturnValue_t initialize();
|
||||
|
||||
/**
|
||||
* @brief Function to add parameter to json file
|
||||
* @brief Function to add parameter to json file. If the json file does
|
||||
* not yet exist it will be created here.
|
||||
*
|
||||
* @param key The string to identify the parameter
|
||||
* @param value The value to set for this parameter
|
||||
@@ -43,6 +44,17 @@ class LocalParameterHandler : public NVMParameterBase {
|
||||
*/
|
||||
template<typename T> ReturnValue_t addParameter(std::string key, T value);
|
||||
|
||||
/**
|
||||
* @brief Function will update a parameter which already exists in the json
|
||||
* file
|
||||
*
|
||||
* @param key The unique string to identify the parameter to update
|
||||
* @param value The new new value to set
|
||||
*
|
||||
* @return OK if successful, otherwise error return value
|
||||
*/
|
||||
template<typename T> ReturnValue_t updateParameter(std::string key, T value);
|
||||
|
||||
private:
|
||||
|
||||
// Name relative to mount point of SD card where parameters will be stored
|
||||
@@ -63,4 +75,16 @@ template<typename T> inline ReturnValue_t LocalParameterHandler::addParameter(st
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
template<typename T> inline ReturnValue_t LocalParameterHandler::updateParameter(std::string key, T value) {
|
||||
ReturnValue_t result = setValue(key, value);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = writeJsonFile();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
#endif /* BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ */
|
||||
|
Reference in New Issue
Block a user