summaryrefslogtreecommitdiff
path: root/p2pvr/lib/containerCreator.h
blob: 9804d9be6bb085687a0b5577b5cb209ca42d9211 (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
33
#ifndef CONTAINERCREATOR_H
#define CONTAINERCREATOR_H

#include <boost/function.hpp>
#include <Ice/Handle.h>
#include "objectRowState.h"

template <typename T, typename V, typename P = IceInternal::Handle<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 = P(new V);
				container.push_back(v);
				ObjectRowState<P> rs;
				for (unsigned int c = 0; c < columnCount; c++) {
					rs.fields[c] = get(c);
				}
				UnbindColumns<P>(rs, v);
			}
		}
	private:
		T & container;
};

#endif