Bridge++  Version 1.4.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 nlevel)
20  : m_vl(CommonParameters::Vlevel()),
21  m_num_level(nlevel), m_actions(nlevel), m_integrator_types(nlevel)
22 {
23 }
24 
25 
26 //====================================================================
27 bool ActionList::append(const int level, Action *action)
28 {
29  if ((level < 0) || (level >= m_num_level)) return false;
30 
31  m_actions[level].push_back(action);
32 
33  return true;
34 }
35 
36 
37 //====================================================================
38 bool ActionList::append(const int level, unique_ptr<Action>& action)
39 {
40  return append(level, action.get());
41 }
42 
43 
44 //====================================================================
45 bool ActionList::append(const int level, const std::vector<Action *>& actions)
46 {
47  if ((level < 0) || (level >= m_num_level)) return false;
48 
49  for (size_t i = 0, n = actions.size(); i < n; ++i) {
50  m_actions[level].push_back(actions[i]);
51  }
52 
53  return true;
54 }
55 
56 
57 //====================================================================
58 bool ActionList::set_integrator_type(const int level, const std::string& type)
59 {
60  if ((level < 0) || (level >= m_num_level)) return false;
61 
62  m_integrator_types[level] = type;
63 
64  return true;
65 }
66 
67 
68 //====================================================================
69 bool ActionList::set_integrator_type(const std::string& type)
70 {
71  for (size_t i = 0; i < m_num_level; ++i) {
72  m_integrator_types[i] = type;
73  }
74 
75  return true;
76 }
77 
78 
79 //====================================================================
81 {
82  ActionSet v;
83 
84  for (size_t i = 0; i < m_num_level; ++i) {
85  v.insert(v.end(), m_actions[i].begin(), m_actions[i].end());
86  }
87 
88  return v;
89 }
90 
91 
92 //====================================================================
93 ActionSet ActionList::get_actions(const int level) const
94 {
95  if ((level < 0) || (level >= m_num_level)) return ActionSet();
96 
97  return m_actions[level];
98 }
99 
100 
101 //====================================================================
102 std::string ActionList::get_integrator_type(const int level) const
103 {
104  if ((level < 0) || (level >= m_num_level)) return std::string();
105 
106  return m_integrator_types[level];
107 }
108 
109 
110 //====================================================================
112 {
113  return m_num_level;
114 }
115 
116 
117 //====================================================================
118 //============================================================END=====
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_num_level
Definition: action_list.h:66
ActionSet get_actions() const
Definition: action_list.cpp:80
pointer get() const
Common parameter class: provides parameters as singleton.
std::vector< std::string > m_integrator_types
Definition: action_list.h:68
std::vector< ActionSet > m_actions
Definition: action_list.h:67
std::string get_integrator_type(const int level) const
bool set_integrator_type(const int level, const std::string &type)
Definition: action_list.cpp:58
std::vector< Action * > ActionSet
Definition: action_list.h:38