libikarus/include/ikarus/values/value.h
Folling 03c18debec
move sub-functions of value impls to concrete types
Signed-off-by: Folling <mail@folling.io>
2025-01-01 14:07:47 +01:00

50 lines
1.9 KiB
C

#pragma once
/// \file value.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \defgroup values Values
/// \brief The values of properties.
/// \details Each entity has a value for each property it is associated with.
/// These value classes represent plain objects. They are not associated with any entity.
/// Each value may be undefined. \see IkarusProperty
/// Values are stored as lists. If a property is "singular" then its value is a list of size 1.
/// Values are typed, with types existing for each of the corresponding property types.
/// When setting values for a property the type must match the property type and the value must be valid under the property's
/// settings. \see PropertyType
/// @{
IKARUS_BEGIN_HEADER
/// \brief The common type for all values.
struct IkarusValue;
/// \brief Visits an entity value, calling the appropriate function for the value's type.
/// \param value The entity value to visit.
/// \pre \li Must not be null.
/// \param toggle_visitor The function to call if the value is a toggle value. Skipped if null.
/// \param number_visitor The function to call if the value is a number value. Skipped if null.
/// \param text_visitor The function to call if the value is a text value. Skipped if null.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_value_visit(
IkarusValue * value,
void (*toggle_visitor)(struct IkarusToggleValue *, void *),
void (*number_visitor)(struct IkarusNumberValue *, void *),
void (*text_visitor)(struct IkarusTextValue *, void *),
void * data
);
/// \see ikarus_value_visit
IKA_API void ikarus_value_visit_const(
IkarusValue const * value,
void (*toggle_visitor)(struct IkarusToggleValue const *, void *),
void (*number_visitor)(struct IkarusNumberValue const *, void *),
void (*text_visitor)(struct IkarusTextValue const *, void *),
void * data
);
IKARUS_END_HEADER
/// @}