/**
 * \file Main.h
 * \date 17.02.2002
 *
 * Interface for the CMain class
 */

#ifndef MODULES_MAIN_H
#define MODULES_MAIN_H

#include "Common/Interfaces/Control.h"
#include "Common/Module.h"

struct MODULE_ELEM;

/**
 * \class CMain
 * \author Marek Lehuta
 * \brief Control task module
 */
class Main : public Module, public ControlInterface
{
public:
	Main();
	virtual ~Main();

	/// Return interface for a task
	virtual Interface* GetInterface(int task) const;
	/// Return module for a task
	virtual Module* GetModule(int task) const;

	/// Initialize this module
	virtual int Init(int argc, char** argv, int iask = -1);
	/// Start this module
	virtual void Run(int task = -1);
	/// Stop this module
	virtual void ShutDown() { run = false; }

	/// Register new module
	virtual int RegisterModule(Module* module, int task,
		int priority = LOW_PRIORITY);

	/// Get main module pointer
	static Main* GetInstance() { return instance; }

protected:

private:
	MODULE_ELEM* moduleList;
	bool run;

	static Main* instance;

};

#endif // MODULES_MAIN_H
