CondConfig.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_test_types_CondConfig_h
2 #define fhiclcpp_test_types_CondConfig_h
3 
4 #include "fhiclcpp/types/Atom.h"
7 #include "fhiclcpp/types/Table.h"
9 
10 #include <array>
11 #include <ostream>
12 #include <string>
13 
14 namespace fhicl {
15 
16  class Vec {
17  std::array<int, 3> hls_;
18 
19  public:
20  Vec(int i, int j, int k) : hls_{{i, j, k}} {}
21  auto const&
22  operator()() const
23  {
24  return hls_;
25  }
26  };
27 
28  std::ostream&
29  operator<<(std::ostream& os, Vec const& v)
30  {
31  return os << "Half-lengths are: (" << v()[0] << ", " << v()[1] << ", "
32  << v()[2] << ")";
33  }
34 
35  struct CondConfig {
36 
37  Atom<bool> flag{Name("flag")};
38 
39  bool
40  flag_is_true() const
41  {
42  return flag();
43  }
44 
45  OptionalAtom<int> num1{Name("num1"),
46  Comment("Used if \"flag: true\"."),
48 
49  Atom<int> num2{Name("num2"),
50  Comment("Used if \"flag: false\"."),
52 
53  Atom<std::string> shape{Name("shape"), "box"};
54 
55  struct BoxParameters {
56  TupleAs<Vec(int, int, int)> halfLengths{Name("halfLengths"),
57  Vec{1, 2, 3}};
58  OptionalAtom<std::string> boxName{Name("boxName")};
60  };
62  Name("parameters"),
63  Comment("Used if \"shape: box\"."),
64  MaybeUseFunction([this]() { return shape() == "box"; })};
65 
67  Atom<int> radius{Name("radius")};
68  };
70  Name("parameters"),
71  Comment("Used if \"shape: sphere\"."),
72  MaybeUseFunction([this]() { return shape() == "sphere"; })};
73  };
74 }
75 
76 #endif /* fhiclcpp_test_types_CondConfig_h */
77 
78 // Local variables:
79 // mode: c++
80 // End:
std::function< bool()> use_unless(T *p, NullaryConfigPredicate_t< T > f)
std::function< bool()> use_if(T *p, NullaryConfigPredicate_t< T > f)
ChannelGroupService::Name Name
bool flag_is_true() const
Definition: CondConfig.h:40
std::array< int, 3 > hls_
Definition: CondConfig.h:17
#define Comment
Vec(int i, int j, int k)
Definition: CondConfig.h:20
std::ostream & operator<<(std::ostream &, ParameterSetID const &)
auto const & operator()() const
Definition: CondConfig.h:22