/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Stefan Denk <denk@ira.uka.de>
 *         Kendy Kutzner <kutzner@ira.uka.de>
 *
 * $Id: vtchannel.cc,v 1.3 2005/12/27 12:12:33 kutzner Exp $
 *
 */

// libc

#include <assert.h>

// vidtrans

#include "vtchannel.h"

/**
 * Convert a vtchannel object into a VDR cChannel pointer. Doesn't change the
 * object, just searches through the list of VDR channels and returns the first
 * match.
 * \return Pointer to a VDR cChannel object if there is a matching channel.
 * NULL otherwise.
 */
cChannel *
vtchannel::tovdr() const {
	cChannel * c = Channels.GetByChannelID(tChannelID::FromString(_channel.c_str()));
	//dsyslog("%s: channel '%s' equals %p", __PRETTY_FUNCTION__, _channel.c_str(), c);
	return c;
}

/**
 * Convert a VDR cChannel pointer to a vtchannel. Simply uses the VDR-provided method.
 * \return nothing, because it is always successful.
 */
void
vtchannel::fromvdr(const cChannel * c) {
	assert(c);
	_channel = c->GetChannelID().ToString();
}

/**
 * Compare two channels.
 * Needed for standard containers.
 * Compare with basic string functions.
 */
bool
vtchannel::operator<(const vtchannel & other) const {
	return _channel < other._channel;
}
