当前位置: 首页>>代码示例>>C++>>正文


C++ OptionalAttribute类代码示例

本文整理汇总了C++中OptionalAttribute的典型用法代码示例。如果您正苦于以下问题:C++ OptionalAttribute类的具体用法?C++ OptionalAttribute怎么用?C++ OptionalAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OptionalAttribute类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getOption

 int SamplingAlgorithmOptions_Impl::samples() const {
   int result;
   OptionalAttribute option = getOption("samples");
   BOOST_ASSERT(option);
   result = option->valueAsInteger();
   return result;
 }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:7,代码来源:SamplingAlgorithmOptions.cpp

示例2: getValue

 double OutputAttributeVariable_Impl::getValue(const DataPoint& dataPoint) const {
   OptionalAttribute oa = dataPoint.getOutputAttribute(m_attributeName);
   if (!oa) {
     LOG_AND_THROW("Unable to retrieve attribute '" << m_attributeName << "' for DataPoint at "
                   << toString(dataPoint.directory()) << ".");
   }
   Attribute attribute = oa.get();
   OptionalDouble result;
   AttributeValueType valueType = attribute.valueType();
   if (valueType == AttributeValueType::Double) {
     result = attribute.valueAsDouble();
   }
   if (valueType == AttributeValueType::Quantity) {
     result = attribute.valueAsQuantity().value();
   }
   if (valueType == AttributeValueType::Integer) {
     result = double(attribute.valueAsInteger());
   }
   if (valueType == AttributeValueType::Unsigned) {
     result = double(attribute.valueAsUnsigned());
   }
   if (!result) {
     LOG_AND_THROW("Unable to extract double value from attribute '" << m_attributeName
                   << "' of type " << valueType.valueDescription() << ".");
   }
   return *result;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:27,代码来源:OutputAttributeVariable.cpp

示例3: LOG

  bool SamplingAlgorithmOptions_Impl::setSamples(int value) {
	  if (value < 1) {
      LOG(Warn,"Cannot set SamplingAlgorithmOptions samples to a value less than one.");
      return false;
	  }
    OptionalAttribute option = getOption("samples");
    BOOST_ASSERT(option);
    option->setValue(value);
    return true;
  }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:10,代码来源:SamplingAlgorithmOptions.cpp

示例4: setSeed

 void DDACEAlgorithmOptions_Impl::setSeed(int value){
   OptionalAttribute option;
   if ((option = getOption("seed"))) {
     option->setValue(value);
   }
   else {
     option = Attribute("seed",value);
     saveOption(*option);
   }
 }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:10,代码来源:DDACEAlgorithmOptions.cpp

示例5: setSymbols

 bool DDACEAlgorithmOptions_Impl::setSymbols(int value) {
   OptionalAttribute option;
   if ((option = getOption("symbols"))) {
     option->setValue(value);
   }
   else {
     option = Attribute("symbols",value);
     saveOption(*option);
   }
   return true;
 }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:11,代码来源:DDACEAlgorithmOptions.cpp

示例6: QString

void OSIntegerEdit::refreshTextAndLabel() {
  if (m_modelObject) {
    QString textValue;
    ModelObject modelObject = m_modelObject.get();
    std::stringstream ss;

    if (m_isAutosizedProperty) {
      Attribute autosized = modelObject.getAttribute(*m_isAutosizedProperty).get();
      if (autosized.valueAsBoolean()) {
        textValue = QString("autosize");
      }
    }

    if (m_isAutocalculatedProperty) {
      Attribute autocalculated = modelObject.getAttribute(*m_isAutocalculatedProperty).get();
      if (autocalculated.valueAsBoolean()) {
        textValue = QString("autocalculate");
      }
    }

    OptionalAttribute attribute = modelObject.getAttribute(m_property);
    if (attribute) {
      int value = attribute->valueAsInteger();
      if (m_isScientific) {
        ss << std::scientific;
      }
      else {
        ss << std::fixed;
      }
      if (m_precision) {
        ss << std::setprecision(*m_precision);
      }
      ss << value;
      textValue = toQString(ss.str());
      ss.str("");
    }

    this->setText(textValue);

    if (m_isDefaultedProperty) {
      Attribute defaulted = modelObject.getAttribute(*m_isDefaultedProperty).get();
      if (defaulted.valueAsBoolean()) {
        this->setStyleSheet("color:green");
      }
      else {
        this->setStyleSheet("color:black");
      }
    }
  }
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:50,代码来源:OSIntegerEdit.cpp

示例7: LOG

 bool ParameterStudyAlgorithmOptions_Impl::setNumSteps(int value) {
   if (value < 1) {
     LOG(Warn,"Cannot set ParameterStudyAlgorithmOptions numSteps to a value less than one.");
     return false;
   }
   OptionalAttribute option;
   if ((option = getOption("numSteps"))) {
     option->setValue(value);
   }
   else {
     option = Attribute("numSteps",value);
     saveOption(*option);
   }
   return true;
 }
开发者ID:Zicao,项目名称:OpenStudio,代码行数:15,代码来源:ParameterStudyAlgorithmOptions.cpp

示例8: LOG

 bool PSUADEDaceAlgorithmOptions_Impl::setSamples(int value) {
   if (value < 1) {
     LOG(Warn,"Cannot set PSUADEDaceAlgorithmOptions samples to a value less than one.");
     return false;
   }
   OptionalAttribute option;
   if ((option = getOption("samples"))) {
     option->setValue(value);
   }
   else {
     option = Attribute("samples",value);
     saveOption(*option);
   }
   return true;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:15,代码来源:PSUADEDaceAlgorithmOptions.cpp

示例9: TEST_F

TEST_F(DataFixture, Attribute_Source) {
  AttributeVector attributes;

  // create vector of attributes with no sources
  attributes.push_back(Attribute("My Boolean Attribute",false));
  attributes.push_back(Attribute("My Double Attribute",34.2,"W"));
  attributes.push_back(Attribute("My Integer Attribute",5));
  attributes.push_back(Attribute("My String Attribute","flat finish"));
  attributes.push_back(Attribute("tricky_source","don't talk back"));

  // xml and back
  Attribute container("Containing Attribute",attributes);
  QDomDocument doc = container.toXml();
  OptionalAttribute containerCopy = Attribute::loadFromXml(doc);
  ASSERT_TRUE(containerCopy);
  AttributeVector attributesCopy = containerCopy.get().valueAsAttributeVector();
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_TRUE(attributeCopy.source().empty());
  }

  // json and back
  QVariant variant = detail::toVariant(attributes);
  int n = variant.toMap().size();
  attributesCopy = detail::toVectorOfAttribute(variant,VersionString(openStudioVersion()));
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_TRUE(attributeCopy.source().empty());
  }

  // apply same source to all attributes
  for (Attribute& attribute : attributes) {
    attribute.setSource("big data set");
  }

  // xml and back
  doc = container.toXml();
  containerCopy = Attribute::loadFromXml(doc);
  ASSERT_TRUE(containerCopy);
  attributesCopy = containerCopy.get().valueAsAttributeVector();
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_EQ("big data set",attributeCopy.source());
  }

  // json and back
  variant = detail::toVariant(attributes);
  EXPECT_EQ(n+1,variant.toMap().size());
  attributesCopy = detail::toVectorOfAttribute(variant,VersionString(openStudioVersion()));
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_EQ("big data set",attributeCopy.source());
  }

  // change one attribute's source to something different
  attributes[2].setSource("a wiki");

  // xml and back
  doc = container.toXml();
  containerCopy = Attribute::loadFromXml(doc);
  ASSERT_TRUE(containerCopy);
  attributesCopy = containerCopy.get().valueAsAttributeVector();
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_FALSE(attributeCopy.source().empty());
  }
  EXPECT_EQ("a wiki",attributesCopy[2].source());

  // json and back
  variant = detail::toVariant(attributes);
  EXPECT_EQ(n+attributes.size(),variant.toMap().size());
  attributesCopy = detail::toVectorOfAttribute(variant,VersionString(openStudioVersion()));
  EXPECT_EQ(attributes.size(),attributesCopy.size());
  for (const Attribute& attributeCopy : attributesCopy) {
    EXPECT_FALSE(attributeCopy.source().empty());
  }
  // order is not guaranteed

}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:79,代码来源:Attribute_GTest.cpp

示例10: getOption

 int SequentialSearchOptions_Impl::objectiveToMinimizeFirst() const {
   OptionalAttribute option = getOption("objectiveToMinimizeFirst");
   BOOST_ASSERT(option);
   return option->valueAsInteger();
 }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:5,代码来源:SequentialSearchOptions.cpp


注:本文中的OptionalAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。