|
|
|
@ -58,9 +58,6 @@ ReturnValue_t GlobalConfigHandler::unlockConfigFile(){
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TBD for set/get/insert: Mutx lock, set/get/insert, Mutex unlock
|
|
|
|
|
//Use template functions for different data types
|
|
|
|
|
//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 resultSet = RETURN_OK;
|
|
|
|
@ -75,6 +72,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(std:
|
|
|
|
|
|
|
|
|
|
resultSet=setValue(key, data);
|
|
|
|
|
if(resultSet!=RETURN_OK){
|
|
|
|
|
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 0, 0);
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << result << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -105,6 +103,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::getConfigFileValue(std:
|
|
|
|
|
|
|
|
|
|
resultGet=getValue(key, data);
|
|
|
|
|
if (resultGet!= RETURN_OK){
|
|
|
|
|
triggerEvent(GET_CONFIGFILEVALUE_FAILED, 0, 0);
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::info << "GlobalConfigHandler::getConfigFileValue lock mutex failed with " << result << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -133,6 +132,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::insertConfigFileValue(s
|
|
|
|
|
|
|
|
|
|
resultInsert=insertValue(key, data);//Should never fail
|
|
|
|
|
if(resultInsert!=RETURN_OK){
|
|
|
|
|
triggerEvent(INSERT_CONFIGFILEVALUE_FAILED, 0, 0);
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::info << "GlobalConfigHandler::insertConfigFileValue insert failed with " << result << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -181,6 +181,7 @@ ReturnValue_t GlobalConfigHandler::WriteConfigFile(){
|
|
|
|
|
|
|
|
|
|
resultWrite =writeJsonFile();
|
|
|
|
|
if(resultWrite!=RETURN_OK){
|
|
|
|
|
triggerEvent(WRITE_CONFIGFILE_FAILED, 0, 0);
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::info << "GlobalConfigHandler::WriteConfigFile write json failed with " << result << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -209,6 +210,7 @@ ReturnValue_t GlobalConfigHandler::ReadConfigFile(){
|
|
|
|
|
|
|
|
|
|
resultRead=readJsonFile();
|
|
|
|
|
if(resultRead!=RETURN_OK){
|
|
|
|
|
triggerEvent(READ_CONFIGFILE_FAILED, 0, 0);
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::info << "GlobalConfigHandler::ReadConfigFile read json failed with " << result << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -230,3 +232,15 @@ ReturnValue_t GlobalConfigHandler::ResetConfigFile(){
|
|
|
|
|
result =writeJsonFile();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReturnValue_t GlobalConfigHandler::setConfigFileName(std::string configFileName){
|
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
|
setFullName(configFileName);
|
|
|
|
|
result=ResetConfigFile();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
std::string GlobalConfigHandler::getConfigFileName(){
|
|
|
|
|
|
|
|
|
|
return getFullName();
|
|
|
|
|
}
|
|
|
|
|