summaryrefslogtreecommitdiff
path: root/p2pvr/lib/containerCreator.h
blob: da4eced7fff654f94b7dc752740f0cd015305746 (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
#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,
				unsigned int columnCount)
		{
			while (fetch()) {
				auto v = new V;
				container.push_back(v);
				ObjectRowState<IceInternal::Handle<V>> rs;
				for (unsigned int c = 0; c < columnCount; c++) {
					rs.fields[c] = get(c);
				}
				UnbindColumns<IceInternal::Handle<V>>(rs, v);
			}
		}
	private:
		T & container;
};

#endif