summaryrefslogtreecommitdiff
path: root/p2pvr/daemon/containerIterator.h
blob: 88976af38562643e842855ce3de28a8c46286cee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CONTAINERITERATOR_H
#define CONTAINERITERATOR_H

#include <iHaveSubTasks.h>
#include "objectRowState.h"

template <typename T>
class ContainerIterator : public IHaveSubTasks {
	public:
		ContainerIterator(const T * con, const SelectedColumns & sc) :
			SourceObject(__PRETTY_FUNCTION__),
			IHaveSubTasks(NULL),
			binder(boost::bind(&BindColumns<typename T::value_type>, _1, sc, _2)),
			container(con)
		{
		}

		void execute(ExecContext * ec) const
		{
			ObjectRowStateTmpl<typename T::value_type> rs;
			for (const auto & i : *container) {
				binder(rs, i);
				rs.process(ec, boost::bind(&ContainerIterator::executeChildren, this, ec));
			}
		}

	private:
		boost::function<void(RowState &, const typename T::value_type &)> binder;
		const T * container;

		void executeChildren(ExecContext * ec) const
		{
			for (const Tasks::value_type & sq : normal) {
				sq->execute(ec);
			}
		}
};

#endif