// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp

#pragma once

#ifndef NAZARA_UBERSHADER_HPP
#define NAZARA_UBERSHADER_HPP

#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Renderer/UberShaderInstance.hpp>
#include <unordered_map>

namespace Nz
{
	class UberShader;

	using UberShaderConstRef = ObjectRef<const UberShader>;
	using UberShaderLibrary = ObjectLibrary<UberShader>;
	using UberShaderRef = ObjectRef<UberShader>;

	class NAZARA_RENDERER_API UberShader : public RefCounted
	{
		friend UberShaderLibrary;
		friend class Renderer;

		public:
			UberShader() = default;
			UberShader(const UberShader&) = delete;
			UberShader(UberShader&&) = delete;
			virtual ~UberShader();

			virtual UberShaderInstance* Get(const ParameterList& parameters) const = 0;

			UberShader& operator=(const UberShader&) = delete;
			UberShader& operator=(UberShader&&) = delete;

			// Signals:
			NazaraSignal(OnUberShaderRelease, const UberShader* /*uberShader*/);

		private:
			static bool Initialize();
			static void Uninitialize();

			static UberShaderLibrary::LibraryMap s_library;
	};
}

#endif // NAZARA_UBERSHADER_HPP
