summaryrefslogtreecommitdiff
path: root/p2pvr/lib/si.cpp
blob: 45fa7932d6f700abb059ae3610337bdf9f7952db (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
#include "si.h"
#include "dvbsiHelpers.h"
#include "containerCreator.h"
#include <linux/dvb/frontend.h>
#include <rdbmsDataSource.h>
#include <sqlHandleAsVariableType.h>
#include <selectcommand.h>
#include <logger.h>

typedef boost::shared_ptr<DB::SelectCommand> SelectPtr;

P2PVR::Deliveries
SI::GetAllDeliveries(short type, const Ice::Current &)
{
	auto db = dataSource<RdbmsDataSource>("postgres");
	SelectPtr sel;
	switch (type) {
		case FE_OFDM:
			sel = SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM delivery_dvbt"));
			break;
	}
	Logger()->messagebf(LOG_DEBUG, "%s: ", __PRETTY_FUNCTION__);
	P2PVR::Deliveries rtn;
	ContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn);
	cc.populate(boost::bind(&DB::SelectCommand::fetch, sel), [sel](unsigned int c) {
			HandleAsVariableType h;
			const DB::Column & col = (*sel)[c];
			col.apply(h);
			return h.variable;
		}, boost::bind(&DB::SelectCommand::columnCount, sel));
	return rtn;
}