Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SettingVisitors.hh
Go to the documentation of this file.
1 ///
2 /// @file SettingVisitors.hh
3 /// @brief Various operations on Setting class
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_SettingVisitors_HH
13 #define HAMMER_SettingVisitors_HH
14 
15 #include "Hammer/Tools/Setting.hh"
16 
17 namespace Hammer {
18 
19  struct SettingChecker : public boost::static_visitor<bool> {
20  bool operator()(boost::blank a, boost::blank b) const;
21  bool operator()(bool a, bool b) const;
22  bool operator()(int a, int b) const;
23  bool operator()(double a, double b) const;
24  bool operator()(std::complex<double> a, std::complex<double> b) const;
25  bool operator()(const std::string& a, const std::string& b) const;
26  bool operator()(const std::vector<double>& a, const std::vector<double>& b) const;
27  bool operator()(const std::vector<std::string>& a, const std::vector<std::string>& b) const;
28  bool operator()(const Setting::MatrixType& a, const Setting::MatrixType& b) const;
29  template <typename T, typename S>
30  typename std::enable_if<!std::is_same<T, S>::value, bool>::type operator()(T, S) const {
31  return false;
32  }
33  };
34 
35  class SettingWriter : public boost::static_visitor<Setting::WrittenSettingType> {
36  public:
37  SettingWriter(flatbuffers::FlatBufferBuilder* builder);
38 
39  Setting::WrittenSettingType operator()(boost::blank a) const;
43  Setting::WrittenSettingType operator()(std::complex<double> a) const;
44  Setting::WrittenSettingType operator()(const std::string& a) const;
45  Setting::WrittenSettingType operator()(const std::vector<double>& a) const;
46  Setting::WrittenSettingType operator()(const std::vector<std::string>& a) const;
48 
49  private:
50  flatbuffers::FlatBufferBuilder* _builder;
51  };
52 
53 
54  struct SettingEncoder : public boost::static_visitor<YAML::Node> {
55  YAML::Node operator()(boost::blank a) const;
56  YAML::Node operator()(bool a) const;
57  YAML::Node operator()(int a) const;
58  YAML::Node operator()(double a) const;
59  YAML::Node operator()(std::complex<double> a) const;
60  YAML::Node operator()(const std::string& a) const;
61  YAML::Node operator()(const std::vector<double>& a) const;
62  YAML::Node operator()(const std::vector<std::string>& a) const;
63  YAML::Node operator()(const Setting::MatrixType& a) const;
64  };
65 
66  struct SettingStringConverter : public boost::static_visitor<std::string> {
67  std::string operator()(boost::blank a) const;
68  std::string operator()(bool a) const;
69  std::string operator()(int a) const;
70  std::string operator()(double a) const;
71  std::string operator()(std::complex<double> a) const;
72  std::string operator()(const std::string& a) const;
73  std::string operator()(const std::vector<double>& a) const;
74  std::string operator()(const std::vector<std::string>& a) const;
75  std::string operator()(const Setting::MatrixType& a) const;
76  };
77 
78 } // namespace Hammer
79 
80 
81 #endif
SettingWriter(flatbuffers::FlatBufferBuilder *builder)
Definition: Setting.cc:63
std::vector< std::vector< double >> MatrixType
Definition: Setting.hh:112
std::string operator()(boost::blank a) const
Definition: Setting.cc:208
std::enable_if<!std::is_same< T, S >::value, bool >::type operator()(T, S) const
flatbuffers::FlatBufferBuilder * _builder
bool operator()(boost::blank a, boost::blank b) const
Definition: Setting.cc:23
std::pair< flatbuffers::Offset< void >, Serial::FBSettingTypes > WrittenSettingType
Definition: Setting.hh:98
YAML::Node operator()(boost::blank a) const
Definition: Setting.cc:139
Hammer setting class.
Setting::WrittenSettingType operator()(boost::blank a) const
Definition: Setting.cc:65