本文整理汇总了C++中ParameterList::entry方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::entry方法的具体用法?C++ ParameterList::entry怎么用?C++ ParameterList::entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterList
的用法示例。
在下文中一共展示了ParameterList::entry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: haveSameValues
bool Teuchos::haveSameValues( const ParameterList& list1, const ParameterList& list2 )
{
// Check that the top-level names of the two parameter lists are the same
//const std::string ¶mListName1 = list1.name();
//const std::string ¶mListName2 = list2.name();
//if ( paramListName1 != paramListName2 ) {
// return false;
//}
ParameterList::ConstIterator itr1, itr2;
for(
itr1 = list1.begin(), itr2 = list2.begin();
itr1 != list1.end() && itr2 != list2.end();
++itr1, ++itr2
)
{
const std::string &entryName1 = list1.name(itr1);
const std::string &entryName2 = list2.name(itr2);
const ParameterEntry &entry1 = list1.entry(itr1);
const ParameterEntry &entry2 = list2.entry(itr2);
if( entryName1 != entryName2 ) {
return false;
}
if( entry1.isList() && entry2.isList() ) {
if (
!haveSameValues(
getValue<ParameterList>(entry1),
getValue<ParameterList>(entry2))
)
{
// Note: Above we cast to a non-const ParameterList even through we
// only need a const ParameterList. We have to do this since a
// non-const ParameterList is always added initially which determines
// the value.
return false;
}
}
else {
if( entry1.getAny() != entry2.getAny() ) {
return false;
}
}
}
// Check that the two parameter lists are the same length:
if ((itr1 != list1.end()) || (itr2 != list2.end())) {
return false;
}
return true;
}
示例2: run
void BCManager::run()
{
if (jacT != Teuchos::null) isAdjoint = true;
typedef ParameterList::ConstIterator ParamIter;
for (ParamIter i = bcParams.begin(); i != bcParams.end(); ++i)
{
std::string const& name = bcParams.name(i);
Teuchos::ParameterEntry const& entry = bcParams.entry(i);
assert(entry.isList());
applyBC(Teuchos::getValue<ParameterList>(entry));
}
}
示例3: if
bool Teuchos::operator==( const ParameterList& list1, const ParameterList& list2 )
{
// Check that the top-level names of the two parameter lists are the same
//const std::string ¶mListName1 = list1.name();
//const std::string ¶mListName2 = list2.name();
//if ( paramListName1 != paramListName2 ) {
// return false;
//}
ParameterList::ConstIterator itr1, itr2;
for(
itr1 = list1.begin(), itr2 = list2.begin();
itr1 != list1.end() && itr2 != list2.end();
++itr1, ++itr2
)
{
const std::string &entryName1 = list1.name(itr1);
const std::string &entryName2 = list2.name(itr2);
const ParameterEntry &entry1 = list1.entry(itr1);
const ParameterEntry &entry2 = list2.entry(itr2);
if( entryName1 != entryName2 ) {
return false;
}
else if( entry1 != entry2 ) {
return false;
}
// Note that the above statement automatically recursively compare the
// sublists since ParameterList objects are stored in the 'any' variable
// held by the ParameterEntry object and this same comparison operator will
// be used.
}
// Check that the two parameter lists are the same length:
if ((itr1 != list1.end()) || (itr2 != list2.end())) {
return false;
}
return true;
}
示例4: buildInitialValidatorMap
void XMLParameterListWriter::buildInitialValidatorMap(
const ParameterList& p,
ValidatortoIDMap& validatorIDsMap) const
{
for (ParameterList::ConstIterator i=p.begin(); i!=p.end(); ++i) {
const ParameterEntry& entry = p.entry(i);
if(entry.isList()){
buildInitialValidatorMap(
getValue<ParameterList>(entry),
validatorIDsMap);
}
else if(nonnull(entry.validator())){
validatorIDsMap.insert(entry.validator());
}
}
}
示例5: toString
//.........这里部分代码省略.........
// - we use repartitioning on some level
// This is not ideal, as we may have "repartition: enable" turned on by default
// and not present in the list, but it is better than nothing.
useCoordinates_ = false;
if ((paramList.isParameter("repartition: enable") && paramList.get<bool>("repartition: enable") == true) ||
(paramList.isParameter("aggregation: drop scheme") && paramList.get<std::string>("aggregation: drop scheme") == "laplacian")) {
useCoordinates_ = true;
} else {
for (int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
std::string levelStr = "level" + toString(levelID);
if (paramList.isSublist(levelStr)) {
const ParameterList& levelList = paramList.sublist(levelStr);
if ((levelList.isParameter("repartition: enable") && levelList.get<bool>("repartition: enable") == true) ||
(levelList.isParameter("aggregation: drop scheme") && levelList.get<std::string>("aggregation: drop scheme") == "laplacian")) {
useCoordinates_ = true;
break;
}
}
}
}
// Detect if we do implicit P and R rebalance
if (paramList.isParameter("repartition: enable") && paramList.get<bool>("repartition: enable") == true)
this->doPRrebalance_ = paramList.get<bool>("repartition: rebalance P and R", Hierarchy::GetDefaultPRrebalance());
this->implicitTranspose_ = paramList.get<bool>("transpose: use implicit", Hierarchy::GetDefaultImplicitTranspose());
// Create default manager
RCP<FactoryManager> defaultManager = rcp(new FactoryManager());
defaultManager->SetVerbLevel(this->verbosity_);
UpdateFactoryManager(paramList, ParameterList(), *defaultManager);
defaultManager->Print();
for (int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
RCP<FactoryManager> levelManager;
if (paramList.isSublist("level " + toString(levelID))) {
// Some level specific parameters, update default manager
bool mustAlreadyExist = true;
ParameterList& levelList = paramList.sublist("level " + toString(levelID), mustAlreadyExist);
levelManager = rcp(new FactoryManager(*defaultManager));
levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
UpdateFactoryManager(levelList, paramList, *levelManager);
} else {
// No level specific parameter, use default manager
levelManager = defaultManager;
}
this->AddFactoryManager(levelID, 1, levelManager);
}
if (paramList.isParameter("strict parameter checking") &&
paramList.get<bool> ("strict parameter checking")) {
ParameterList unusedParamList;
// Check for unused parameters that aren't lists
for (ParameterList::ConstIterator itr = paramList.begin(); itr != paramList.end(); ++itr) {
const ParameterEntry& entry = paramList.entry(itr);
if (!entry.isList() && !entry.isUsed())
unusedParamList.setEntry(paramList.name(itr), entry);
}
#if 0
// Check for unused parameters in level-specific sublists
for (int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
std::string levelStr = "level" + toString(levelID);
if (paramList.isSublist(levelStr)) {
const ParameterList& levelList = paramList.sublist(levelStr);
for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
const ParameterEntry& entry = levelList.entry(itr);
if (!entry.isList() && !entry.isUsed())
unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
}
}
}
#endif
if (unusedParamList.numParams() > 0) {
std::ostringstream unusedParamsStream;
int indent = 4;
unusedParamList.print(unusedParamsStream, indent);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, Teuchos::Exceptions::InvalidParameter,
"WARNING: Unused parameters were detected. Please check spelling and type." << std::endl << unusedParamsStream.str());
}
}
// FIXME: parameters passed to packages, like Ifpack2, are not touched by us, resulting in "[unused]" flag
// being displayed. On the other hand, we don't want to simply iterate through them touching. I don't know
// what a good solution looks like
this->GetOStream(static_cast<MsgType>(Runtime1 | Test), 0) << paramList << std::endl;
}
示例6: validateParametersAndSetDefaults
void ParameterList::validateParametersAndSetDefaults(
ParameterList const& validParamList,
int const depth
)
{
typedef std::deque<ListPlusValidList> sublist_list_t;
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
RCP<FancyOStream> out = VerboseObjectBase::getDefaultOStream();
OSTab tab(out);
*out << "\n*** Entering ParameterList::validateParametersAndSetDefaults(...) "
"for this->name()=\""<<this->name()<<"\"...\n";
#endif
//
// A) loop through and validate the parameters at this level.
//
// Here we generate a list of sublists that we will search next
//
sublist_list_t sublist_list;
{
Iterator itr;
for (itr = this->nonconstBegin(); itr != this->nonconstEnd(); ++itr) {
const std::string &entryName = this->name(itr);
ParameterEntry &theEntry = this->nonconstEntry(itr);
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
OSTab tab(out);
*out << "\nentryName=\""<<entryName<<"\"\n";
#endif
const ParameterEntry *validEntry = validParamList.getEntryPtr(entryName);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validEntry, Exceptions::InvalidParameterName
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nwas not found in the list of valid parameters!"
"\n\nThe valid parameters and types are:\n"
<<validParamList.currentParametersString()
);
RCP<const ParameterEntryValidator> validator;
if (nonnull(validator=validEntry->validator())) {
validator->validateAndModify(entryName, this->name(), &theEntry);
theEntry.setValidator(validator);
}
else {
const bool validType =
( validEntry!=NULL
? theEntry.getAny(false).type() == validEntry->getAny(false).type()
: false
);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validType, Exceptions::InvalidParameterType
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nexists in the list of valid parameters but has the wrong type."
"\n\nThe correct type is \""
<< validEntry->getAny(false).typeName() << "\"."
);
// Note: If there is no validator for this item, then we can not
// validate the value of the parameter, only its type!
}
if( theEntry.isList() && depth > 0 ) {
sublist_list.push_back(
ListPlusValidList(
&getValue<ParameterList>(theEntry),
&getValue<ParameterList>(*validEntry)
)
);
}
}
}
//
// B) Loop through the valid parameters at this level that are not set in
// *this, and set their defaults.
//
{
ConstIterator itr;
for (itr = validParamList.begin(); itr != validParamList.end(); ++itr) {
const std::string &validEntryName = validParamList.name(itr);
const ParameterEntry &validEntry = validParamList.entry(itr);
const ParameterEntry *theEntry = this->getEntryPtr(validEntryName);
if (!theEntry) {
// This entry does not exist, so add it. Here we will only set the
// value of the entry and its validator and and leave off the
// documentation. The reason that the validator is set is so that it
// can be used to extract and validate entries in the transformed list
// *this without having to refer back to the valid parameter list.
ParameterEntry newEntry;
newEntry.setAnyValue(
validEntry.getAny(),
true // isDefault
);
newEntry.setValidator(validEntry.validator());
this->setEntry(validEntryName,newEntry);
}
}
}
//
// C) Loop through the sublists and validate their parameters and set their
//.........这里部分代码省略.........