Project

General

Profile

Fhiclcpp types in detail » History » Version 1

Version 1/56 - Next » - Current version
Kyle Knoepfel, 08/17/2015 03:20 PM


fhiclcpp types in detail


Common features

Each of the fhiclcpp types has the following accessors:

std::string key()            const;
std::string comment()        const;
bool        has_default()    const;
par_type    parameter_type() const;

N.B. To call these functions, the difference in syntax is crucial:

Atom<int> val { Key("val") };

auto key1 = val.key();   //   correct
auto key2 = val().key(); // ! compile-time ERROR - 'val()' is an int, which has no accessor called 'key()' 

key()

A call to key() returns the full key, including all enclosing tables. For example, consider a module that is designed to allow the following configuration:

pset: {
  list: [ { particle: electron },
          { particle: muon } ]
}
For a suitably declared set of fhiclcpp parameters, the returned key corresponding to "muon" would be pset.list[1].particle.

N.B. The returned value is different than the relative name that is supplied in the Key("val") argument to the fhiclcpp parameter constructor.


Return types

fhiclcpp parameter Function call Return type
Simple fhiclcpp parameters
Atom<std::string> label; label() std::string const&
Sequence<int> counts; counts() std::vector<int>
counts(1) int
Sequence<double, 3u> point; point() std::array<double, 3u>
point(0) double
Tuple<std::string, double> assoc; assoc() std::tuple<std::string, double>
assoc.get<0>() std::string
assoc.get<double>() double
Table<Config> config; config() Config const&
Nested fhiclcpp parameters
Sequence< Sequence<int> > datasets; datasets() std::vector< std::vector<int> >
datasets(17) std::vector<int>
Sequence< Sequence<int>, 2u > twoDatasets; twoDatasets() std::array< std::vector<int>, 2u >
twoDatasets(1) std::vector<int>
Sequence< Sequence<int, 2u> > intPairs; intPairs() std::vector< std::array<int, 2u> >
intPairs(42) std::array<int, 2u>
Sequence< Tuple<std::string, int, bool> > triplets; triplets() std::vector< std::tuple<std::string, int, bool> >
triplets(3) std::tuple<std::string, int, bool>
Sequence< Table<Config> > manyConfigTables; manyConfigTables() std::vector< Config >
manyConfigTables(6) Config const&
Tuple< std::string, Table<Config> > configAssoc; configAssoc() std::tuple< std::string, Config >
configAssoc.get<0>() std::string
configAssoc.get<std::string>() std::string
configAssoc.get<1>() Config
configAssoc.get< Table<Config> >() Config
Tuple< Tuple<std::string,bool>, Sequence<int> > awkward; awkward() std::tuple< std::tuple<std::string, bool>, std::vector<int> >
awkward.get<0>() std::tuple<std::string,bool>
awkward.get<1>() std::vector<int>

Atom<T>

Atom<int> var { Key("var") };
Atom<int> var { Key("var"), Comment("A parameter description") };
Atom<int> var { Key("var"), Comment("A parameter description"), 9 }; // includes default

Sequence<T>

Sequence<T>::make_empty()


Sequence<T,std::size_t>


Tuple<T...>


Table<T>