summaryrefslogtreecommitdiff
path: root/p2pvr/lib/objectRowState.h
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/lib/objectRowState.h')
-rw-r--r--p2pvr/lib/objectRowState.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/p2pvr/lib/objectRowState.h b/p2pvr/lib/objectRowState.h
new file mode 100644
index 0000000..9ba69f0
--- /dev/null
+++ b/p2pvr/lib/objectRowState.h
@@ -0,0 +1,45 @@
+#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;
+typedef boost::function<void(const ColumnCreator &)> ColumnSpecifier;
+
+template <typename V>
+void BindColumns(RowState &, const V &);
+
+template <typename V>
+void UnbindColumns(RowState &, const V &);
+
+template <typename V>
+void CreateColumns(const ColumnCreator &);
+
+template <typename T>
+class ObjectRowState : public RowState {
+ public:
+ ObjectRowState(const ColumnSpecifier & cs = CreateColumns<T>) :
+ columns(ColumnCreatorHelper(cs))
+ {
+ fields.resize(columns.size());
+ }
+ const Columns & getColumns() const { return columns; }
+
+ private:
+ static Columns ColumnCreatorHelper(const ColumnSpecifier & cs)
+ {
+ int index = 0;
+ Columns columns;
+ cs([&columns, &index](const std::string & name, bool) {
+ columns.insert(new Column(index++, name));
+ });
+ return columns;
+ }
+
+ Columns columns;
+};
+
+#endif
+