/* ***********************************************************************
//
//   Copyright (C) 2025 -- The 4D-STAR Collaboration
//   File Author: Emily Boudreaux
//   Last Modified: April 09, 2025
//
//   4DSSE is free software; you can use it and/or modify
//   it under the terms and restrictions the GNU General Library Public
//   License version 3 (GPLv3) as published by the Free Software Foundation.
//
//   4DSSE is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU Library General Public License for more details.
//
//   You should have received a copy of the GNU Library General Public License
//   along with this software; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// *********************************************************************** */

#include <memory>
#include <variant>

#include "opatIO.h"
#include "helm.h"
#include "meshIO.h"
#include "EOSio.h"

namespace serif::resource::types {
    /**
     * @file resourceManagerTypes.h
     * @brief Defines types and functions for managing resources.
     *
     * This file provides type definitions and functions for handling different
     * types of resources in a unified manner.
     */

    // -- Valid resource types
    /**
     * @brief A variant type that can hold different types of resources.
     *
     * The Resource type is a std::variant that can hold a unique pointer to
     * an OpatIO, MeshIO, or EOSio object.
     *
     * Example usage:
     * @code
     * Resource resource = std::make_unique<OpatIO>(...);
     * @endcode
     */
    using Resource = std::variant<
                        std::unique_ptr<opat::OPAT>,
                        std::unique_ptr<serif::mesh::MeshIO>,
                        std::unique_ptr<serif::eos::EOSio>>;

    /**
     * @brief Extracts the first segment of a given string.
     *
     * This function takes a string input and returns the first segment
     * separated by a delimiter (default is '/').
     *
     * @param input The input string to be processed.
     * @return The first segment of the input string.
     *
     * Example usage:
     * @code
     * std::string segment = getFirstSegment("path/to/resource");
     * // segment == "path"
     * @endcode
     */
    std::string getFirstSegment(const std::string& input);

    /**
     * @brief Creates a resource based on the specified type and path.
     *
     * This function creates a resource object based on the provided type
     * and initializes it using the given path.
     *
     * @param type The type of the resource to be created (e.g., "OpatIO", "MeshIO", "EosIO").
     * @param path The path to initialize the resource with.
     * @return A Resource object initialized with the specified type and path.
     *
     * Example usage:
     * @code
     * Resource resource = createResource("OpatIO", "path/to/opat");
     * @endcode
     */
    Resource createResource(const std::string& type, const std::string& path);
}