/*****************************************************************************
 * Copyright (c) 2022 MAK Technologies, Inc.
 * All rights reserved.
 *****************************************************************************/

 //! \file UserDefinedShader.h 
 //! \brief Contains makOsgSpeedTree::UserDefinedShader class. 
 //! \ingroup makOsgSpeedTree
 
#pragma once
#include "OSG/OsgST_PreReqs.h"
#include "OSG/OsgST_Types.h"
#include "OSG/OsgST_Iterators.h"
#include "OSG/OsgST_ShaderType.h"

#include <map>
#include <unordered_set>

namespace SpeedTree
{
   class CUserDefinedShadersCollection;
}

namespace makOsgSpeedTree
{
    class OsgSTExport UserDefinedShader
    {
    public:
        UserDefinedShader(uint32 id, ShaderType shaderType);
        virtual ~UserDefinedShader();
        uint32 GetID(void) const;
        bool operator==(const UserDefinedShader& rhs) const;
        ShaderType GetShaderType(void) const;
    private:
        UserDefinedShader(){}
        uint32 m_ID;
        ShaderType m_ShaderType;
    };

    struct OsgSTExport UserDefinedShaderHasher
    {
       size_t operator() (const UserDefinedShader& interval) const;
    };

    typedef std::unordered_set<UserDefinedShader, UserDefinedShaderHasher> SetUserDefinedShaders;

    class OsgSTExport UserDefinedShadersCollection
    {
    public:
        UserDefinedShadersCollection(size_t hashId);
        UserDefinedShadersCollection() {}

        virtual ~UserDefinedShadersCollection();
        bool operator==(const UserDefinedShadersCollection& rhs) const;
        size_t GetHashId(void) const{return m_HashId;}
        bool HasShader(const UserDefinedShader& shader) const;
        void Add(const UserDefinedShader& shader);
        void clear();

        size_t NumShaders(void) const;
        const UserDefinedShader& GetShader(size_t index) const;

        static void copyTo(SpeedTree::CUserDefinedShadersCollection& stDstUserDefinedShaders, const UserDefinedShadersCollection& srcUserDefinedShaders);
    private:
       size_t m_HashId;

       SetUserDefinedShaders m_UserDefinedShaders;
    };

    typedef std::map<int, UserDefinedShadersCollection> UserDefinedShadersCollectionMap;
}