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

#pragma once

#include <glmCrowdIOAPI.h>
#include <glmString.h>
#include <glmDeepInferenceWrapper.h>
#include <sstream>

#ifdef __GNUC__
#define GLMDEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define GLMDEPRECATED(func) __declspec(deprecated) func
#endif

namespace glm
{
    namespace crowdio
    {
        struct GolaemVersion
        {
            enum Value
            {
                MAIN_VERSION,
                MAJOR_VERSION,
                MINOR_VERSION,
                PATCH_VERSION,
                END
            };
        };

        /// setup the golaem product, must be called before init
        extern GLM_CROWDIO_API void setupGolaemProduct(const char* productName, const char* productVersion);
        template <typename DataType>
        void setupGolaemProduct(const char* DCCName, const DataType& DCCVersion)
        {
            std::stringstream versionAsString;
            versionAsString << DCCVersion;
            setupGolaemProduct(DCCName, versionAsString.str().c_str());
        }
        extern GLM_CROWDIO_API const GlmString& getGolaemProductName();
        extern GLM_CROWDIO_API const GlmString& getGolaemProductVersion();

        /// initialize the Golaem Crowd IO library
        extern GLM_CROWDIO_API void init();

        /// finish the Golaem Crowd IO library
        extern GLM_CROWDIO_API void finish();

        extern GLM_CROWDIO_API bool isFinished();

        extern GLM_CROWDIO_API const char* getGolaemFrameExtension();
        extern GLM_CROWDIO_API const char* getGolaemSimulationExtension();
        extern GLM_CROWDIO_API const char* getGolaemTransformHistoryExtension();
		extern GLM_CROWDIO_API const char* getGolaemDigitalAssetExtension();

        extern GLM_CROWDIO_API GlmString getGolaemVersion();
        extern GLM_CROWDIO_API GlmString getGolaemReleaseLabel();
        extern GLM_CROWDIO_API GlmString getGolaemReleaseDate();
        extern GLM_CROWDIO_API unsigned int getGolaemMainVersion();
        extern GLM_CROWDIO_API void getGolaemAPIVersion(unsigned int version[4]);

        // Compare API versions, returns version1 > version2
        extern GLM_CROWDIO_API bool versionGreater(unsigned int version1[4], unsigned int version2[4]);
        // Compare API versions, returns version1 == version2
        extern GLM_CROWDIO_API bool versionEqual(unsigned int version1[4], unsigned int version2[4]);

        extern GLM_CROWDIO_API void openLayout(const char* jsonFilePath, char** jsonContent /*, int* jsonContentLength*/, bool& isPLE); // user is in charge of releasing returned memory with a call to free(). isPLE is informational only
        extern GLM_CROWDIO_API void createLayout(char** jsonContent /*, int* jsonContentLength*/, bool& isPLE);                         // user is in charge of releasing returned memory with a call to free(). isPLE is informational only
        extern GLM_CROWDIO_API void saveLayout(const char* jsonFilePath, const char* jsonContent);
        extern GLM_CROWDIO_API void freeCharArray(char** dataToFree); // to be called from python bindings to enforece using same malloc / delete as glmCrowdIO.dll

        extern GLM_CROWDIO_API void updateLayout(GlmString& jsonContent);

        extern GLM_CROWDIO_API DeepInferenceWrapper& getTheDeepInferenceWrapper();
    } // namespace crowdio
} // namespace glm
