validate_ParameterSet_t.cc
Go to the documentation of this file.
2 
3 #include "fhiclcpp/types/Atom.h"
5 #include "fhiclcpp/types/Table.h"
6 #include "fhiclcpp/types/Tuple.h"
7 
8 #include <iostream>
9 
10 namespace {
11 
12  using namespace fhicl;
13 
14  //============================================================================
15  // Job configuration
16  //
17 
18  struct PSet2 {
19  Atom<std::string> test{Name("test"), Comment("this works"), "try again"};
20  Sequence<int> sequence{Name("sequence")};
21  };
22 
23  struct Test {
24  Atom<int> value{Name("c")};
25  };
26 
27  struct ForRootInput {
28  Atom<std::string> primary{Name("a")};
29  Sequence<std::string> secondaries{Name("b")};
30  Sequence<Table<Test>> tablesequence2{Name("tableSequence2")};
31  };
32 
33  struct Configuration {
34  Atom<bool> flag{Name("flag"), true};
35 
36  Tuple<double, std::string> pair{Name("pair")};
38 
39  Sequence<Tuple<int, double>> vt{Name("vecOfTuples")};
40  Sequence<Tuple<int, double>, 2> at{Name("arrayOfTuples")};
41 
42  Sequence<Sequence<int>> vv{Name("vecOfVecs")};
43  Sequence<Sequence<int, 2>> va{Name("vecOfArrays")};
44  Sequence<Sequence<int>, 2> av{Name("arrayOfVecs")};
45  Sequence<Sequence<int, 2>, 2> aa{Name("arrayOfArrays")};
46 
47  Tuple<Sequence<double>, bool, int> tv{Name("tupleWithVec")};
48  Tuple<Sequence<double, 2>, bool, int> ta{Name("tupleWithArray")};
49  Tuple<Tuple<int, double>, bool, int> tt{Name("tupleWithTuple")};
50 
51  Sequence<Table<ForRootInput>> vtable{Name("vecOfTables")};
52  Tuple<Table<ForRootInput>, bool, int> tupleWithTable{
53  Name("tupleWithTable")};
54  Tuple<Sequence<Table<ForRootInput>>, double> tvtable{
55  Name("tupleWithVecTable")};
56  Tuple<Sequence<Table<ForRootInput>, 2>, double> tstable{
57  Name("tupleWithArrTable")};
58  Sequence<Tuple<Table<ForRootInput>, double>> vttable{
59  Name("vecWithTupleTable")};
60  Sequence<Tuple<Table<ForRootInput>, double>, 2> attable{
61  Name("arrWithTupleTable")};
62  Table<PSet2> pset2{Name("pset2")};
63  };
64 }
65 
66 int
68 {
69  putenv(const_cast<char*>("FHICL_FILE_PATH=./test:."));
70  cet::filepath_lookup policy("FHICL_FILE_PATH");
71  std::string cfg_in("validate_ParameterSet_t.fcl");
72  auto const pset = fhicl::ParameterSet::make(cfg_in, policy);
73 
74  try {
75  Table<Configuration> table{Name("pset")};
76  table.validate(pset.get<fhicl::ParameterSet>("pset"));
77  }
78  catch (std::exception const& e) {
79  std::cout << e.what() << std::endl;
80  }
81 }
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
ChannelGroupService::Name Name
Definition: type_traits.h:61
const double e
int main()
#define Comment
Test()
Definition: templ.cpp:25
int bool
Definition: qglobal.h:345
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)