Implemented set/get/insert functions for config file handler
This commit is contained in:
parent
74b38a6d06
commit
0fb620b290
@ -60,17 +60,93 @@ ReturnValue_t GlobalConfigHandler::unlockConfigFile(){
|
|||||||
|
|
||||||
//TBD for set/get/insert: Mutx lock, set/get/insert, Mutex unlock
|
//TBD for set/get/insert: Mutx lock, set/get/insert, Mutex unlock
|
||||||
//Use template functions for different data types
|
//Use template functions for different data types
|
||||||
ReturnValue_t GlobalConfigHandler::setConfigFileValue(){
|
//Trigger Event, if set/get/insert/write/Read fails
|
||||||
|
template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(std::string key, T data){
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
ReturnValue_t resultSet = RETURN_OK;
|
||||||
|
|
||||||
|
result=lockConfigFile();
|
||||||
|
if (result!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::setConfigFileValue lock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultSet=setValue(key, data);
|
||||||
|
if(resultSet!=RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
result=unlockConfigFile();
|
||||||
|
if (result!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::setConfigFileValue unlock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
template <typename T> ReturnValue_t GlobalConfigHandler::getConfigFileValue(std::string key, T& data){
|
||||||
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
ReturnValue_t resultGet = RETURN_OK;
|
||||||
|
|
||||||
|
result=lockConfigFile();
|
||||||
|
if (result!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::getConfigFileValue lock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultGet=getValue(key, data);
|
||||||
|
if (resultGet!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::getConfigFileValue lock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
result=unlockConfigFile();
|
||||||
|
if (result!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::getConfigFileValue unlock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
ReturnValue_t GlobalConfigHandler::getConfigFileValue(){
|
template <typename T> ReturnValue_t GlobalConfigHandler::insertConfigFileValue(std::string key, T data){
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
return result;
|
ReturnValue_t resultInsert = RETURN_OK;
|
||||||
}
|
|
||||||
ReturnValue_t GlobalConfigHandler::insertConfigFileValue(){
|
result=lockConfigFile();
|
||||||
ReturnValue_t result = RETURN_OK;
|
if (result!= RETURN_OK){
|
||||||
return result;
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::insertConfigFileValue lock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultInsert=insertValue(key, data);//Should never fail
|
||||||
|
if(resultInsert!=RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::insertConfigFileValue insert failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
result=unlockConfigFile();
|
||||||
|
if (result!= RETURN_OK){
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "GlobalConfigHandler::insertConfigFileValue unlock mutex failed with " << result << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultInsert;
|
||||||
}
|
}
|
||||||
ReturnValue_t GlobalConfigHandler::resetConfigFileValues(){
|
ReturnValue_t GlobalConfigHandler::resetConfigFileValues(){
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
@ -44,9 +44,9 @@ public:
|
|||||||
|
|
||||||
ReturnValue_t lockConfigFile();
|
ReturnValue_t lockConfigFile();
|
||||||
ReturnValue_t unlockConfigFile();
|
ReturnValue_t unlockConfigFile();
|
||||||
ReturnValue_t setConfigFileValue();
|
template <typename T> ReturnValue_t setConfigFileValue(std::string key, T data);
|
||||||
ReturnValue_t getConfigFileValue();
|
template <typename T> ReturnValue_t getConfigFileValue(std::string key, T& data);
|
||||||
ReturnValue_t insertConfigFileValue();
|
template <typename T> ReturnValue_t insertConfigFileValue(std::string key, T data);
|
||||||
ReturnValue_t resetConfigFileValues();
|
ReturnValue_t resetConfigFileValues();
|
||||||
ReturnValue_t WriteConfigFile();
|
ReturnValue_t WriteConfigFile();
|
||||||
ReturnValue_t ReadConfigFile();
|
ReturnValue_t ReadConfigFile();
|
||||||
|
Loading…
Reference in New Issue
Block a user