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


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

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


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

示例1: applyBC

void BCManager::applyBC(ParameterList const& p)
{
  // validate parameters
  RCP<ParameterList> vp = getValidBCParameters();
  p.validateParameters(*vp,0);

  // get the input parameters
  std::string val = p.get<std::string>("Value");
  std::string set = p.get<std::string>("Node Set");
  std::string dof = p.get<std::string>("DOF");

  // does this node set actually exist?
  assert(ns.count(set) == 1);

  // does this dof actually exist?
  int offset = problem->getOffset(dof);

  if (!isAdjoint)
    modifyPrimalSystem(val, offset, set);
  else
    modifyAdjointSystem(offset, set);
}
开发者ID:ImmutableLtd,项目名称:Albany,代码行数:22,代码来源:GOAL_BCUtils.cpp

示例2: validate_params

static void validate_params(ParameterList const& p, SolInfo* s) {
  auto disc = s->get_disc();
  auto ss_name = p.get<std::string>("side set");
  disc->get_sides(ss_name);
  p.validateParameters(get_valid_params(), 0);
}
开发者ID:bgranzow,项目名称:goal,代码行数:6,代码来源:goal_ibcs.cpp

示例3: 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


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