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


C++ ParameterList::getEntryRCP方法代码示例

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


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

示例1: convertParameterList

XMLObject XMLParameterListWriter::convertParameterList(
  const ParameterList& p,
  ParameterEntry::ParameterEntryID& idCounter,
  EntryIDsMap& entryIDsMap,
  const ValidatortoIDMap& validatorIDsMap) const
{
  XMLObject rtn(getParameterListTagName());

  for (ParameterList::ConstIterator i=p.begin(); i!=p.end(); ++i){
    RCP<const ParameterEntry> entry = p.getEntryRCP(i->first);
    if(entry->isList()){
      XMLObject newPL = convertParameterList(
        getValue<ParameterList>(entry),
        idCounter,
        entryIDsMap,
        validatorIDsMap);
      newPL.addAttribute(
        getNameAttributeName(), p.name(i));
      newPL.addAttribute(
        ParameterEntryXMLConverter::getIdAttributeName(), idCounter);
      entryIDsMap.insert(EntryIDsMap::value_type(entry, idCounter));
      rtn.addChild(newPL);
      ++idCounter;
    }
    else{
      rtn.addChild(ParameterEntryXMLConverterDB::convertEntry(
        entry, p.name(i), idCounter, validatorIDsMap));
      entryIDsMap.insert(EntryIDsMap::value_type(entry, idCounter));
      ++idCounter;
    }
  }
  return rtn;
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:33,代码来源:Teuchos_XMLParameterListWriter.cpp

示例2: variableLengthArray

/**
 * Test the ArrayLengthDependency.
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testArrayLengthDep){
	RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
	RCP<DependencySheet> depSheet1 =
    RCP<DependencySheet>(new DependencySheet);

	ParameterList
	numberArrayLengthDepList = My_deplist->sublist(
    "Number Array Length Dependency List", false,
    "Number Array Length Dependecy testing list.");
	numberArrayLengthDepList.set("Array Length", 10, "array length setter");
	Array<double> variableLengthArray(11,23.0);
	RCP<EnhancedNumberValidator<double> >
	varLengthArrayVali = RCP<EnhancedNumberValidator<double> >(
  		new EnhancedNumberValidator<double>(10,50,4)
	);
	numberArrayLengthDepList.set(
    "Variable Length Array", variableLengthArray, "variable length array",
	  RCP<ArrayNumberValidator<double> >(
      new ArrayNumberValidator<double>(varLengthArrayVali)));

	RCP<NumberArrayLengthDependency<int, double> >
	  arrayLengthDep(
  		new NumberArrayLengthDependency<int, double>(
			numberArrayLengthDepList.getEntryRCP("Array Length"),
			numberArrayLengthDepList.getEntryRCP("Variable Length Array"),
      rcp(new AdditionFunction<int>(1))
		)
	);
	depSheet1->addDependency(arrayLengthDep);
  Array<double> curArray =
    numberArrayLengthDepList.get<Array<double> >("Variable Length Array");
	TEST_ASSERT(curArray.length() ==11);
	numberArrayLengthDepList.set("Array Length", 12);
	arrayLengthDep()->evaluate();
  curArray =
    numberArrayLengthDepList.get<Array<double> >("Variable Length Array");
  out << curArray.length() << std::endl;
	TEST_ASSERT(curArray.length() ==13);
	numberArrayLengthDepList.set("Array Length", -2);
	TEST_THROW(arrayLengthDep()->evaluate(),
    Exceptions::InvalidParameterValue);
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:45,代码来源:Dependencies_UnitTests.cpp

示例3: variableColsArray

/**
 * Test the TwoDColDependency.
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testTwoDColDependency){
	RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
	RCP<DependencySheet> depSheet1 =
    RCP<DependencySheet>(new DependencySheet);

	ParameterList
	colNumDepList = My_deplist->sublist(
    "2D Col Depdency List", false,
    "2D Col Dependecy testing list.");
	colNumDepList.set("Num cols", 2, "num cols setter");
  TwoDArray<double> variableColsArray(11,3,16.5);
	RCP<EnhancedNumberValidator<double> >
	varColArrayVali = RCP<EnhancedNumberValidator<double> >(
  		new EnhancedNumberValidator<double>(10,50,4)
	);
	colNumDepList.set(
    "Variable Col Array", variableColsArray, "variable col array",
	  RCP<TwoDArrayNumberValidator<double> >(
      new TwoDArrayNumberValidator<double>(varColArrayVali)));

	RCP<TwoDColDependency<int, double> >
	  arrayColDep = rcp(
  		new TwoDColDependency<int, double>(
		  colNumDepList.getEntryRCP("Num cols"),
			colNumDepList.getEntryRCP("Variable Col Array") ,
      rcp(new AdditionFunction<int>(1))
		)
	);
	depSheet1->addDependency(arrayColDep);
  TwoDArray<double> curArray =
    colNumDepList.get<TwoDArray<double> >("Variable Col Array");
	TEST_EQUALITY_CONST(curArray.getNumCols(),3);
	colNumDepList.set("Num cols", 4);
	arrayColDep()->evaluate();
  curArray =
    colNumDepList.get<TwoDArray<double> >("Variable Col Array");
	TEST_EQUALITY_CONST(curArray.getNumCols(),5);
	colNumDepList.set("Num cols", -2);
	TEST_THROW(arrayColDep()->evaluate(),
    Exceptions::InvalidParameterValue);
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:44,代码来源:Dependencies_UnitTests.cpp

示例4: StringValidatorDependency

/**
 * Test all the validator dependencies.
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testValiDeps){
	RCP<ParameterList> My_deplist = rcp(new ParameterList);
	RCP<DependencySheet> depSheet1 = rcp(new DependencySheet);

	/*
	 * Testing StringValidatorDependency
	 */
 	RCP<StringToIntegralParameterEntryValidator<int> >
   	stringFoodTypeValidator = rcp(
		new StringToIntegralParameterEntryValidator<int>(
		tuple<std::string>( "Cheese", "Soda", "Chips" )
		,"Food Type"
		)
	);

	RCP<StringToIntegralParameterEntryValidator<int> >
    cheeseValidator = rcp(
		new StringToIntegralParameterEntryValidator<int>(
   			tuple<std::string>( "Swiss", "American", "Super Awesome Cheese" )
			,"Food Selector"
			)
	);

	RCP<StringToIntegralParameterEntryValidator<int> >
	sodaValidator = rcp(
		new StringToIntegralParameterEntryValidator<int>(
			tuple<std::string>( "Pepsi", "Coke", "Kurtis Cola", "Bad Cola" )
			,"Food Selector"
			)
		);

	RCP<StringToIntegralParameterEntryValidator<int> >
	chipsValidator = rcp(
		new StringToIntegralParameterEntryValidator<int>(
			tuple<std::string>( "Lays", "Doritos", "Kurtis Super Awesome Brand" )
			,"Food Selector"
		)
	);

	StringValidatorDependency::ValueToValidatorMap testValidatorMap1;
	testValidatorMap1["Cheese"] = cheeseValidator;
	testValidatorMap1["Soda"] = sodaValidator;
	testValidatorMap1["Chips"] = chipsValidator;

	ParameterList stringValiDepList = My_deplist->sublist(
    "String Validator Dependency", false,
    "String Validator Dependency testing list.");
	stringValiDepList.set(
    "Food Selector", "Swiss", "select the food you want", cheeseValidator);
	stringValiDepList.set(
    "Food Type",
    "Cheese",
    "String Validator Dependency Tester",
    stringFoodTypeValidator);

	RCP<StringValidatorDependency>
	stringValiDep = rcp(
		new StringValidatorDependency(
			stringValiDepList.getEntryRCP("Food Type"),
			stringValiDepList.getEntryRCP("Food Selector"),
			testValidatorMap1,
			cheeseValidator
		)
	);

	depSheet1->addDependency(stringValiDep);
	
	TEST_NOTHROW(stringValiDepList.validateParameters(stringValiDepList));
	TEST_ASSERT(depSheet1->hasDependents(
    stringValiDepList.getEntryRCP("Food Type")));
	RCP<const DependencySheet::DepSet> stringValiDepSet =
    depSheet1->getDependenciesForParameter(
      stringValiDepList.getEntryRCP("Food Type"));
	TEST_ASSERT(stringValiDepSet->size() == 1);
	stringValiDepList.set("Food Type","Soda");
	stringValiDep->evaluate();
	TEST_ASSERT(stringValiDepList.getEntry("Food Selector").validator()
    ==
    sodaValidator);
	TEST_THROW(stringValiDepList.validateParameters(stringValiDepList),
    Exceptions::InvalidParameterValue);
	stringValiDepList.set("Food Selector", "Pepsi");
	TEST_NOTHROW(stringValiDepList.validateParameters(stringValiDepList));


	/*
	 * Tesing some different aspects of the StringValidatorDependency
	 */
	ParameterList
	stringValiDepList2 = My_deplist->sublist(
		"String Validator Dependency (other validators)",
		false,
		"String validator testing"
	);

	RCP<StringToIntegralParameterEntryValidator<int> >
	stringRangeValidator = rcp(
//.........这里部分代码省略.........
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:101,代码来源:Dependencies_UnitTests.cpp

示例5: BoolVisualDependency

/**
 * Testing all the visual dependencies
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testVisualDeps){
	RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
	RCP<DependencySheet> depSheet1 =
    RCP<DependencySheet>(new DependencySheet);
  /*
   * Two Simple NumberVisualDependency test
   */

	ParameterList
	simpleNumDepTestList = My_deplist->sublist(
		"NumberVisual Dependency List (double)",
		false,
		"Number visual Dependency testing list"
	);
		
	simpleNumDepTestList.set("Temperature",101.0);
	simpleNumDepTestList.set("Cheese to Fondue", "Swiss", "The cheese to fondue");
	simpleNumDepTestList.set("reverse param", "hello");

	RCP<NumberVisualDependency<double> > simpleNumDep =
	RCP<NumberVisualDependency<double> >(
		new NumberVisualDependency<double>(
			simpleNumDepTestList.getEntryRCP("Temperature"),
			simpleNumDepTestList.getEntryRCP("Cheese to Fondue"),
      true
		)
	);
	RCP<NumberVisualDependency<double> > reverseNumDep =
	RCP<NumberVisualDependency<double> >(
		new NumberVisualDependency<double>(
			simpleNumDepTestList.getEntryRCP("Temperature"),
			simpleNumDepTestList.getEntryRCP("reverse param"),
      false
		)
	);
  depSheet1->addDependency(simpleNumDep);
  depSheet1->addDependency(reverseNumDep);
	simpleNumDep->evaluate();
	reverseNumDep->evaluate();
	TEST_ASSERT(simpleNumDep->isDependentVisible());
	TEST_ASSERT(!reverseNumDep->isDependentVisible());
	simpleNumDepTestList.set("Temperature",-1.0);
	simpleNumDep->evaluate();
	reverseNumDep->evaluate();
	TEST_ASSERT(!simpleNumDep->isDependentVisible());
	TEST_ASSERT(reverseNumDep->isDependentVisible());


	/*
	 * complex Testing the NumberVisualDependency
	 */
	ParameterList
	doubleVisualDepList = My_deplist->sublist(
		"NumberVisual Dependency List (double)",
		false,
		"Number visual Dependency testing list"
	);
		
	doubleVisualDepList.set(
    "Temperature",101.0, "The temperature of the fondue");
	doubleVisualDepList.set(
    "Cheese to Fondue", "Swiss", "The cheese to fondue");
  doubleVisualDepList.set("reverse param", "hello");
  RCP<SubtractionFunction<double> > fondueFunc = rcp(new
    SubtractionFunction<double>(100));

	RCP<NumberVisualDependency<double> > fondueDep =
	RCP<NumberVisualDependency<double> >(
		new NumberVisualDependency<double>(
			doubleVisualDepList.getEntryRCP("Temperature"),
			doubleVisualDepList.getEntryRCP("Cheese to Fondue"),
      true,
			fondueFunc
		)
	);
	RCP<NumberVisualDependency<double> > reverseFondueDep =
	RCP<NumberVisualDependency<double> >(
		new NumberVisualDependency<double>(
			doubleVisualDepList.getEntryRCP("Temperature"),
			doubleVisualDepList.getEntryRCP("reverse param"),
      false,
			fondueFunc
		)
	);
	depSheet1->addDependency(fondueDep);
	depSheet1->addDependency(reverseFondueDep);
	fondueDep->evaluate();
  reverseFondueDep->evaluate();
	TEST_ASSERT(fondueDep->isDependentVisible());
	TEST_ASSERT(!reverseFondueDep->isDependentVisible());
	doubleVisualDepList.set("Temperature",99.0);
	fondueDep->evaluate();
  reverseFondueDep->evaluate();
	TEST_ASSERT(!fondueDep->isDependentVisible());
	TEST_ASSERT(reverseFondueDep->isDependentVisible());

	/*
//.........这里部分代码省略.........
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:101,代码来源:Dependencies_UnitTests.cpp


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