Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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, unique_ptr<Action>& action)
42 {
43  return append(level, action.get());
44 }
45 
46 
47 //====================================================================
48 bool ActionList::append(const int level, const std::vector<Action *>& actions)
49 {
50  if ((level < 0) || (level >= m_Nlevels)) {
51  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);
52  exit(EXIT_FAILURE);
53  }
54 
55  for (size_t i = 0, n = actions.size(); i < n; ++i) {
56  m_actions[level].push_back(actions[i]);
57  }
58 
59  return true;
60 }
61 
62 
63 //====================================================================
64 bool ActionList::set_integrator_type(const int level, const std::string& type)
65 {
66  if ((level < 0) || (level >= m_Nlevels)) {
67  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);
68  exit(EXIT_FAILURE);
69  }
70 
71  m_integrator_types[level] = type;
72 
73  return true;
74 }
75 
76 
77 //====================================================================
78 bool ActionList::set_integrator_type(const std::string& type)
79 {
80  for (size_t i = 0; i < m_Nlevels; ++i) {
82  }
83 
84  return true;
85 }
86 
87 
88 //====================================================================
90 {
91  ActionSet v;
92 
93  for (size_t i = 0; i < m_Nlevels; ++i) {
94  v.insert(v.end(), m_actions[i].begin(), m_actions[i].end());
95  }
96 
97  return v;
98 }
99 
100 
101 //====================================================================
102 ActionSet ActionList::get_actions(const int level) const
103 {
104  if ((level < 0) || (level >= m_Nlevels)) return ActionSet();
105 
106  return m_actions[level];
107 }
108 
109 
110 //====================================================================
111 std::string ActionList::get_integrator_type(const int level) const
112 {
113  if ((level < 0) || (level >= m_Nlevels)) return std::string();
114 
115  return m_integrator_types[level];
116 }
117 
118 
119 //====================================================================
121 {
122  return m_Nlevels;
123 }
124 
125 
126 //====================================================================
127 //============================================================END=====
Bridge::VerboseLevel m_vl
Definition: action_list.h:62
BridgeIO vout
Definition: bridgeIO.cpp:503
ActionList(const int nlevel)
Definition: action_list.cpp:19
int get_levels() const
static const std::string class_name
Definition: action_list.h:43
Base class of HMC action class family.
Definition: action.h:36
bool append(const int level, Action *action)
Definition: action_list.cpp:27
int m_Nlevels
Definition: action_list.h:65
ActionSet get_actions() const
Definition: action_list.cpp:89
pointer get() const
Common parameter class: provides parameters as singleton.
std::vector< std::string > m_integrator_types
Definition: action_list.h:67
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
std::vector< ActionSet > m_actions
Definition: action_list.h:66
std::string get_integrator_type(const int level) const
bool set_integrator_type(const int level, const std::string &type)
Definition: action_list.cpp:64
std::vector< Action * > ActionSet
Definition: action_list.h:38