Bridge++  Ver. 2.0.2
action_list.cpp
Go to the documentation of this file.
1 
14 #include "action_list.h"
15 
16 const std::string ActionList::class_name = "ActionList";
17 
18 //====================================================================
19 ActionList::ActionList(const int Nlevels)
20  : m_vl(CommonParameters::Vlevel()),
21  m_Nlevels(Nlevels), m_actions(Nlevels), m_integrator_types(Nlevels)
22 {
23 }
24 
25 
26 //====================================================================
27 bool ActionList::append(const int level, Action *action)
28 {
29  if ((level < 0) || (level >= m_Nlevels)) {
30  vout.crucial(m_vl, "Error at %s: (level=%d > 0) && (level=%d < Nlevels=%d) is required\n", class_name.c_str(), level, level, m_Nlevels);
31  exit(EXIT_FAILURE);
32  }
33 
34  m_actions[level].push_back(action);
35 
36  return true;
37 }
38 
39 
40 //====================================================================
41 bool ActionList::append(const int level, const std::vector<Action *>& actions)
42 {
43  if ((level < 0) || (level >= m_Nlevels)) {
44  vout.crucial(m_vl, "Error at %s: (level=%d > 0) && (level=%d < Nlevels=%d) is required\n", class_name.c_str(), level, level, m_Nlevels);
45  exit(EXIT_FAILURE);
46  }
47 
48  for (size_t i = 0, n = actions.size(); i < n; ++i) {
49  m_actions[level].push_back(actions[i]);
50  }
51 
52  return true;
53 }
54 
55 
56 //====================================================================
57 bool ActionList::set_integrator_type(const int level, const std::string& type)
58 {
59  if ((level < 0) || (level >= m_Nlevels)) {
60  vout.crucial(m_vl, "Error at %s: (level=%d > 0) && (level=%d < Nlevels=%d) is required\n", class_name.c_str(), level, level, m_Nlevels);
61  exit(EXIT_FAILURE);
62  }
63 
64  m_integrator_types[level] = type;
65 
66  return true;
67 }
68 
69 
70 //====================================================================
71 bool ActionList::set_integrator_type(const std::string& type)
72 {
73  for (size_t i = 0; i < m_Nlevels; ++i) {
75  }
76 
77  return true;
78 }
79 
80 
81 //====================================================================
83 {
84  ActionSet v;
85 
86  for (size_t i = 0; i < m_Nlevels; ++i) {
87  v.insert(v.end(), m_actions[i].begin(), m_actions[i].end());
88  }
89 
90  return v;
91 }
92 
93 
94 //====================================================================
95 ActionSet ActionList::get_actions(const int level) const
96 {
97  if ((level < 0) || (level >= m_Nlevels)) return ActionSet();
98 
99  return m_actions[level];
100 }
101 
102 
103 //====================================================================
104 std::string ActionList::get_integrator_type(const int level) const
105 {
106  if ((level < 0) || (level >= m_Nlevels)) return std::string();
107 
108  return m_integrator_types[level];
109 }
110 
111 
112 //====================================================================
114 {
115  return m_Nlevels;
116 }
117 
118 
119 //====================================================================
120 //============================================================END=====
ActionList::m_Nlevels
int m_Nlevels
Definition: action_list.h:64
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
ActionList::set_integrator_type
bool set_integrator_type(const int level, const std::string &type)
Definition: action_list.cpp:57
action_list.h
Action
Base class of HMC action class family.
Definition: action.h:36
ActionList::m_integrator_types
std::vector< std::string > m_integrator_types
Definition: action_list.h:66
ActionList::get_integrator_type
std::string get_integrator_type(const int level) const
Definition: action_list.cpp:104
ActionSet
std::vector< Action * > ActionSet
Definition: action_list.h:38
ActionList::m_actions
std::vector< ActionSet > m_actions
Definition: action_list.h:65
ActionList::append
bool append(const int level, Action *action)
Definition: action_list.cpp:27
ActionList::ActionList
ActionList(const int nlevel)
Definition: action_list.cpp:19
ActionList::m_vl
Bridge::VerboseLevel m_vl
Definition: action_list.h:61
ActionList::get_actions
ActionSet get_actions() const
Definition: action_list.cpp:82
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
ActionList::class_name
static const std::string class_name
Definition: action_list.h:43
Element_type::type
type
Definition: bridge_defs.h:41
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
ActionList::get_levels
int get_levels() const
Definition: action_list.cpp:113