diff options
Diffstat (limited to 'p2pvr/lib/objectRowState.h')
-rw-r--r-- | p2pvr/lib/objectRowState.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/p2pvr/lib/objectRowState.h b/p2pvr/lib/objectRowState.h new file mode 100644 index 0000000..9d53d43 --- /dev/null +++ b/p2pvr/lib/objectRowState.h @@ -0,0 +1,43 @@ +#ifndef OBJECT_ROW_STATE_H +#define OBJECT_ROW_STATE_H + +#include <boost/function.hpp> +#include <string> +#include <rowSet.h> + +typedef boost::function<void(const std::string &, bool)> ColumnCreator; + +template <typename V, typename... Parents> +void BindColumns(RowState &, const V &, const Parents & ...); + +template <typename V> +void UnbindColumns(RowState &, const V &); + +template <typename V> +void CreateColumns(const ColumnCreator &); + +template <typename T> +class ObjectRowState : public RowState { + public: + ObjectRowState() : + columns(ColumnCreatorHelper()) + { + fields.resize(columns.size()); + } + const Columns & getColumns() const { return columns; } + + private: + Columns ColumnCreatorHelper() + { + int index = 0; + Columns columns; + CreateColumns<T>([&columns, &index](const std::string & name, bool) { + columns.insert(new Column(index++, name)); + }); + return columns; + } + Columns columns; +}; + +#endif + |