#pragma once

#include <string>
#include <map>
#include <cstdint>
#include <optional>

#include "src/Targets/BriefTargetDescriptor.hpp"

namespace Services
{
    class TargetService
    {
    public:
        /**
         * Performs a lookup for the given target configuration value, to retrieve the corresponding brief target
         * descriptor object.
         *
         * @param configValue
         *  The target configuration value to lookup.
         *
         * @return
         *  A BriefTargetDescriptor object, if found, otherwise, std::nullopt.
         */
        static std::optional<Targets::BriefTargetDescriptor> briefDescriptor(const std::string& configValue);

        /**
         * Provides access to the internal mapping of the brief target descriptor objects of all targets supported by
         * Bloom. See TargetService::descriptorsByConfigValue for more.
         *
         * @return
         */
        static const std::map<std::string, Targets::BriefTargetDescriptor>& briefDescriptorsByConfigValue();

    private:
        /**
         * This mapping contains brief target descriptor objects for every target supported by Bloom, mapped by their
         * configuration value.
         *
         * The contents of this mapping is generated by a build script and stored in an ASCII text file, located
         * at GENERATED_BRIEF_TARGET_DESCRIPTOR_MAPPING_PATH.
         *
         * See build/scripts/GenerateBriefTargetDescriptors.php and the root CMakeLists.txt for more.
         */
        static const inline std::map<std::string, Targets::BriefTargetDescriptor> descriptorsByConfigValue = {
#include GENERATED_BRIEF_TARGET_DESCRIPTOR_MAPPING_PATH
        };
    };
}
