26 #if ! defined (octave_action_container_h)
27 #define octave_action_container_h 1
29 #include "octave-config.h"
57 OCTAVE_END_NAMESPACE(util)
74 OCTAVE_DISABLE_COPY_MOVE (
elem)
76 virtual ~
elem () = default;
78 virtual
void run () { }
90 template <
typename F,
typename... Args>
92 : m_fcn (std::bind (fcn, args...))
95 void run () { m_fcn (); }
99 std::function<void ()> m_fcn;
104 template <
typename T>
110 : m_ptr (&ref), m_val (val) { }
116 void run () { *m_ptr = m_val; }
121 typename util::atomic_traits<T>::type m_val;
126 template <
typename T>
138 void run () {
delete m_ptr; }
151 template <typename F, typename... Args>
152 void add (F&& fcn, Args&& ... args)
154 add_action (
new fcn_elem (std::forward<F> (fcn),
155 std::forward<Args> (args)...));
162 template <
typename... Params,
typename... Args>
163 void add_fcn (
void (*fcn) (Params...), Args&& ... args)
165 add_action (
new fcn_elem (fcn, 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)...));
174 template <
typename T,
typename... Params,
typename... Args>
175 void add_method (T& obj,
void (T::*method) (Params...), Args&& ... args)
177 add_action (
new fcn_elem (method, &obj, std::forward<Args> (args)...));
182 template <
typename T>
189 template <
typename T>
196 template <
typename T>
202 operator bool ()
const {
return ! empty (); }
217 for (std::size_t i = 0; i < num; i++)
223 virtual std::size_t
size ()
const = 0;
225 bool empty ()
const {
return size () == 0; }
232 OCTAVE_END_NAMESPACE(
octave)
~delete_ptr_elem()=default
fcn_elem(F &&fcn, Args &&... args)
restore_var_elem(T &ref, const T &val)
~restore_var_elem()=default
void add_method(T *obj, void(T::*method)(Params...), Args &&... args)
virtual std::size_t size() const =0
void add_method(T &obj, void(T::*method)(Params...), Args &&... args)
virtual void run_first()=0
virtual void add_action(elem *new_elem)=0
void protect_var(T &var, const T &val)
void discard(std::size_t num)
void add_fcn(void(*fcn)(Params...), Args &&... args)
virtual void discard_first()=0
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn