/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A. - All Rights Reserved.                        *
*                                                                          *
***************************************************************************/

#pragma once

#include <glmCrowdIOAPI.h>
#include <glmMemory.h>
//#include <glmTypes.h>
//#include <glmMap.h>
#include <glmArray.h>
#include <glmString.h>
#include <glmSimulationCacheInformation.h>

namespace glm
{
    namespace crowdio
    {
        //struct SimCacheLibItem
        //{
        //    GlmString _cacheDir;
        //    GlmString _cacheName;
        //    GlmString _characterFiles; // coma separated gchas
        //    glm::Array<GlmString> _crowdFields;
        //    GlmString _destTerrain; 
        //    bool _enableLayout;
        //    int _endFrame;
        //    GlmString _image;
        //    GlmString _itemName; 
        //    GlmString _layoutFile;
        //    int _nbEntities;
        //    GlmString _nodeName;
        //    GlmString _sourceTerrain;
        //    int _startFrame;
        //    glm::Array<GlmString> _tags;
        //    GlmString _type;
        //};

        //struct SimulationCacheLibrary
        //{
        //    glm::Array<SimCacheLibItem> items;
        //    GlmString _libFile;
        //    bool _libFileDirty;
        //    int _libFileVersion;
        //    GlmString _type;
        //};

        class GLM_CROWDIO_API SimulationCacheLibrary
        {

        public:
            glm::Array<SimulationCacheInformation> _cacheInformations; // size should match _cacheProxyNames after parsing, else error

        public:
            SimulationCacheLibrary();

            ~SimulationCacheLibrary();

            SimulationCacheInformation* getCacheInformationByCacheName(const char* name);
            SimulationCacheInformation* getCacheInformationByItemName(const char* name);

            bool loadLibrary(const char* libraryFilePath, bool loadImages = false);
            bool loadLibrary(const char* buffer, size_t bufferByteSize, bool loadImages = false);
            
            void clear();

            inline size_t getCacheInformationCount();

            inline SimulationCacheInformation& getCacheInformation(size_t index);
        };

        size_t SimulationCacheLibrary::getCacheInformationCount()
        {
            return _cacheInformations.size();
        }

        SimulationCacheInformation& SimulationCacheLibrary::getCacheInformation(size_t index)
        {
            return _cacheInformations[index];
        }
    } // namespace crowdio
} // namespace glm