26 #if ! defined (octave_action_container_h)
27 #define octave_action_container_h 1
29 #include "octave-config.h"
65 virtual void run (
void) { }
77 template <
typename F,
typename... Args>
79 : m_fcn (std::bind (fcn, args...))
82 void run (
void) { m_fcn (); }
86 std::function<void (
void)>
m_fcn;
97 : m_ptr (&ref), m_val (val) { }
105 void run (
void) { *m_ptr = m_val; }
114 template <
typename T>
128 void run (
void) {
delete m_ptr; }
145 template <
typename F,
typename... Args>
146 void add (F&& fcn, Args&& ... args)
148 add_action (
new fcn_elem (std::forward<F> (fcn),
149 std::forward<Args> (args)...));
156 template <
typename... Params,
typename... Args>
157 void add_fcn (
void (*fcn) (Params...), Args&& ... args)
159 add_action (
new fcn_elem (fcn, std::forward<Args> (args)...));
162 template <
typename T,
typename... Params,
typename... Args>
163 void add_method (T *obj,
void (T::*method) (Params...), Args&& ... args)
165 add_action (
new fcn_elem (method, obj, std::forward<Args> (args)...));
168 template <
typename T,
typename... Params,
typename... Args>
169 void add_method (T& obj,
void (T::*method) (Params...), Args&& ... args)
171 add_action (
new fcn_elem (method, &obj, std::forward<Args> (args)...));
176 template <
typename T>
183 template <
typename T>
190 template <
typename T>
196 operator bool (
void)
const {
return ! empty (); }
211 for (std::size_t i = 0; i < num; i++)
217 virtual std::size_t
size (
void)
const = 0;
219 bool empty (
void)
const {
return size () == 0; }
delete_ptr_elem(const delete_ptr_elem &)=delete
virtual ~elem(void)=default
elem & operator=(const elem &)=delete
elem(const elem &)=delete
std::function< void(void)> m_fcn
fcn_elem(F &&fcn, Args &&... args)
restore_var_elem(const restore_var_elem &)=delete
restore_var_elem(T &ref, const T &val)
void add(F &&fcn, Args &&... args)
void add_method(T *obj, void(T::*method)(Params...), Args &&... args)
virtual void run_first(void)=0
void add_method(T &obj, void(T::*method)(Params...), Args &&... args)
virtual std::size_t size(void) const =0
action_container(const action_container &)=delete
virtual void add_action(elem *new_elem)=0
virtual void discard_first(void)=0
void protect_var(T &var, const T &val)
virtual ~action_container(void)=default
void discard(std::size_t num)
void add_fcn(void(*fcn)(Params...), Args &&... args)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn