61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
#pragma once
|
|
|
|
/// \file value.h
|
|
/// \author Folling <folling@ikarus.world>
|
|
|
|
/// \defgroup values Values
|
|
/// \brief Values are data in entities.
|
|
/// \details An entity is made up of any number of values.
|
|
/// Each value defines a certain aspect of an entity.
|
|
/// Values have a name, a type, and some data.
|
|
/// Examples of values would be:
|
|
/// - Is Dead (Toggle)
|
|
/// - Age (Number)
|
|
/// - ISBN (Text)
|
|
///
|
|
/// Values are either single or multiple.
|
|
/// We call this property "Cardinality" (\see IkarusValueCardinality)
|
|
/// because it's really hard to find a simpler name.
|
|
/// Each piece of data within a value is called a "datapoint".
|
|
/// Single values have exactly one datapoint, multiple values have any number of
|
|
/// datapoints. For example "Age" would be singular, while "Nicknames" would be
|
|
/// multiple. The type is unaffected by this. A pendant in programming languages
|
|
/// would be a List<T>. Note that all values are stored as a list of items,
|
|
/// even if the value is singular. Single values effectively act as a list with
|
|
/// one element. This is enforced by the API at runtime.
|
|
///
|
|
/// For a comprehensive list of value types, see \ref IkarusValueType.
|
|
/// @{
|
|
|
|
#include <ikarus/errors.h>
|
|
#include <ikarus/macros.h>
|
|
|
|
IKARUS_BEGIN_HEADER
|
|
|
|
/// \brief The common type for all value data.
|
|
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.
|
|
/// \remark Skipped if null.
|
|
/// \param number_visitor The function to call if the value is a number value.
|
|
/// \remark Skipped if null.
|
|
/// \param text_visitor The function to call if the value is a text value.
|
|
/// \remark Skipped if null.
|
|
/// \param data The data passed to the visitor functions.
|
|
/// \param error_out \see errors.h
|
|
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,
|
|
IkarusErrorData * error_out
|
|
);
|
|
|
|
IKARUS_END_HEADER
|
|
|
|
/// @}
|