#pragma once
#include <memory>
#include <typeindex>
#include <typeinfo>

/**
 * namespace for the Entity-Component-System (ECS)
 */
namespace ecs {

// Classe de base pour tous les composants
class Component {
public:
    Component() = default;
    virtual ~Component() = default;

    // Empêcher la copie
    Component(const Component&) = delete;
    Component& operator=(const Component&) = delete;

    // Permettre le déplacement
    Component(Component&&) = default;
    Component& operator=(Component&&) = default;

    /**
     * Virtual function to initialize the component.
     */
    virtual void Initialize() {}

    /**
     * Virtual function to update the component.
     * @param deltaTime Time since the last update.
     */
    virtual void Update(float deltaTime) {}

    // virtual std::string Serialize() {}
    // virtual void Deserialize(const std::string& data) {}
};

/**
 * Type alias for a shared pointer to a Component.
 */
using ComponentPtr = std::shared_ptr<Component>;
    
/**
* Type alias for a unique identifier for a component type.
*/
using ComponentTypeID = std::type_index;

/**
 * Function to get the unique type ID for a component type.
 */
template<typename T>
ComponentTypeID GetComponentTypeID() {
    static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
    return std::type_index(typeid(T));
}

}  // namespace ecs
