41template<
typename T>
class RtList;
60 using list_t =
typename std::list<T*>;
61 using value_type =
typename list_t::value_type;
62 using size_type =
typename list_t::size_type;
63 using iterator =
typename list_t::iterator;
64 using const_iterator =
typename list_t::const_iterator;
83 for (
auto& delinquent: _the_actual_list)
delete delinquent;
84 _the_actual_list.clear();
94 _fifo.push(
new AddCommand(_the_actual_list, item));
102 template<
typename ForwardIterator>
103 void add(ForwardIterator first, ForwardIterator last)
105 _fifo.push(
new AddCommand(_the_actual_list, first, last));
111 _fifo.push(
new RemCommand(_the_actual_list, to_rem));
117 template<
typename ForwardIterator>
118 void rem(ForwardIterator first, ForwardIterator last)
120 _fifo.push(
new RemCommand(_the_actual_list, first, last));
126 _fifo.push(
new ClearCommand(_the_actual_list));
130 void splice(iterator position, RtList& x)
132 assert(&_fifo == &x._fifo);
133 _the_actual_list.splice(position, x._the_actual_list);
137 void splice(iterator position, RtList& x, iterator first, iterator last)
139 assert(&_fifo == &x._fifo);
140 _the_actual_list.splice(position, x._the_actual_list, first, last);
144 iterator begin() {
return _the_actual_list.begin(); }
145 const_iterator begin()
const {
return _the_actual_list.begin(); }
146 iterator end() {
return _the_actual_list.end(); }
147 const_iterator end()
const {
return _the_actual_list.end(); }
148 bool empty()
const {
return _the_actual_list.empty(); }
149 size_type size()
const {
return _the_actual_list.size(); }
154 list_t _the_actual_list;
166 : _splice_list(1, element)
167 , _dst_list(dst_list)
169 assert(element !=
nullptr);
176 template<
typename InputIterator>
177 AddCommand(list_t& dst_list, InputIterator first, InputIterator last)
178 : _splice_list(first, last)
179 , _dst_list(dst_list)
184 _dst_list.splice(_dst_list.end(), _splice_list);
204 : _dst_list(dst_list)
205 , _delinquents(1, delinquent)
212 template<
typename InputIterator>
213 RemCommand(list_t& dst_list, InputIterator first, InputIterator last)
214 : _dst_list(dst_list)
215 , _delinquents(first, last)
222 for (
auto& i: _delinquents)
224 auto delinquent = std::find(_dst_list.begin(), _dst_list.end(), i);
225 if (delinquent != _dst_list.end())
228 _splice_list.splice(_splice_list.begin(), _dst_list, delinquent);
232 throw std::logic_error(
"RemCommand: Item not found!");
242 for (
auto& delinquent: _splice_list)
delete delinquent;
243 _splice_list.clear();
260 : _dst_list(dst_list)
265 _delinquents.swap(_dst_list);
270 for (
auto& delinquent: _delinquents)
delete delinquent;
271 _delinquents.clear();
Manage command queue from non-realtime thread to realtime thread.
Classes derived from this class cannot be copied (but still moved).
virtual void execute()
The actual implementation of the command.
virtual void cleanup()
Cleanup of resources.
AddCommand(list_t &dst_list, InputIterator first, InputIterator last)
Constructor to add a bunch of items at once.
AddCommand(list_t &dst_list, T *element)
Constructor to add a single item.
ClearCommand(list_t &dst_list)
Constructor.
virtual void execute()
The actual implementation of the command.
virtual void cleanup()
Cleanup of resources.
RemCommand(list_t &dst_list, T *delinquent)
Constructor to remove a single item.
RemCommand(list_t &dst_list, InputIterator first, InputIterator last)
Constructor to remove a bunch of items at once.
virtual void execute()
The actual implementation of the command.
virtual void cleanup()
Cleanup of resources.
void add(ForwardIterator first, ForwardIterator last)
Add a range of elements to the list.
X * add(X *item)
Add an element to the list.
void splice(iterator position, RtList &x, iterator first, iterator last)
Splice a part of another RtList into the RtList.
void rem(T *to_rem)
Remove an element from the list.
void clear()
Remove all elements from the list.
void rem(ForwardIterator first, ForwardIterator last)
Remove a range of elements from the list.
RtList(CommandQueue &fifo)
Constructor.
void splice(iterator position, RtList &x)
Splice another RtList into the RtList.
Audio Processing Framework.
Abstract base class for realtime commands.