summaryrefslogtreecommitdiff
path: root/p2pvr/lib/containerCreator.h
blob: aed2479d5f22c526118cb5a26de1f1b2ff655bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef CONTAINERCREATOR_H
#define CONTAINERCREATOR_H

#include <boost/function.hpp>

template <typename T, typename V>
class ContainerCreator {
	public:
		ContainerCreator(T & c) : container(c) { }

		void populate(
				boost::function<bool()> fetch,
				boost::function<VariableType(unsigned int)> get,
				boost::function<unsigned int()> columns)
		{
			while (fetch()) {
				auto v = new V;
				container.push_back(v);
				ObjectRowState<IceInternal::Handle<V>> rs;
				const auto columnCount = columns();
				for (unsigned int c = 0; c < columnCount; c++) {
					rs.fields[c] = get(c);
				}
				UnbindColumns<IceInternal::Handle<V>>(rs, v);
			}
		}
	private:
		T & container;
};

#endif