#ifndef COMPONENTMANAGER
#define COMPONENTMANAGER

#include <stdio.h>
#include <windows.h>
#include <string>
#include <d3dx9.h>
#include <iostream>
#include "output.h"
#include "plugin.h"
#include "resource.h"
#include "visualisation.h"
#include "manifest.h"
#include "ini.h"
#include "tchar.h"
#include "utils.h"

class ComponentManager
{
	private: 
		BOOL							LoadPlugin(std::string path); // Load a plugin from a perticular path.

		Visualisation*					ParseManifest(std::string path); // Parse a manifest from a perticular path.
		Plugin*							FindPlugin(std::string name); // Find a plugin in the list.
		D3DXVECTOR4						ParseVector4(std::string vector); // Parse a manifest Vector4 to a Direct3D Vector4.
		RESOLUTION						ParseResolution(std::string resolution); // Parse a manifest resolution.

		OutputManager*					Output; // Link to output manager.

		BOOL							SplashEnabled; // If the splash screen is enabled.

	public: 

		ComponentManager();
		~ComponentManager();

		VOID							Release(); // Release all objects.

		std::vector<Plugin*>			Plugins; // The list of loaded plugins.
		std::vector<Visualisation*>		Visualisations; // The list of loaded visualisations.

		Visualisation*					FrontVisualisation; // The front visualisation.
		Visualisation*					BackVisualisation; // The back visualisation.

		Visualisation*					GetNext(Visualisation* previous); // Get the next visualisation in the list.
		std::vector<std::string>		GetFiles(std::string dir, std::string type); // Get a list of files in a directory with a perticular extension.
		int								GetCount(); // Get the number of visualisations loaded.

		BOOL							Init(IDirect3DDevice9* device, BOOL showSplash); // Initialise the components.

		VOID							GetPlugins(std::string path); // Get all of the plugins in a perticular directory.
		VOID							GetVisualisations(std::string path); // Get all of the visualisations in a perticular directory.

		VOID							SetOutput(OutputManager* output);  // Sets the output manager.
};

#endif
