#ifndef __WFX_LANG_WFXSYSTEM_H__
#define __WFX_LANG_WFXSYSTEM_H__

#include <WFX/WFXIncludes.h>
#include <WFX/lang/Singleton.h>
#include <WFX/kernel/TimeTask.h>
#include <WFX/input/InputHandler.h>
#include <WFX/renderer/RenderWindow.h>
#include <WFX/renderer/Renderer.h>
#include <WFX/scene/TextureManager.h>
#include <WFX/util/EndianConvert.h>

namespace WFX {

    namespace lang {
        
        /**
         * WFX System interface - Abstract Factory Pattern
         * this class represents any System-Specific functionality
         * implementations should use the pointers in this class to
         * ensure that all Resources are deleted accordingly
         */
        class WFXSystem : public WFX::lang::Singleton<WFXSystem> {
            public:
                /** Ctor */
                WFXSystem();

                /** Dtor */
                virtual ~WFXSystem();

                /** 
                 * generator Method - returns a pointer to 
                 * a valid System implementation
                 */
                static WFXSystem* getImpl();

                /**
                 * creates the Timer and returns a pointer to it
                 */
                virtual WFX::kernel::TimeTask* getTimeTask() = 0;
                
                /**
                 * creates an InputHandler
                 * @return: a pointer to the InputHandler
                 *
                 * @throws: any Exception the InputHandler might generate
                 */
                virtual WFX::input::InputHandler* getInputHandler() = 0;

                /**
                 * creates a renderwindow
                 * implementations must add the Window to the RenderWindows vector
                 * @see renderer/RenderWindow::RenderWindow
                 * @return: a pointer to the renderwindow
                 */
                virtual WFX::renderer::RenderWindow* getRenderWindow(Int w, Int h, Int d, std::string title, bool fs) = 0;
                
                /**
                 * creates a Renderer
                 * @return: a pointer to the Renderer
                 *
                 * @throws: any Exception the Renderer might generate
                 */
                virtual WFX::renderer::Renderer* getRenderer() = 0;
                            
                /**
                 * creates a System dependent TextureManager, returns the default TM of def == true 
                 * @return: a pointer to the TextureManager
                 *
                 * @throws: any Exception the TextureManager might generate
                 */
                virtual WFX::scene::TextureManager* getTextureManager(bool def = false) = 0;

                /**
                 * returns an EndianConvert instance
                 * common endianess is LITTLE ENDIAN
                 */
                virtual WFX::util::EndianConvert* getEndianConvert() = 0;
                            
                /**
                 * returns the current directory
                 * implementations should return a unix-like notation e.g. /home/foo
                 * Important: do not add unnecessary trailing slashes...
                 */
                virtual std::string getCurrentPath() = 0;

            protected:
                /** the TimeTask */
                WFX::kernel::TimeTask* TimeTask;
                /** the InputHandler */
                WFX::input::InputHandler* InputHandler;
                /** the RenderWindows */
                std::vector<WFX::renderer::RenderWindow*> RenderWindows;
                /** the Renderer */
                WFX::renderer::Renderer* Renderer;
                /** the TextureManager */
                WFX::scene::TextureManager* TextureManager;
                            

            private:
        };

    }
    
}

//define some singleton stuff
#define SYS WFX::lang::WFXSystem::getInstance()
#define SYSPTR WFX::lang::WFXSystem::getInstancePtr()
#endif //include guard

