finalize schema/data setup
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
4d7bf09c4e
commit
954b8a11a3
89 changed files with 2324 additions and 6271 deletions
143
include/ikarus/objects/property.h
Normal file
143
include/ikarus/objects/property.h
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
#pragma once
|
||||
|
||||
/// \file property.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \defgroup properties Properties
|
||||
/// \brief Properties define the structure and types of data.
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Properties define the structure of blueprints.
|
||||
/// \details Each blueprint can have any number of properties.
|
||||
/// Every property has a type that identifies the kind of data that can be put
|
||||
/// in. This is the "base class" of properties. See the derived types (e.g.
|
||||
/// IkarusToggleProperty) for more information.
|
||||
///
|
||||
/// The following types currently exist:
|
||||
/// - Toggle: A true/false boolean-like value
|
||||
/// - Number: An arbitrary numeric value
|
||||
/// - Text: An arbitrary textual value
|
||||
///
|
||||
/// Property Examples:
|
||||
/// - Is Dead (Toggle)
|
||||
/// - Age (Number)
|
||||
/// - ISBN (Text)
|
||||
///
|
||||
/// Each entity associated with the property has a value for it.
|
||||
///
|
||||
/// \remark Values for properties are lazily created to save space.
|
||||
/// Fetching the value for some property of some entity will return the
|
||||
/// property's default value if none is specified.
|
||||
struct IkarusProperty;
|
||||
|
||||
/// \brief Flags for creating a property.
|
||||
enum IkarusPropertyCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusPropertyCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Create a new property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param schema The schema of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param flags Flags for creating the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or NULL if an error occurred.
|
||||
/// \remark Must only be deleted with #ikarus_property_delete.
|
||||
IKA_API IkarusProperty * ikarus_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusValueSchema * schema,
|
||||
IkarusPropertyCreateFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for deleting a property.
|
||||
enum IkarusPropertyDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusPropertyDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Delete a property.
|
||||
/// \param property The property to delete.
|
||||
/// \param flags Flags for deleting the property.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_delete(
|
||||
IkarusProperty * property,
|
||||
IkarusPropertyDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Get the project a property belongs to.
|
||||
/// \param property The property to get the project of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project the property belongs to or null if an error occurred.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API struct IkarusProject * ikarus_property_get_project(
|
||||
IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Get the name of a property.
|
||||
/// \param property The property to get the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name of the property or null if an error occurred.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API char const * ikarus_property_get_name(
|
||||
IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Get the schema of a property.
|
||||
/// \param property The property to get the schema of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The schema of the property or null if an error occurred.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API struct IkarusValueSchema * ikarus_property_get_schema(
|
||||
IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for setting the name of a property.
|
||||
enum IkarusPropertySetNameFlags {
|
||||
/// \brief No flags.
|
||||
IkarusPropertySetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Set the name of a property.
|
||||
/// \param property The property to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Ownership remains with the caller.
|
||||
IKA_API void ikarus_property_set_name(
|
||||
IkarusProperty * property,
|
||||
char const * name,
|
||||
IkarusPropertySetNameFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
Loading…
Add table
Add a link
Reference in a new issue