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

#pragma once

#include "glmRTTI.h"
#include "glmTypes.h"

namespace glm
{
    struct ShaderAttributeV1;

    /**
     * \brief Shader Attribure
     */
    struct GLM_CORE_API ShaderAttributeV2
    {
        GLM_RTTI("01c8d8a5-8457-45ed-b8cc-c3108cfeff70", ShaderAttributeV2, addAttributes)
    public:
        GLM_CLASS_STAT_ID(glm::MemoryStatIds::GolaemShared);

        /// The name of the attribute
        glm::GlmString _name;

        /// The type of the attribute
        ShaderAttributeType::Value _type = ShaderAttributeType::INT;

        /// The string value
        glm::GlmString _stringValue;

        /// If true, a random value between the min and max values will be used,
        /// otherwise the PP attribute value will be used instead
        ShaderAttributeValueType::Value _valueType = ShaderAttributeValueType::RANDOM;

        /// The PP attribute from which to retrieve the value
        glm::GlmString _ppAttr;

        // added in v8.0.0
        glm::PODArray<float> _weights;

    protected:
        /// The min value (to be interpreted according to the type)
        glm::GlmString _minValue = "0";

        /// The max value (to be interpreted according to the type)
        glm::GlmString _maxValue = "0";

    public:
        /**
         * \brief V1 backwards compatibility
         * \note V1 does not have weigths
         */
        void createFromV1(ShaderAttributeV1& shaderAttributeV1);

        void setMinValue(glm::GlmString minValue); // for inspection
        void setMaxValue(glm::GlmString maxValue); // for inspection

        inline glm::GlmString getMinValue() const; // for inspection
        inline glm::GlmString getMaxValue() const; // for inspection

    protected:
        /**
         * \brief Inspection needed method declaring the inspectable attributes.
         */
        static void addAttributes();

        /**
         * \brief Accessor to the attribute type needed for inspection
         */
        int getTypeAsInt() const;
        void setTypeFromInt(int value);

        /**
         * \brief Accessor to the attribute type needed for inspection
         */
        int getValueTypeAsInt() const;
        void setValueTypeFromInt(int value);
    };

    //------------------------------------------------------------
    inline glm::GlmString ShaderAttributeV2::getMinValue() const
    {
        return _minValue;
    }

    //------------------------------------------------------------
    inline glm::GlmString ShaderAttributeV2::getMaxValue() const
    {
        return _maxValue;
    }
} // namespace glm
