diff options
Diffstat (limited to 'p2pvr/lib/containerIterator.h')
-rw-r--r-- | p2pvr/lib/containerIterator.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/p2pvr/lib/containerIterator.h b/p2pvr/lib/containerIterator.h new file mode 100644 index 0000000..1c4e6bf --- /dev/null +++ b/p2pvr/lib/containerIterator.h @@ -0,0 +1,41 @@ +#ifndef CONTAINERITERATOR_H +#define CONTAINERITERATOR_H + +#include <iHaveSubTasks.h> +#include <boost/foreach.hpp> +#include "objectRowState.h" + +template <typename T> +class ContainerIterator : public IHaveSubTasks { + public: + template <typename ... Parents> + ContainerIterator(const T * con, const Parents & ... p) : + SourceObject(__PRETTY_FUNCTION__), + IHaveSubTasks(NULL), + binder(boost::bind(&BindColumns<typename T::value_type, Parents...>, _1, _2, p...)), + container(con) + { + } + void execute(ExecContext * ec) const + { + ObjectRowState<typename T::value_type> rs; + BOOST_FOREACH(const auto & i, *container) { + binder(rs, i); + rs.process(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 + { + BOOST_FOREACH(const Tasks::value_type & sq, normal) { + sq->execute(ec); + } + } +}; + +#endif + |