#pragma once

#include "Array.h"
#include "Critical.h"

namespace Framework
{
    class Texture; //! Texture.h

    //! Manages all loaded texture data so that multiple drawings can use
    //! the same data
    class TextureList : public virtual ReferenceCounter
    {
    private:
        int nextId;
        mutable ReadWriteLock lock;
        RCArray<Texture>* textures;
        RCArray<Text>* names;

    public:
        //! Constructor
        TextureList();
        //! Destructor
        ~TextureList();
        //! Deletes all textures
        DLLEXPORT void clear();
        //! Adds a texture to the list
        //! \param t The texture
        //! \param name The name under which the texture is stored in the list
        DLLEXPORT bool addTexture(Texture* t, const char* name);
        //! Removes a texture from the list
        //! \param name The name of the texture
        DLLEXPORT void removeTexture(const char* name);
        //! Checks whether a texture is stored under a specific name
        //! \param name The name \return true if a texture with the name exists
        DLLEXPORT bool hasTexture(const char* name) const;
        //! Returns a specific texture
        //! \param name The name of the texture
        DLLEXPORT Texture* getTexture(const char* name) const;
        //! Returns a specific texture
        //! \param id The id of the texture
        DLLEXPORT Texture* getTexture(int id) const;
        //! Returns a specific texture without increased reference counter
        //! \param name The name of the texture
        DLLEXPORT Texture* zTexture(const char* name) const;
        //! Returns a specific texture without increased reference counter
        //! \param id The id of the texture
        DLLEXPORT Texture* zTexture(int id) const;
    };
} // namespace Framework