summaryrefslogtreecommitdiff
path: root/p2pvr/lib/mapIterator.h
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/lib/mapIterator.h')
-rw-r--r--p2pvr/lib/mapIterator.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/p2pvr/lib/mapIterator.h b/p2pvr/lib/mapIterator.h
new file mode 100644
index 0000000..8a06fe6
--- /dev/null
+++ b/p2pvr/lib/mapIterator.h
@@ -0,0 +1,45 @@
+#ifndef MAPITERATOR_H
+#define MAPITERATOR_H
+
+#include <iHaveSubTasks.h>
+#include <boost/foreach.hpp>
+#include "objectRowState.h"
+
+template <typename T>
+class MapIterator : public IHaveSubTasks {
+ public:
+ template <typename ... Parents>
+ MapIterator(const ColumnSpecifier & cs, const T * m, const Parents & ... p) :
+ SourceObject(__PRETTY_FUNCTION__),
+ IHaveSubTasks(NULL),
+ binder(boost::bind(&BindColumns<typename T::value_type, Parents...>, _1, _2, p...)),
+ columnSpecifier(cs),
+ map(m)
+ {
+ }
+
+ void execute(ExecContext * ec) const
+ {
+ ObjectRowState<typename T::value_type> rs(columnSpecifier);
+ BOOST_FOREACH(const auto & i, *map) {
+ binder(rs, i);
+ rs.process(boost::bind(&MapIterator::executeChildren, this, ec));
+ }
+ }
+
+ private:
+ boost::function<void(RowState &, const typename T::value_type &)> binder;
+ const ColumnSpecifier columnSpecifier;
+ const T * map;
+
+ void executeChildren(ExecContext * ec) const
+ {
+ BOOST_FOREACH(const Tasks::value_type & sq, normal) {
+ sq->execute(ec);
+ }
+ }
+};
+
+#endif
+
+