63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
#pragma once
|
|
#include "Renderable.h"
|
|
#include <renderive/base/property/Concepts.hpp>
|
|
#include <renderive/base/property/Validators.hpp>
|
|
#include <renderive/renderable/Renderable_Build.hpp>
|
|
#include <concepts>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <utility>
|
|
namespace renderive {
|
|
template <Property_Product Product_Type, Property_Set Properties_Type,
|
|
Property_Validator<Properties_Type> Validator_Type =
|
|
No_Property_Validator<Properties_Type>>
|
|
struct Renderable_Builder {
|
|
using Product = Product_Type;
|
|
using Properties = Properties_Type;
|
|
using Validator = Validator_Type;
|
|
using Self = Renderable_Builder;
|
|
|
|
Renderable_Builder() requires std::default_initializable<Validator> = default;
|
|
|
|
template <auto Member,
|
|
Property_Member_Assignable<Properties, Member> Value>
|
|
Self& set(Value&& value) {
|
|
properties_.*Member = std::forward<Value>(value);
|
|
return *this;
|
|
}
|
|
|
|
template <Property_Configurator<Properties> Configure>
|
|
Self& configure(Configure&& configure) {
|
|
std::invoke(std::forward<Configure>(configure), properties_);
|
|
return *this;
|
|
}
|
|
|
|
Self& set_object_name(std::string name) {
|
|
object_name_ = std::move(name);
|
|
return *this;
|
|
}
|
|
|
|
[[nodiscard]] const Properties& properties_value() const noexcept {
|
|
return properties_;
|
|
}
|
|
|
|
template <class... Args>
|
|
[[nodiscard]] renderive_Owner<Product> build(Args&&... args) {
|
|
validator_(properties_);
|
|
auto result = renderive_Owner<Product>(
|
|
renderable_inheritance::Builder_Access::make<Product>(
|
|
std::forward<Args>(args)...));
|
|
renderable_inheritance::Builder_Access::initialize_state(
|
|
*result, std::move(properties_));
|
|
detail::Renderable_Build_Access::set_object_name(
|
|
*result, std::move(object_name_));
|
|
return result;
|
|
}
|
|
|
|
private:
|
|
Properties properties_{};
|
|
[[no_unique_address]] Validator validator_{};
|
|
std::string object_name_;
|
|
};
|
|
} // namespace renderive
|