예제 #1
0
파일: CFGParam.cpp 프로젝트: annaborn/mars
 bool CFGParam::getProperty(CFGProperty *property) const {
   unsigned int state = property->getState();
   if( (state & CFGProperty::allSetButValue) == CFGProperty::allSetButValue ) {
     CFGProperty *tmpProperty = propertys.at(property->getPropertyIndex());
     if( tmpProperty->isSameAs(*property) && tmpProperty->isValueSet() ) {
       double dValue = 0.0;
       int iValue = 0;
       bool bValue = false;
       string sValue = "";
       switch( property->getPropertyType() ) {
       case doubleProperty:
         tmpProperty->getValue(&dValue);
         property->setValue(dValue);
         break;
       case intProperty:
         tmpProperty->getValue(&iValue);
         property->setValue(iValue);
         break;
       case boolProperty:
         tmpProperty->getValue(&bValue);
         property->setValue(bValue);
         break;
       case stringProperty:
         tmpProperty->getValue(&sValue);
         property->setValue(sValue);
         break;
       default:
         return false;
       } //switch
       return true;
     } //if
   } //if
   return false;
 }
예제 #2
0
파일: CFGParam.cpp 프로젝트: annaborn/mars
    void CFGParam::writeToYAML(YAML::Emitter &out) const {
      out << YAML::BeginMap;

      out << YAML::Key << "name";
      out << YAML::Value << paramName;

      out << YAML::Key << "type";
      out << YAML::Value << cfgParamTypeString[paramType];

      if (options & userSave) {
        out << YAML::Key << "userSave";
        out << YAML::Value << true;
      }

      if (options & saveOnClose) {
        out << YAML::Key << "saveOnClose";
        out << YAML::Value << true;
      }

      unsigned int i = 0;
      mutexPropertys.lock();
      for(i = 0; i < propertys.size(); ++i) {
        CFGProperty *prop = propertys.at(i);
        if(prop->isValueSet()) {
          out << YAML::Key << getPropertyNameByIndex(i);
          double dValue = 0.0;
          int iValue = 0;
          string sValue = "";
          bool bValue = false;
          switch (prop->getPropertyType()) {
          case intProperty:
            prop->getValue(&iValue);
            out << YAML::Value << iValue;
            break;
          case boolProperty:
            prop->getValue(&bValue);
            out << YAML::Value << bValue;
            break;
          case stringProperty:
            prop->getValue(&sValue);
            out << YAML::Value << sValue;
            break;
          case doubleProperty:
            prop->getValue(&dValue);
            out << YAML::Value << dValue;
            break;
          default:
            out << YAML::Value << "error";
            break;
          } //switch
        }
      }
      mutexPropertys.unlock();

      out << YAML::EndMap;
    }
예제 #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;
   }
 }