/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <memory>
#include <vector>
#include <vulkan/vulkan.hpp>

namespace OpenVulkano::Vulkan
{
	class Device;

	class DeviceManager final
	{
		std::vector<std::shared_ptr<Device>> devices;

	public:
		DeviceManager() = default;

		DeviceManager(const vk::Instance& instance)
		{
			Init(instance);
		}

		~DeviceManager()
		{
			if (!devices.empty()) Close();
		}

		void Init(const vk::Instance& instance);

		std::shared_ptr<Device> GetCompatibleDevice(const vk::ArrayProxy<const std::string>& deviceExtensions);

		std::string ProduceMissingDeviceCompatibilityReport(const vk::ArrayProxy<const std::string>& deviceExtensions);

		void Close()
		{
			devices.clear();
		}
	};
}
