Example #1
0
    void CFGManager::insertParam(CFGParam *newParam) {
      mutexCFGParams.lock();
      cfgParamId id = newParam->getId();
      mapStringToParam::const_iterator iter;
      string stringID = newParam->getGroup() + ":" + newParam->getName();
      iter = cfgParamsByString.find(stringID);

      // is there already this param?
      if( iter != cfgParamsByString.end() ) {
        // then get the values of the properties and override the old ones
        CFGParam* oldParam = iter->second;
        unsigned int i = 0;
        for(i = 0; i < oldParam->getNrOfPropertys(); ++i) {
          CFGProperty myProperty;
          myProperty.setParamId(newParam->getId());
          myProperty.setPropertyIndex(i);
          myProperty.setPropertyType(newParam->getPropertyTypeByIndex(i));
          if( newParam->getProperty(&myProperty) ) {
            if( myProperty.isValueSet() ) {
              myProperty.changeParamId(oldParam->getId());
              oldParam->setProperty(myProperty);
            }
          } //if
        } //for
        // delete the new param which is no more needed
        deleteParam(newParam);
      } else {
        string stringId = newParam->getGroup() + ":" + newParam->getName();
        cfgParamsById.insert(pair<cfgParamId, CFGParam*>(id, newParam));
        cfgParamsByString.insert(pair<string, CFGParam*>(stringId, newParam));
      }
      mutexCFGParams.unlock();
    }
Example #2
0
 bool CFGManager::setProperty(const cfgPropertyStruct &_propertyS) {
   utils::MutexLocker locker(&mutexCFGParams);
   CFGParam *param = NULL;
   CFGProperty property;
   property.setParamId(_propertyS.paramId);
   property.setPropertyIndex(_propertyS.propertyIndex);
   property.setPropertyType(_propertyS.propertyType);
   switch (_propertyS.propertyType) {
   case boolProperty:
     property.setValue(_propertyS.bValue);
     break;
   case doubleProperty:
     property.setValue(_propertyS.dValue);
     break;
   case intProperty:
     property.setValue(_propertyS.iValue);
     break;
   case stringProperty:
     property.setValue(_propertyS.sValue);
     break;
   default:
     return false;
   } // switch
   if( getParam(&param, _propertyS.paramId) ) {
     return param->setProperty(property);
   } else {
     return false;
   }
 }
Example #3
0
 bool CFGManager::getPropertyValue(cfgParamId paramId,
                                   const string &_propertyName,
                                   string *rValue) const {
   utils::MutexLocker locker(&mutexCFGParams);
   CFGParam *param = NULL;
   if( getParam(&param, paramId) ) {
     CFGProperty property;
     property.setParamId( paramId );
     property.setPropertyIndex( param->getPropertyIndexByName(_propertyName) );
     property.setPropertyType(stringProperty);
     if( getProperty(&property) ) {
       property.getValue(rValue);
       return true;
     } else {
       return false;
     }
   } else {
     return false;
   }
 }
Example #4
0
 bool CFGManager::setPropertyValue(const string &_group,
                                   const string &_name,
                                   const string &_propertyName,
                                   const string &rValue) {
   utils::MutexLocker locker(&mutexCFGParams);
   CFGParam *param = NULL;
   if( getParam(&param, _group, _name) ) {
     CFGProperty property;
     property.setParamId( param->getId() );
     property.setPropertyIndex( param->getPropertyIndexByName(_propertyName) );
     property.setPropertyType(stringProperty);
     property.setValue(rValue);
     if( setProperty(property) ) {
       return true;
     } else {
       return false;
     }
   } else {
     return false;
   }
 }