#ifndef M2File_H
#define M2File_H

#include "Array.h"

namespace Framework
{
    class Model2DData; //! Model2D.h
    class Text;        //! Text.h

    //! This class manages the framework's own file format for 2D model data.
    //! Multiple 2D model data can be stored in one file.
    class M2File : public virtual ReferenceCounter
    {
    private:
        Text* pfad;
        RCArray<Text>* modelName;
        Array<__int64>* modelPos;

    public:
        //! Constructor
        DLLEXPORT M2File();
        //! Constructor
        //! \param pfad The path to the file
        DLLEXPORT M2File(const char* pfad);
        //! Constructor
        //! \param pfad The path to the file
        DLLEXPORT M2File(Text* pfad);
        //! Destructor
        DLLEXPORT ~M2File();
        //! Sets the path to the file
        //! \param pfad Path to the file
        DLLEXPORT void setPfad(const char* pfad);
        //! Sets a pointer to the path to the file
        //! \param pfad Pointer to the path to the file
        DLLEXPORT void setPfadZ(Text* pfad);
        //! Reads basic information from the file needed for its usage
        DLLEXPORT void readData();
        //! Saves 2D model data to the file
        //! \param zMdr A pointer to the data to save without increased
        //! reference counter \param name The name under which the data should
        //! be stored in the file \return 1 if the model was saved.
        //! 0 if an error occurred during saving
        DLLEXPORT bool saveModel(Model2DData* zMdr, Text* name);
        //! Saves 2D model data to the file
        //! \param zMdr A pointer to the data to save without increased
        //! reference counter \param name The name under which the data should
        //! be stored in the file \return 1 if the model was saved.
        //! 0 if an error occurred during saving
        DLLEXPORT bool saveModel(Model2DData* zMdr, const char* name);
        //! Deletes a 2D model from the file
        //! \param name The name of the model
        //! \return 1 if the model was deleted. 0 if the model was not
        //! found or an error occurred during saving
        DLLEXPORT bool removeModel(Text* name);
        //! Deletes a 2D model from the file
        //! \param name The name of the model
        //! \return 1 if the model was deleted. 0 if the model was not
        //! found or an error occurred during saving
        DLLEXPORT bool removeModel(const char* name);
        //! Loads a 2D model from the file
        //! \param name The name of the model to load
        //! \return The loaded data
        DLLEXPORT Model2DData* loadModel(Text* name) const;
        //! Loads a 2D model from the file
        //! \param name The name of the model to load
        //! \return The loaded data
        DLLEXPORT Model2DData* loadModel(const char* name) const;
        //! Checks whether a specific 2D model exists in the file
        //! \param name The name of the 2D model to search for
        //! \return 1 if the model was found. 0 otherwise
        DLLEXPORT bool hasModel(const char* name) const;
        //! Returns the number of stored models
        DLLEXPORT int getModelCount() const;
        //! Returns the name of a specific model
        //! \param i The index of the model
        //! \return A pointer to the name of the model without increased
        //! reference counter
        DLLEXPORT Text* zModelName(int i) const;
    };
} // namespace Framework

#endif