20 #ifndef ANTKEEPER_RENDER_MATERIAL_VARIABLE_HPP
21 #define ANTKEEPER_RENDER_MATERIAL_VARIABLE_HPP
51 [[nodiscard]] virtual std::
size_t size() const noexcept = 0;
99 [[nodiscard]] inline std::
size_t size() const noexcept
override
101 return elements.size();
104 [[nodiscard]]
inline std::unique_ptr<material_variable_base>
clone()
const override
106 return std::make_unique<material_variable<T>>(*this);
116 elements.front() = value;
127 elements[index] = value;
135 return elements.front();
147 return elements[index];
155 return elements.data();
159 std::vector<element_type> elements;
Abstract base class for material variables.
virtual constexpr material_variable_type type() const noexcept=0
Returns the material variable data type.
virtual std::size_t size() const noexcept=0
Returns the number of elements in an array variable, or 1 if the variable is not an array.
virtual std::unique_ptr< material_variable_base > clone() const =0
Creates a copy of this material property.
virtual ~material_variable_base()=default
Destructs a material variable base.
T element_type
Material variable element type.
void set(std::size_t index, const element_type &value)
Sets the value of a single element in an array variable.
material_variable(std::size_t size, const element_type &value=element_type())
Constructs a material variable.
const element_type * data() const noexcept
Returns a pointer to the element array.
material_variable(std::initializer_list< element_type > list)
Constructs a material variable from a list of element values.
const element_type & get(std::size_t index) const
Returns a reference to the element at a given index.
material_variable()
Constructs a material variable with a single element.
std::unique_ptr< material_variable_base > clone() const override
Creates a copy of this material property.
const element_type & get() const
Returns a reference to the first element in the array.
virtual constexpr material_variable_type type() const noexcept override
Returns the material variable data type.
void set(const element_type &value)
Sets the value of the the variable, or the value of the first element if the variable is an array.
material_variable_type
Material variable data types.