22 #include <Teuchos_ParameterList.hpp>
23 #include <Teuchos_XMLObject.hpp>
24 #include <Teuchos_XMLParameterListWriter.hpp>
25 #include <Teuchos_ParameterXMLFileReader.hpp>
26 #include <Teuchos_ValidatorXMLConverterDB.hpp>
28 #include <Teuchos_StandardParameterEntryValidators.hpp>
47 Teuchos::ParameterList pl(
"pl");
50 string parameterName(
"speed_versus_quality");
51 RCP<const Teuchos::StringValidator> strValidatorP =
52 rcp(
new Teuchos::StringValidator(
53 tuple<string>(
"speed",
"balance",
"quality")));
54 std::ostringstream docString;
55 strValidatorP->printDoc(
56 "When algorithm choices exist, opt for speed or solution quality?\n"
57 "(Default is a balance of speed and quality)\n",
59 pl.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
63 string parameterName(
"debug_output_file");
64 RCP<const Teuchos::FileNameValidator > fnameValidatorP =
65 fnameValidatorP = rcp(
new Teuchos::FileNameValidator(
false));
66 std::ostringstream docString;
67 fnameValidatorP->printDoc(
68 "name of file to which debug/status messages should be written\n"
69 "(process rank will be included in file name)\n",
71 pl.set<
string>(parameterName,
"/dev/null", docString.str(),
76 string parameterName(
"random_seed");
77 RCP<const Teuchos::AnyNumberParameterEntryValidator> anyNumValidatorP =
78 rcp(
new Teuchos::AnyNumberParameterEntryValidator);
79 std::ostringstream docString;
80 anyNumValidatorP->printDoc(
"random seed\n", docString);
81 pl.set<
string>(parameterName,
"0.5", docString.str(), anyNumValidatorP);
85 string parameterName(
"debug_level");
86 RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> >
88 rcp(
new Teuchos::StringToIntegralParameterEntryValidator<int>(
89 tuple<string>(
"no_status",
92 "verbose_detailed_status"),
95 "library outputs no status information",
96 "library outputs basic status information (default)",
97 "library outputs detailed information",
98 "library outputs very detailed information"),
100 tuple<int>(0, 1, 2, 3),
104 string info(
"the amount of status/warning/debugging info printed\n");
105 info.append(
"(If the compile flag Z2_OMIT_ALL_STATUS_MESSAGES was set,\n");
106 info.append(
"then message output code is not executed at runtime.)\n");
108 std::ostringstream docString;
109 str2intValidatorP->printDoc(info, docString);
110 pl.set<
string>(parameterName,
"basic_status", docString.str(),
115 string parameterName(
"debug_procs");
117 RCP<const irl_t> intRangeValidatorP = rcp(
new irl_t);
118 std::ostringstream docString;
119 intRangeValidatorP->printDoc(
120 "list of ranks that output debugging/status messages (default \"0\")\n",
122 pl.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorP);
127 RCP<irlConverter_t > converter = rcp(
new irlConverter_t);
128 Teuchos::ValidatorXMLConverterDB::addConverter(
134 Teuchos::XMLParameterListWriter plw;
135 Teuchos::XMLObject obj = plw.toXML(pl);
137 std::cout <<
"Parameter list: " << std::endl;
138 std::cout << obj << std::endl;
141 of.open(
"params.xml");
142 of << obj << std::endl;
147 Teuchos::ParameterXMLFileReader rdr(
"params.xml");
148 Teuchos::ParameterList newpl = rdr.getParameters();
149 Teuchos::XMLObject objnew = plw.toXML(newpl);
151 std::cout <<
"After reading in from XML file: " << std::endl;
152 std::cout << objnew << std::endl;
Defines Parameter related enumerators, declares functions.
XML conversion code for IntegerRangeListValidator.
int main(int narg, char **arg)
A ParameterList validator for integer range lists.
Define IntegerRangeList validator.