#include <cassert>
#include <config/xf-config.h>

#if (USE_XF_IDF_STM32_XF_CLASS != 0)

#include "xf/interface/timeoutmanager.h"
#include "xf/interface/dispatcher.h"
#include "xf/xf.h"

using interface::XFTimeoutManager;

void XF_initialize(int timeInterval) {
    XF::initialize(timeInterval);
}

void XF_exec() {
    XF::exec();
}

void XF_execOnce() {
    XF::execOnce();
}

// TODO: Implement code for XF class

bool XF::isInitialized_ = false;
bool XF::isRunning_ = false;

void XF::initialize(int timeInterval, int argc, char *argv[]){

	if(!isInitialized_) {
		interface::XFTimeoutManager::getInstance()->initialize(timeInterval);

		isInitialized_ = true;
	}
}

int XF::exec(){
	int foo;
	foo = interface::XFDispatcher::getInstance()->execute();
	isRunning_ = true;
	return foo;
}

int XF::execOnce() {
	interface::XFDispatcher::getInstance()->executeOnce();
	isRunning_ = true;
	return 0;
}

bool XF::isRunning() {
	return isRunning_;
}

#endif // USE_XF_IDF_STM32_XF_CLASS
