#ifndef _IMPORT_BASE_HPP_
#define _IMPORT_BASE_HPP_

#include <string>
#include <fstream>

#include "system/parts.hpp"
#include "system/signals.hpp"

/**
 * @brief Base class for importing data from a file.
 *
 * This class provides a foundation for parsing files and managing
 * system parts and signals. Derived classes must implement the `parse` method.
 */
class ImportBase
{
protected:
    Parts *prts; ///< Pointer to the Parts object.
    Signals *sigs; ///< Pointer to the Signals object.
    std::fstream file_lines; ///< File stream for reading the input file.

public:
    /**
     * @brief Constructor for ImportBase.
     *
     * Initializes the file stream and creates new Parts and Signals objects.
     *
     * @param file_name Name of the file to be imported.
     */
    ImportBase(std::string file_name) : file_lines(std::fstream(file_name))
    {
        prts = new Parts();
        sigs = new Signals();
    };

    /**
     * @brief Pure virtual method for parsing the file.
     *
     * Derived classes must implement this method to define how the file is parsed.
     *
     * @param signals Pointer to the signals object to be completed.
     */
    virtual void parse(Signals * signals) = 0;

    /**
     * @brief Retrieves the Parts object.
     * @return Pointer to the Parts object.
     */
    Parts * parts()
    {
        return prts;
    }

    /**
     * @brief Retrieves the Signals object.
     * @return Pointer to the Signals object.
     */
    Signals * signals()
    {
        return sigs;
    }

    /**
     * @brief Virtual destructor for ImportBase.
     *
     * Ensures proper cleanup of derived classes.
     */
    virtual ~ImportBase() = default;
};

#endif // _IMPORT_BASE_HPP_