diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-01-27 02:41:29 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-13 17:29:49 +0100 |
commit | 33a8b31afd92bf6c51b665fa95cb3662e8e60038 (patch) | |
tree | 579067c3603768d7972f218364ef0ac3679a74cf /p2pvr/daemon/containerIterator.h | |
parent | Add deps on sql (diff) | |
download | p2pvr-33a8b31afd92bf6c51b665fa95cb3662e8e60038.tar.bz2 p2pvr-33a8b31afd92bf6c51b665fa95cb3662e8e60038.tar.xz p2pvr-33a8b31afd92bf6c51b665fa95cb3662e8e60038.zip |
Move some bits from lib into more focused parts
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..14c339d --- /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(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 + |