#include "Real_Time_Data_Base.hpp"
#include "renderive/renderable/base/Renderable_Base.hpp"
#include <utility>

Real_Time_Data_Binding::Real_Time_Data_Binding(Renderable_Base& renderable, Real_Time_Data_Base& data)
    : renderable_(&renderable), data_(&data) {
    renderable_->register_real_time_data(*data_);
}

Real_Time_Data_Binding::Real_Time_Data_Binding(Real_Time_Data_Binding&& other) noexcept
    : renderable_(std::exchange(other.renderable_, nullptr)), data_(std::exchange(other.data_, nullptr)) {}

Real_Time_Data_Binding::~Real_Time_Data_Binding() {
    if (renderable_) {
        renderable_->unregister_real_time_data(*data_);
    }
}

Real_Time_Data_Binding Real_Time_Data_Base::bind_renderable(Renderable_Base& renderable) {
    return {renderable, *this};
}
