#pragma once
#include <FontWriter/Type/types.hpp>

namespace JabyEngine {
    struct PrimitiveFactory {
        FontPrimitive* start_adr;
        FontPrimitive* end_adr;
        FontPrimitive* cur_element;

        static constexpr PrimitiveFactory empty() {
            return PrimitiveFactory{.start_adr = nullptr, .end_adr = nullptr, .cur_element = nullptr};
        }

        static constexpr PrimitiveFactory create(FontPrimitive* start, size_t length) {
            return PrimitiveFactory{.start_adr = start, .end_adr = start + length, .cur_element = start};
        }

        FontPrimitive& new_primitive() {
            auto& new_primitive = *this->cur_element++;
            if(this->cur_element == this->end_adr) {
                this->cur_element = this->start_adr;
            }

            return new_primitive;
        }
    };

    extern PrimitiveFactory GlobalPrimitiveFactory;
}