diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-18 00:25:45 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-18 00:25:45 +0100 |
commit | 3d154e756d61d8617bb8023eb552b5e4faab2a74 (patch) | |
tree | a887a65f8699e7dbf46e8d50c25b575e50d498b2 /p2pvr/daemon/containerIterator.h | |
parent | Merge branch 'netfs-test-refactor' (diff) | |
parent | Compatibility with AppInstance and ExecContext changes (diff) | |
download | p2pvr-3d154e756d61d8617bb8023eb552b5e4faab2a74.tar.bz2 p2pvr-3d154e756d61d8617bb8023eb552b5e4faab2a74.tar.xz p2pvr-3d154e756d61d8617bb8023eb552b5e4faab2a74.zip |
Merge branch 'p2pvr'
Diffstat (limited to 'p2pvr/daemon/containerIterator.h')
-rw-r--r-- | p2pvr/daemon/containerIterator.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/p2pvr/daemon/containerIterator.h b/p2pvr/daemon/containerIterator.h new file mode 100644 index 0000000..88976af --- /dev/null +++ b/p2pvr/daemon/containerIterator.h @@ -0,0 +1,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 + |