#include "cdutils_x.h"
#include "cdutils_core.h"

using namespace CDUtils;

XInterface X;


XInterface::XInterface(): Interface(CDType::cdX) {
	CONNECTU(core, X_ReceivedX, this, receivedX);
}


void XInterface::setEnabled(const CDType & x, bool en) {
	core->x_mutex.lock();
	CDType & t((*s)[x.path()]);
	if (t.cd_type() != CDType::cdX) {
		core->x_mutex.unlock();
		return;
	}
	t.x_enabled = en;
	//piCout << t << "x_enabled" << en;
	core->need_rebuild_x = true;
	core->x_mutex.unlock();
}


PIVector<PIDeque<int> > XInterface::enabledList() const {
	return CDCore::instance()->x_selected;
}


void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) {
	CDCore::instance()->x_selected = l;
}


void XInterface::lock() {
	CDCore::instance()->x_mutex.lock();
}


void XInterface::unlock() {
	CDCore::instance()->x_mutex.unlock();
}


void XInterface::start(double freq) {
	core->startX(freq);
}


void XInterface::stop() {
	core->stopX();
}
