finalize schema/data setup
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
70820129ae
commit
195f51d3d0
89 changed files with 2324 additions and 6271 deletions
|
|
@ -5,5 +5,3 @@ file(
|
|||
)
|
||||
|
||||
set(INCLUDE_FILES ${FILES} PARENT_SCOPE)
|
||||
|
||||
add_subdirectory(ikarus)
|
||||
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(models)
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
/// \file errors.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup errors Errors
|
||||
/// \brief Error handling within libikarus
|
||||
/// \details Functions in Ikarus may fail. To report the type of failure all functions have an out parameter for the error.
|
||||
/// Upon erring the function will store relevant information about the error in the out parameter.
|
||||
/// If the out parameter is null nothing will be stored. This is not recommended as it essentially ignores errors.
|
||||
/// For the sake of simplicity we have avoided mechanisms that "force" clients to handle errors.
|
||||
/// Note that Ikarus does not check for null pointers. Passing null pointers to functions that do not explicitly state that they accept null
|
||||
/// pointers is undefined behaviour. This decision is done for the sake of brevity and readability. `project_get_name(project)` is also
|
||||
/// synonymous to `project->get_name()` in OOP languages, which shares the same semantics.
|
||||
/// Upon erring the function will store relevant information about the error in
|
||||
/// the out parameter. If the out parameter is null nothing will be stored. This
|
||||
/// is not recommended as it essentially ignores errors. For the sake of
|
||||
/// simplicity we have avoided mechanisms that "force" clients to handle errors.
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
|
@ -22,73 +20,77 @@ IKARUS_BEGIN_HEADER
|
|||
/// \remark Note that this doesn't show responsibility. An error with source "SubSystem" could still be the
|
||||
/// fault of libikarus, it just indicates where the error occurred.
|
||||
enum IkarusErrorInfo {
|
||||
/// \brief No error occurred.
|
||||
IkarusErrorInfo_None = 0x0,
|
||||
/// \brief The client misused the API.
|
||||
/// Example: Accessing a resource that does not exist.
|
||||
IkarusErrorInfo_Client_Misuse = 0x01000001,
|
||||
/// \brief The client provided a null value for a parameter that must not be null.
|
||||
/// Example: Passing null for `ikarus_project_get_name`
|
||||
IkarusErrorInfo_Client_InvalidNull = 0x01000002,
|
||||
/// \brief The client provided an index that was out of bounds for some array.
|
||||
/// Example: Passing the index 3 for an `IkarusToggleValue` with size 3.
|
||||
IkarusErrorInfo_Client_IndexOutOfBounds = 0x01000003,
|
||||
/// \brief The client provided a numeric value that was out of bounds
|
||||
/// Example: Passing the value 2^32 to an i32 (might be passed as a string).
|
||||
IkarusErrorInfo_Client_ValueOutOfBounds = 0x01000004,
|
||||
/// \brief The client provided invalid input that doesn't fit in any of the other categories.
|
||||
/// Example: Passing an empty/blank string for a string that must be non-empty/-blank.
|
||||
IkarusErrorInfo_Client_InvalidInput = 0x01000005,
|
||||
/// \brief The client provided valid data in an invalid format.
|
||||
/// Example: Passing a malformed JSON string.
|
||||
IkarusErrorInfo_Client_InvalidFormat = 0x01000006,
|
||||
/// \brief The client violated a constraint.
|
||||
/// \details This error is most likely caused by endusers.
|
||||
/// Example: A user tries to set the age of a character to an value outside of their specified range.
|
||||
IkarusErrorInfo_Client_ConstraintViolated = 0x10000007,
|
||||
/// \brief No error occurred.
|
||||
IkarusErrorInfo_None = 0x0,
|
||||
/// \brief The client misused the API.
|
||||
/// Example: Accessing a resource that does not exist.
|
||||
IkarusErrorInfo_Client_Misuse = 0x01000001,
|
||||
/// \brief The client provided a null value for a parameter that must not be null.
|
||||
/// Example: Passing null for `ikarus_project_get_name`
|
||||
IkarusErrorInfo_Client_InvalidNull = 0x01000002,
|
||||
/// \brief The client provided a non-existent resource.
|
||||
/// Example: Passing an entity to a function after it has been deleted.
|
||||
IkarusErrorInfo_Client_NonExistent = 0x01000003,
|
||||
/// \brief The client provided an index that was out of bounds for some array.
|
||||
/// Example: Passing the index 3 for an `IkarusToggleValue` with size 3.
|
||||
IkarusErrorInfo_Client_IndexOutOfBounds = 0x01000004,
|
||||
/// \brief The client provided a numeric value that was out of bounds
|
||||
/// Example: Passing the value 2^32 to an i32 (might be passed as a string).
|
||||
IkarusErrorInfo_Client_ValueOutOfBounds = 0x01000005,
|
||||
/// \brief The client provided invalid input that doesn't fit in any of the other categories.
|
||||
/// Example: Passing an empty/blank string for a string that must be
|
||||
/// non-empty/-blank.
|
||||
IkarusErrorInfo_Client_InvalidInput = 0x01000006,
|
||||
/// \brief The client provided valid data in an invalid format.
|
||||
/// Example: Passing a malformed JSON string.
|
||||
IkarusErrorInfo_Client_InvalidFormat = 0x01000007,
|
||||
/// \brief The client violated a constraint.
|
||||
/// \details This error is most likely caused by clients.
|
||||
/// Example: A user tries to set the age of a character to a value outside
|
||||
/// its specified range.
|
||||
IkarusErrorInfo_Client_ConstraintViolated = 0x10000008,
|
||||
|
||||
// 0x02 reserved for dependency errors
|
||||
// 0x02 reserved for dependency errors
|
||||
|
||||
/// \brief A file or directory already exists.
|
||||
IkarusErrorInfo_Filesystem_AccessIssue = 0x03000001,
|
||||
/// \brief A file was not found.
|
||||
IkarusErrorInfo_Filesystem_NotFound = 0x03000002,
|
||||
/// \brief A file or directory already exists.
|
||||
IkarusErrorInfo_Filesystem_AlreadyExists = 0x03000003,
|
||||
/// \brief Missing permissions to access a file or directory.
|
||||
IkarusErrorInfo_Filesystem_MissingPermissions = 0x03000004,
|
||||
/// \brief Insufficient space to perform an operation.
|
||||
IkarusErrorInfo_Filesystem_InsufficientSpace = 0x03000005,
|
||||
/// \brief A path is invalid.
|
||||
IkarusErrorInfo_Filesystem_InvalidPath = 0x03000006,
|
||||
/// \brief A file was not found.
|
||||
IkarusErrorInfo_Filesystem_NotFound = 0x03000001,
|
||||
/// \brief A file or directory already exists.
|
||||
IkarusErrorInfo_Filesystem_AlreadyExists = 0x03000002,
|
||||
/// \brief Missing permissions to access a file or directory.
|
||||
IkarusErrorInfo_Filesystem_MissingPermissions = 0x03000003,
|
||||
/// \brief Insufficient space to perform an operation.
|
||||
IkarusErrorInfo_Filesystem_InsufficientSpace = 0x03000004,
|
||||
/// \brief A path is invalid.
|
||||
IkarusErrorInfo_Filesystem_InvalidPath = 0x03000005,
|
||||
|
||||
/// \brief A database connection failed.
|
||||
IkarusErrorInfo_Database_ConnectionFailed = 0x04000001,
|
||||
/// \brief A database query failed.
|
||||
IkarusErrorInfo_Database_QueryFailed = 0x04000002,
|
||||
/// \brief A database migration failed.
|
||||
IkarusErrorInfo_Database_MigrationFailed = 0x04000003,
|
||||
/// \brief A database is in an invalid state. This indicates a corrupt project.
|
||||
/// Example: An entity is linked to a non-existant blueprint.
|
||||
IkarusErrorInfo_Database_InvalidState = 0x04000004,
|
||||
/// \brief A database connection failed.
|
||||
IkarusErrorInfo_Database_ConnectionFailed = 0x04000001,
|
||||
/// \brief A database query failed.
|
||||
IkarusErrorInfo_Database_QueryFailed = 0x04000002,
|
||||
/// \brief A database migration failed.
|
||||
IkarusErrorInfo_Database_MigrationFailed = 0x04000003,
|
||||
/// \brief A database is in an invalid state. This indicates a corrupt project.
|
||||
/// Example: An entity is linked to a non-existent blueprint.
|
||||
IkarusErrorInfo_Database_InvalidState = 0x04000004,
|
||||
|
||||
/// \brief A system call failed.
|
||||
IkarusErrorInfo_OS_SystemCallFailed = 0x05000001,
|
||||
/// \brief A system call returned an invalid value.
|
||||
IkarusErrorInfo_OS_InvalidReturnValue = 0x05000002,
|
||||
/// \brief An OOM error occurred.
|
||||
IkarusErrorInfo_OS_InsufficientMemory = 0x05000003,
|
||||
/// \brief A system call failed.
|
||||
IkarusErrorInfo_OS_SystemCallFailed = 0x05000001,
|
||||
/// \brief A system call returned an invalid value.
|
||||
IkarusErrorInfo_OS_InvalidReturnValue = 0x05000002,
|
||||
/// \brief An OOM error occurred.
|
||||
IkarusErrorInfo_OS_InsufficientMemory = 0x05000003,
|
||||
|
||||
/// \brief A datapoint within ikarus is invalid for the current state of the system.
|
||||
/// \details This differs from IkarusErrorInfo_Database_InvalidState in that the latter implies the database itself holds invalid state,
|
||||
/// whereas the former may imply that the state is ephemeral, e.g. data within a function.
|
||||
/// Example: The name of an object is found to be invalid UTF8.
|
||||
IkarusErrorInfo_LibIkarus_InvalidState = 0x06000001,
|
||||
/// \brief libikarus is unable to perform a certain operation that should succeed.
|
||||
IkarusErrorInfo_LibIkarus_CannotPerformOperation = 0x06000002,
|
||||
/// \brief libikarus is unable to perform a certain operation within a given timeframe.
|
||||
/// Example: A query takes longer than the timeout.
|
||||
IkarusErrorInfo_LibIkarus_Timeout = 0x06000003,
|
||||
/// \brief A datapoint within ikarus is invalid for the current state of the system.
|
||||
/// \details This differs from IkarusErrorInfo_Database_InvalidState in that the latter implies the database itself holds invalid state,
|
||||
/// whereas the former may imply that the state is ephemeral, e.g. data
|
||||
/// within a function.
|
||||
/// Example: The name of an object is found to be invalid UTF8.
|
||||
IkarusErrorInfo_LibIkarus_InvalidState = 0x06000001,
|
||||
/// \brief libikarus is unable to perform a certain operation that should succeed.
|
||||
IkarusErrorInfo_LibIkarus_CannotPerformOperation = 0x06000002,
|
||||
/// \brief libikarus is unable to perform a certain operation within a given timeframe.
|
||||
/// Example: A query takes longer than the timeout.
|
||||
IkarusErrorInfo_LibIkarus_Timeout = 0x06000003,
|
||||
};
|
||||
|
||||
/// \brief The maximum length of an error message.
|
||||
|
|
@ -96,17 +98,17 @@ enum IkarusErrorInfo {
|
|||
|
||||
/// \brief The data stored for an error
|
||||
struct IkarusErrorData {
|
||||
/// \brief The error type
|
||||
IkarusErrorInfo info;
|
||||
/// \brief The error type
|
||||
enum IkarusErrorInfo info;
|
||||
|
||||
char message[IKARUS_ERROR_DATA_MAX_MESSAGE_LIMIT];
|
||||
char message[IKARUS_ERROR_DATA_MAX_MESSAGE_LIMIT];
|
||||
};
|
||||
|
||||
/// \brief Gets the name of an error info.
|
||||
/// \param info The error info to get the name of.
|
||||
/// \return The name of the error info.
|
||||
/// \remark The returned pointer is valid for the lifetime of the program and must not be freed.
|
||||
IKA_API char const * ikarus_get_error_info_name(IkarusErrorInfo info);
|
||||
IKA_API char const * ikarus_error_info_get_name(enum IkarusErrorInfo info);
|
||||
|
||||
/// \brief Checks if an error data is a success.
|
||||
/// \param data The error data to check.
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
file(
|
||||
GLOB_RECURSE
|
||||
FLATBUFFER_SOURCES
|
||||
"*.fbs"
|
||||
)
|
||||
|
||||
foreach (FLATBUFFER_SOURCE IN LISTS ${FLATBUFFER_SOURCES})
|
||||
cmake_path(
|
||||
GET
|
||||
${FLATBUFFER_SOURCE}
|
||||
FILENAME
|
||||
FLATBUFFER_SOURCE_NAME
|
||||
)
|
||||
|
||||
string(
|
||||
CONCAT
|
||||
FLATBUFFER_GENERATED_SOURCE_NAME
|
||||
${FLATBUFFER_SOURCE_NAME}
|
||||
"_generated"
|
||||
)
|
||||
|
||||
cmake_path(
|
||||
REPLACE_EXTENSION
|
||||
${FLATBUFFER_GENERATED_SOURCE_NAME}
|
||||
".h"
|
||||
OUTPUT_VARIABLE
|
||||
FLATBUFFER_GENERATED_HEADER
|
||||
)
|
||||
|
||||
list(APPEND FLATBUFFER_GENERATED_HEADERS ${FLATBUFFER_GENERATED_HEADER})
|
||||
endforeach ()
|
||||
|
||||
add_custom_target(
|
||||
flatbuffer_headers
|
||||
COMMENT "Generating flatbuffer headers"
|
||||
DEPENDS ${FLATBUFFER_SOURCES}
|
||||
BYPRODUCTS ${FLATBUFFER_GENERATED_HEADERS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND flatc --cpp --cpp-std "c++17" ${FLATBUFFER_SOURCES}
|
||||
VERBATIM
|
||||
)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
include "property.fbs";
|
||||
|
||||
namespace Ikarus;
|
||||
|
||||
table Blueprint {
|
||||
id: int64;
|
||||
name: string;
|
||||
description: string;
|
||||
tags: [string];
|
||||
}
|
||||
|
||||
root_type Blueprint;
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_BLUEPRINT_IKARUS_H_
|
||||
#define FLATBUFFERS_GENERATED_BLUEPRINT_IKARUS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "property_generated.h"
|
||||
|
||||
namespace Ikarus {
|
||||
|
||||
struct Blueprint;
|
||||
struct BlueprintBuilder;
|
||||
|
||||
struct Blueprint FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef BlueprintBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ID = 4,
|
||||
VT_NAME = 6,
|
||||
VT_DESCRIPTION = 8,
|
||||
VT_TAGS = 10
|
||||
};
|
||||
int64_t id() const {
|
||||
return GetField<int64_t>(VT_ID, 0);
|
||||
}
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const ::flatbuffers::String *description() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_DESCRIPTION);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *tags() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_TAGS);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int64_t>(verifier, VT_ID, 8) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_DESCRIPTION) &&
|
||||
verifier.VerifyString(description()) &&
|
||||
VerifyOffset(verifier, VT_TAGS) &&
|
||||
verifier.VerifyVector(tags()) &&
|
||||
verifier.VerifyVectorOfStrings(tags()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct BlueprintBuilder {
|
||||
typedef Blueprint Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_id(int64_t id) {
|
||||
fbb_.AddElement<int64_t>(Blueprint::VT_ID, id, 0);
|
||||
}
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Blueprint::VT_NAME, name);
|
||||
}
|
||||
void add_description(::flatbuffers::Offset<::flatbuffers::String> description) {
|
||||
fbb_.AddOffset(Blueprint::VT_DESCRIPTION, description);
|
||||
}
|
||||
void add_tags(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags) {
|
||||
fbb_.AddOffset(Blueprint::VT_TAGS, tags);
|
||||
}
|
||||
explicit BlueprintBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Blueprint> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Blueprint>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Blueprint> CreateBlueprint(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> description = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags = 0) {
|
||||
BlueprintBuilder builder_(_fbb);
|
||||
builder_.add_id(id);
|
||||
builder_.add_tags(tags);
|
||||
builder_.add_description(description);
|
||||
builder_.add_name(name);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Blueprint::Traits {
|
||||
using type = Blueprint;
|
||||
static auto constexpr Create = CreateBlueprint;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Blueprint> CreateBlueprintDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
const char *name = nullptr,
|
||||
const char *description = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<::flatbuffers::String>> *tags = nullptr) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto description__ = description ? _fbb.CreateString(description) : 0;
|
||||
auto tags__ = tags ? _fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::String>>(*tags) : 0;
|
||||
return Ikarus::CreateBlueprint(
|
||||
_fbb,
|
||||
id,
|
||||
name__,
|
||||
description__,
|
||||
tags__);
|
||||
}
|
||||
|
||||
inline const Ikarus::Blueprint *GetBlueprint(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Ikarus::Blueprint>(buf);
|
||||
}
|
||||
|
||||
inline const Ikarus::Blueprint *GetSizePrefixedBlueprint(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Ikarus::Blueprint>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyBlueprintBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Ikarus::Blueprint>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedBlueprintBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Ikarus::Blueprint>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishBlueprintBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Blueprint> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedBlueprintBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Blueprint> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace Ikarus
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_BLUEPRINT_IKARUS_H_
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
include "value.fbs";
|
||||
include "property.fbs";
|
||||
include "blueprint.fbs";
|
||||
|
||||
namespace Ikarus;
|
||||
|
||||
table NamedValue {
|
||||
name: string (key);
|
||||
value: Ikarus.Value.Value;
|
||||
}
|
||||
|
||||
table PropertyValue {
|
||||
property_id: int64 (key);
|
||||
data: Ikarus.Value.Data;
|
||||
}
|
||||
|
||||
table Entity {
|
||||
id: int64;
|
||||
name: string;
|
||||
description: string;
|
||||
tags: [string];
|
||||
values: [NamedValue];
|
||||
property_values: [PropertyValue];
|
||||
}
|
||||
|
||||
root_type Entity;
|
||||
|
|
@ -1,398 +0,0 @@
|
|||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_ENTITY_IKARUS_H_
|
||||
#define FLATBUFFERS_GENERATED_ENTITY_IKARUS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "blueprint_generated.h"
|
||||
#include "property_generated.h"
|
||||
#include "value_generated.h"
|
||||
|
||||
namespace Ikarus {
|
||||
|
||||
struct NamedValue;
|
||||
struct NamedValueBuilder;
|
||||
|
||||
struct PropertyValue;
|
||||
struct PropertyValueBuilder;
|
||||
|
||||
struct Entity;
|
||||
struct EntityBuilder;
|
||||
|
||||
struct NamedValue FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef NamedValueBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NAME = 4,
|
||||
VT_VALUE = 6
|
||||
};
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
bool KeyCompareLessThan(const NamedValue * const o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
template<typename StringType>
|
||||
int KeyCompareWithValue(const StringType& _name) const {
|
||||
if (name()->c_str() < _name) return -1;
|
||||
if (_name < name()->c_str()) return 1;
|
||||
return 0;
|
||||
}
|
||||
const Ikarus::Value::Value *value() const {
|
||||
return GetPointer<const Ikarus::Value::Value *>(VT_VALUE);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_VALUE) &&
|
||||
verifier.VerifyTable(value()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct NamedValueBuilder {
|
||||
typedef NamedValue Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(NamedValue::VT_NAME, name);
|
||||
}
|
||||
void add_value(::flatbuffers::Offset<Ikarus::Value::Value> value) {
|
||||
fbb_.AddOffset(NamedValue::VT_VALUE, value);
|
||||
}
|
||||
explicit NamedValueBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<NamedValue> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<NamedValue>(end);
|
||||
fbb_.Required(o, NamedValue::VT_NAME);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<NamedValue> CreateNamedValue(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<Ikarus::Value::Value> value = 0) {
|
||||
NamedValueBuilder builder_(_fbb);
|
||||
builder_.add_value(value);
|
||||
builder_.add_name(name);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct NamedValue::Traits {
|
||||
using type = NamedValue;
|
||||
static auto constexpr Create = CreateNamedValue;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<NamedValue> CreateNamedValueDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *name = nullptr,
|
||||
::flatbuffers::Offset<Ikarus::Value::Value> value = 0) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
return Ikarus::CreateNamedValue(
|
||||
_fbb,
|
||||
name__,
|
||||
value);
|
||||
}
|
||||
|
||||
struct PropertyValue FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef PropertyValueBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_PROPERTY_ID = 4,
|
||||
VT_DATA_TYPE = 6,
|
||||
VT_DATA = 8
|
||||
};
|
||||
int64_t property_id() const {
|
||||
return GetField<int64_t>(VT_PROPERTY_ID, 0);
|
||||
}
|
||||
bool KeyCompareLessThan(const PropertyValue * const o) const {
|
||||
return property_id() < o->property_id();
|
||||
}
|
||||
int KeyCompareWithValue(int64_t _property_id) const {
|
||||
return static_cast<int>(property_id() > _property_id) - static_cast<int>(property_id() < _property_id);
|
||||
}
|
||||
Ikarus::Value::Data data_type() const {
|
||||
return static_cast<Ikarus::Value::Data>(GetField<uint8_t>(VT_DATA_TYPE, 0));
|
||||
}
|
||||
const void *data() const {
|
||||
return GetPointer<const void *>(VT_DATA);
|
||||
}
|
||||
template<typename T> const T *data_as() const;
|
||||
const Ikarus::Value::ToggleDataPoint *data_as_ToggleDataPoint() const {
|
||||
return data_type() == Ikarus::Value::Data::ToggleDataPoint ? static_cast<const Ikarus::Value::ToggleDataPoint *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::NumberDataPoint *data_as_NumberDataPoint() const {
|
||||
return data_type() == Ikarus::Value::Data::NumberDataPoint ? static_cast<const Ikarus::Value::NumberDataPoint *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::TextDataPoint *data_as_TextDataPoint() const {
|
||||
return data_type() == Ikarus::Value::Data::TextDataPoint ? static_cast<const Ikarus::Value::TextDataPoint *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::SimpleData *data_as_SimpleData() const {
|
||||
return data_type() == Ikarus::Value::Data::SimpleData ? static_cast<const Ikarus::Value::SimpleData *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::CombinedData *data_as_CombinedData() const {
|
||||
return data_type() == Ikarus::Value::Data::CombinedData ? static_cast<const Ikarus::Value::CombinedData *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ListData *data_as_ListData() const {
|
||||
return data_type() == Ikarus::Value::Data::ListData ? static_cast<const Ikarus::Value::ListData *>(data()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ComplexData *data_as_ComplexData() const {
|
||||
return data_type() == Ikarus::Value::Data::ComplexData ? static_cast<const Ikarus::Value::ComplexData *>(data()) : nullptr;
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int64_t>(verifier, VT_PROPERTY_ID, 8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DATA_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_DATA) &&
|
||||
VerifyData(verifier, data(), data_type()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Ikarus::Value::ToggleDataPoint *PropertyValue::data_as<Ikarus::Value::ToggleDataPoint>() const {
|
||||
return data_as_ToggleDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::NumberDataPoint *PropertyValue::data_as<Ikarus::Value::NumberDataPoint>() const {
|
||||
return data_as_NumberDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::TextDataPoint *PropertyValue::data_as<Ikarus::Value::TextDataPoint>() const {
|
||||
return data_as_TextDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::SimpleData *PropertyValue::data_as<Ikarus::Value::SimpleData>() const {
|
||||
return data_as_SimpleData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::CombinedData *PropertyValue::data_as<Ikarus::Value::CombinedData>() const {
|
||||
return data_as_CombinedData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ListData *PropertyValue::data_as<Ikarus::Value::ListData>() const {
|
||||
return data_as_ListData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ComplexData *PropertyValue::data_as<Ikarus::Value::ComplexData>() const {
|
||||
return data_as_ComplexData();
|
||||
}
|
||||
|
||||
struct PropertyValueBuilder {
|
||||
typedef PropertyValue Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_property_id(int64_t property_id) {
|
||||
fbb_.AddElement<int64_t>(PropertyValue::VT_PROPERTY_ID, property_id, 0);
|
||||
}
|
||||
void add_data_type(Ikarus::Value::Data data_type) {
|
||||
fbb_.AddElement<uint8_t>(PropertyValue::VT_DATA_TYPE, static_cast<uint8_t>(data_type), 0);
|
||||
}
|
||||
void add_data(::flatbuffers::Offset<void> data) {
|
||||
fbb_.AddOffset(PropertyValue::VT_DATA, data);
|
||||
}
|
||||
explicit PropertyValueBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<PropertyValue> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<PropertyValue>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<PropertyValue> CreatePropertyValue(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t property_id = 0,
|
||||
Ikarus::Value::Data data_type = Ikarus::Value::Data::NONE,
|
||||
::flatbuffers::Offset<void> data = 0) {
|
||||
PropertyValueBuilder builder_(_fbb);
|
||||
builder_.add_property_id(property_id);
|
||||
builder_.add_data(data);
|
||||
builder_.add_data_type(data_type);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct PropertyValue::Traits {
|
||||
using type = PropertyValue;
|
||||
static auto constexpr Create = CreatePropertyValue;
|
||||
};
|
||||
|
||||
struct Entity FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef EntityBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ID = 4,
|
||||
VT_NAME = 6,
|
||||
VT_DESCRIPTION = 8,
|
||||
VT_TAGS = 10,
|
||||
VT_VALUES = 12,
|
||||
VT_PROPERTY_VALUES = 14
|
||||
};
|
||||
int64_t id() const {
|
||||
return GetField<int64_t>(VT_ID, 0);
|
||||
}
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const ::flatbuffers::String *description() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_DESCRIPTION);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *tags() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_TAGS);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::NamedValue>> *values() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::NamedValue>> *>(VT_VALUES);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::PropertyValue>> *property_values() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::PropertyValue>> *>(VT_PROPERTY_VALUES);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int64_t>(verifier, VT_ID, 8) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_DESCRIPTION) &&
|
||||
verifier.VerifyString(description()) &&
|
||||
VerifyOffset(verifier, VT_TAGS) &&
|
||||
verifier.VerifyVector(tags()) &&
|
||||
verifier.VerifyVectorOfStrings(tags()) &&
|
||||
VerifyOffset(verifier, VT_VALUES) &&
|
||||
verifier.VerifyVector(values()) &&
|
||||
verifier.VerifyVectorOfTables(values()) &&
|
||||
VerifyOffset(verifier, VT_PROPERTY_VALUES) &&
|
||||
verifier.VerifyVector(property_values()) &&
|
||||
verifier.VerifyVectorOfTables(property_values()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct EntityBuilder {
|
||||
typedef Entity Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_id(int64_t id) {
|
||||
fbb_.AddElement<int64_t>(Entity::VT_ID, id, 0);
|
||||
}
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Entity::VT_NAME, name);
|
||||
}
|
||||
void add_description(::flatbuffers::Offset<::flatbuffers::String> description) {
|
||||
fbb_.AddOffset(Entity::VT_DESCRIPTION, description);
|
||||
}
|
||||
void add_tags(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags) {
|
||||
fbb_.AddOffset(Entity::VT_TAGS, tags);
|
||||
}
|
||||
void add_values(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::NamedValue>>> values) {
|
||||
fbb_.AddOffset(Entity::VT_VALUES, values);
|
||||
}
|
||||
void add_property_values(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::PropertyValue>>> property_values) {
|
||||
fbb_.AddOffset(Entity::VT_PROPERTY_VALUES, property_values);
|
||||
}
|
||||
explicit EntityBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Entity> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Entity>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Entity> CreateEntity(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> description = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::NamedValue>>> values = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Ikarus::PropertyValue>>> property_values = 0) {
|
||||
EntityBuilder builder_(_fbb);
|
||||
builder_.add_id(id);
|
||||
builder_.add_property_values(property_values);
|
||||
builder_.add_values(values);
|
||||
builder_.add_tags(tags);
|
||||
builder_.add_description(description);
|
||||
builder_.add_name(name);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Entity::Traits {
|
||||
using type = Entity;
|
||||
static auto constexpr Create = CreateEntity;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Entity> CreateEntityDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
const char *name = nullptr,
|
||||
const char *description = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<::flatbuffers::String>> *tags = nullptr,
|
||||
std::vector<::flatbuffers::Offset<Ikarus::NamedValue>> *values = nullptr,
|
||||
std::vector<::flatbuffers::Offset<Ikarus::PropertyValue>> *property_values = nullptr) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto description__ = description ? _fbb.CreateString(description) : 0;
|
||||
auto tags__ = tags ? _fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::String>>(*tags) : 0;
|
||||
auto values__ = values ? _fbb.CreateVectorOfSortedTables<Ikarus::NamedValue>(values) : 0;
|
||||
auto property_values__ = property_values ? _fbb.CreateVectorOfSortedTables<Ikarus::PropertyValue>(property_values) : 0;
|
||||
return Ikarus::CreateEntity(
|
||||
_fbb,
|
||||
id,
|
||||
name__,
|
||||
description__,
|
||||
tags__,
|
||||
values__,
|
||||
property_values__);
|
||||
}
|
||||
|
||||
inline const Ikarus::Entity *GetEntity(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Ikarus::Entity>(buf);
|
||||
}
|
||||
|
||||
inline const Ikarus::Entity *GetSizePrefixedEntity(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Ikarus::Entity>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyEntityBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Ikarus::Entity>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedEntityBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Ikarus::Entity>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishEntityBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Entity> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedEntityBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Entity> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace Ikarus
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_ENTITY_IKARUS_H_
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
include "value.fbs";
|
||||
|
||||
namespace Ikarus;
|
||||
|
||||
table Property {
|
||||
id: int64;
|
||||
name: string;
|
||||
description: string;
|
||||
tags: [string];
|
||||
value_schema: Ikarus.Value.Schema;
|
||||
default_value: Ikarus.Value.Data;
|
||||
}
|
||||
|
||||
root_type Property;
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_PROPERTY_IKARUS_H_
|
||||
#define FLATBUFFERS_GENERATED_PROPERTY_IKARUS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "value_generated.h"
|
||||
|
||||
namespace Ikarus {
|
||||
|
||||
struct Property;
|
||||
struct PropertyBuilder;
|
||||
|
||||
struct Property FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef PropertyBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ID = 4,
|
||||
VT_NAME = 6,
|
||||
VT_DESCRIPTION = 8,
|
||||
VT_TAGS = 10,
|
||||
VT_VALUE_SCHEMA_TYPE = 12,
|
||||
VT_VALUE_SCHEMA = 14,
|
||||
VT_DEFAULT_VALUE_TYPE = 16,
|
||||
VT_DEFAULT_VALUE = 18
|
||||
};
|
||||
int64_t id() const {
|
||||
return GetField<int64_t>(VT_ID, 0);
|
||||
}
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const ::flatbuffers::String *description() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_DESCRIPTION);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *tags() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_TAGS);
|
||||
}
|
||||
Ikarus::Value::Schema value_schema_type() const {
|
||||
return static_cast<Ikarus::Value::Schema>(GetField<uint8_t>(VT_VALUE_SCHEMA_TYPE, 0));
|
||||
}
|
||||
const void *value_schema() const {
|
||||
return GetPointer<const void *>(VT_VALUE_SCHEMA);
|
||||
}
|
||||
template<typename T> const T *value_schema_as() const;
|
||||
const Ikarus::Value::ConstantSchema *value_schema_as_ConstantSchema() const {
|
||||
return value_schema_type() == Ikarus::Value::Schema::ConstantSchema ? static_cast<const Ikarus::Value::ConstantSchema *>(value_schema()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::SimpleSchema *value_schema_as_SimpleSchema() const {
|
||||
return value_schema_type() == Ikarus::Value::Schema::SimpleSchema ? static_cast<const Ikarus::Value::SimpleSchema *>(value_schema()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::CombinedSchema *value_schema_as_CombinedSchema() const {
|
||||
return value_schema_type() == Ikarus::Value::Schema::CombinedSchema ? static_cast<const Ikarus::Value::CombinedSchema *>(value_schema()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ListSchema *value_schema_as_ListSchema() const {
|
||||
return value_schema_type() == Ikarus::Value::Schema::ListSchema ? static_cast<const Ikarus::Value::ListSchema *>(value_schema()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ComplexSchema *value_schema_as_ComplexSchema() const {
|
||||
return value_schema_type() == Ikarus::Value::Schema::ComplexSchema ? static_cast<const Ikarus::Value::ComplexSchema *>(value_schema()) : nullptr;
|
||||
}
|
||||
Ikarus::Value::Data default_value_type() const {
|
||||
return static_cast<Ikarus::Value::Data>(GetField<uint8_t>(VT_DEFAULT_VALUE_TYPE, 0));
|
||||
}
|
||||
const void *default_value() const {
|
||||
return GetPointer<const void *>(VT_DEFAULT_VALUE);
|
||||
}
|
||||
template<typename T> const T *default_value_as() const;
|
||||
const Ikarus::Value::ToggleDataPoint *default_value_as_ToggleDataPoint() const {
|
||||
return default_value_type() == Ikarus::Value::Data::ToggleDataPoint ? static_cast<const Ikarus::Value::ToggleDataPoint *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::NumberDataPoint *default_value_as_NumberDataPoint() const {
|
||||
return default_value_type() == Ikarus::Value::Data::NumberDataPoint ? static_cast<const Ikarus::Value::NumberDataPoint *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::TextDataPoint *default_value_as_TextDataPoint() const {
|
||||
return default_value_type() == Ikarus::Value::Data::TextDataPoint ? static_cast<const Ikarus::Value::TextDataPoint *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::SimpleData *default_value_as_SimpleData() const {
|
||||
return default_value_type() == Ikarus::Value::Data::SimpleData ? static_cast<const Ikarus::Value::SimpleData *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::CombinedData *default_value_as_CombinedData() const {
|
||||
return default_value_type() == Ikarus::Value::Data::CombinedData ? static_cast<const Ikarus::Value::CombinedData *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ListData *default_value_as_ListData() const {
|
||||
return default_value_type() == Ikarus::Value::Data::ListData ? static_cast<const Ikarus::Value::ListData *>(default_value()) : nullptr;
|
||||
}
|
||||
const Ikarus::Value::ComplexData *default_value_as_ComplexData() const {
|
||||
return default_value_type() == Ikarus::Value::Data::ComplexData ? static_cast<const Ikarus::Value::ComplexData *>(default_value()) : nullptr;
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int64_t>(verifier, VT_ID, 8) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_DESCRIPTION) &&
|
||||
verifier.VerifyString(description()) &&
|
||||
VerifyOffset(verifier, VT_TAGS) &&
|
||||
verifier.VerifyVector(tags()) &&
|
||||
verifier.VerifyVectorOfStrings(tags()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_VALUE_SCHEMA_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_VALUE_SCHEMA) &&
|
||||
VerifySchema(verifier, value_schema(), value_schema_type()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DEFAULT_VALUE_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_DEFAULT_VALUE) &&
|
||||
VerifyData(verifier, default_value(), default_value_type()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Ikarus::Value::ConstantSchema *Property::value_schema_as<Ikarus::Value::ConstantSchema>() const {
|
||||
return value_schema_as_ConstantSchema();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::SimpleSchema *Property::value_schema_as<Ikarus::Value::SimpleSchema>() const {
|
||||
return value_schema_as_SimpleSchema();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::CombinedSchema *Property::value_schema_as<Ikarus::Value::CombinedSchema>() const {
|
||||
return value_schema_as_CombinedSchema();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ListSchema *Property::value_schema_as<Ikarus::Value::ListSchema>() const {
|
||||
return value_schema_as_ListSchema();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ComplexSchema *Property::value_schema_as<Ikarus::Value::ComplexSchema>() const {
|
||||
return value_schema_as_ComplexSchema();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ToggleDataPoint *Property::default_value_as<Ikarus::Value::ToggleDataPoint>() const {
|
||||
return default_value_as_ToggleDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::NumberDataPoint *Property::default_value_as<Ikarus::Value::NumberDataPoint>() const {
|
||||
return default_value_as_NumberDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::TextDataPoint *Property::default_value_as<Ikarus::Value::TextDataPoint>() const {
|
||||
return default_value_as_TextDataPoint();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::SimpleData *Property::default_value_as<Ikarus::Value::SimpleData>() const {
|
||||
return default_value_as_SimpleData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::CombinedData *Property::default_value_as<Ikarus::Value::CombinedData>() const {
|
||||
return default_value_as_CombinedData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ListData *Property::default_value_as<Ikarus::Value::ListData>() const {
|
||||
return default_value_as_ListData();
|
||||
}
|
||||
|
||||
template<> inline const Ikarus::Value::ComplexData *Property::default_value_as<Ikarus::Value::ComplexData>() const {
|
||||
return default_value_as_ComplexData();
|
||||
}
|
||||
|
||||
struct PropertyBuilder {
|
||||
typedef Property Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_id(int64_t id) {
|
||||
fbb_.AddElement<int64_t>(Property::VT_ID, id, 0);
|
||||
}
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Property::VT_NAME, name);
|
||||
}
|
||||
void add_description(::flatbuffers::Offset<::flatbuffers::String> description) {
|
||||
fbb_.AddOffset(Property::VT_DESCRIPTION, description);
|
||||
}
|
||||
void add_tags(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags) {
|
||||
fbb_.AddOffset(Property::VT_TAGS, tags);
|
||||
}
|
||||
void add_value_schema_type(Ikarus::Value::Schema value_schema_type) {
|
||||
fbb_.AddElement<uint8_t>(Property::VT_VALUE_SCHEMA_TYPE, static_cast<uint8_t>(value_schema_type), 0);
|
||||
}
|
||||
void add_value_schema(::flatbuffers::Offset<void> value_schema) {
|
||||
fbb_.AddOffset(Property::VT_VALUE_SCHEMA, value_schema);
|
||||
}
|
||||
void add_default_value_type(Ikarus::Value::Data default_value_type) {
|
||||
fbb_.AddElement<uint8_t>(Property::VT_DEFAULT_VALUE_TYPE, static_cast<uint8_t>(default_value_type), 0);
|
||||
}
|
||||
void add_default_value(::flatbuffers::Offset<void> default_value) {
|
||||
fbb_.AddOffset(Property::VT_DEFAULT_VALUE, default_value);
|
||||
}
|
||||
explicit PropertyBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Property> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Property>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Property> CreateProperty(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> description = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> tags = 0,
|
||||
Ikarus::Value::Schema value_schema_type = Ikarus::Value::Schema::NONE,
|
||||
::flatbuffers::Offset<void> value_schema = 0,
|
||||
Ikarus::Value::Data default_value_type = Ikarus::Value::Data::NONE,
|
||||
::flatbuffers::Offset<void> default_value = 0) {
|
||||
PropertyBuilder builder_(_fbb);
|
||||
builder_.add_id(id);
|
||||
builder_.add_default_value(default_value);
|
||||
builder_.add_value_schema(value_schema);
|
||||
builder_.add_tags(tags);
|
||||
builder_.add_description(description);
|
||||
builder_.add_name(name);
|
||||
builder_.add_default_value_type(default_value_type);
|
||||
builder_.add_value_schema_type(value_schema_type);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Property::Traits {
|
||||
using type = Property;
|
||||
static auto constexpr Create = CreateProperty;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Property> CreatePropertyDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int64_t id = 0,
|
||||
const char *name = nullptr,
|
||||
const char *description = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<::flatbuffers::String>> *tags = nullptr,
|
||||
Ikarus::Value::Schema value_schema_type = Ikarus::Value::Schema::NONE,
|
||||
::flatbuffers::Offset<void> value_schema = 0,
|
||||
Ikarus::Value::Data default_value_type = Ikarus::Value::Data::NONE,
|
||||
::flatbuffers::Offset<void> default_value = 0) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto description__ = description ? _fbb.CreateString(description) : 0;
|
||||
auto tags__ = tags ? _fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::String>>(*tags) : 0;
|
||||
return Ikarus::CreateProperty(
|
||||
_fbb,
|
||||
id,
|
||||
name__,
|
||||
description__,
|
||||
tags__,
|
||||
value_schema_type,
|
||||
value_schema,
|
||||
default_value_type,
|
||||
default_value);
|
||||
}
|
||||
|
||||
inline const Ikarus::Property *GetProperty(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Ikarus::Property>(buf);
|
||||
}
|
||||
|
||||
inline const Ikarus::Property *GetSizePrefixedProperty(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Ikarus::Property>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyPropertyBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Ikarus::Property>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedPropertyBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Ikarus::Property>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishPropertyBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Property> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedPropertyBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Ikarus::Property> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace Ikarus
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_PROPERTY_IKARUS_H_
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
namespace Ikarus.Value;
|
||||
|
||||
table ToggleDataPoint {
|
||||
data: [bool];
|
||||
}
|
||||
|
||||
table NumberDataPoint {
|
||||
data: [double];
|
||||
}
|
||||
|
||||
table TextDataPoint {
|
||||
data: [string];
|
||||
}
|
||||
|
||||
union Data {
|
||||
ToggleDataPoint,
|
||||
NumberDataPoint,
|
||||
TextDataPoint,
|
||||
SimpleData,
|
||||
CombinedData,
|
||||
ListData,
|
||||
ComplexData
|
||||
}
|
||||
|
||||
union Schema {
|
||||
ConstantSchema,
|
||||
SimpleSchema,
|
||||
CombinedSchema,
|
||||
ListSchema,
|
||||
ComplexSchema
|
||||
}
|
||||
|
||||
table ConstantSchema {
|
||||
sub_schema: Schema;
|
||||
data: Data;
|
||||
}
|
||||
|
||||
table SimpleSchema {
|
||||
sub_schema: Schema;
|
||||
}
|
||||
|
||||
table SimpleData {
|
||||
data: Data;
|
||||
}
|
||||
|
||||
table CombinedSchema {
|
||||
schemas: [Schema];
|
||||
}
|
||||
|
||||
table CombinedData {
|
||||
data: [Data];
|
||||
}
|
||||
|
||||
table ListSchema {
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
table ListData {
|
||||
data: [Data];
|
||||
}
|
||||
|
||||
table NamedSchema {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
table ComplexSchema {
|
||||
schemas: [NamedSchema];
|
||||
}
|
||||
|
||||
table NamedData {
|
||||
name: string;
|
||||
data: Data;
|
||||
}
|
||||
|
||||
table ComplexData {
|
||||
data: [NamedData];
|
||||
}
|
||||
|
||||
table Value {
|
||||
schema: Schema;
|
||||
data: Data;
|
||||
}
|
||||
|
||||
root_type Value;
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
/// \file blueprint.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
|
@ -13,57 +13,113 @@
|
|||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Blueprints are templates for managing common properties of entities.
|
||||
/// \details A blueprint is a collection of properties which can be linked to entities.
|
||||
/// Each entity the blueprint is linked to will have values for the blueprints
|
||||
/// properties. Changes in blueprints will be reflected in all linked entities.
|
||||
/// \brief Templates for sharing common properties between entities.
|
||||
/// \details A blueprint allows sharing properties between entities.
|
||||
/// Each entity the blueprint is linked to will have a corresponding value for
|
||||
/// each of the blueprint's properties. Changes in blueprints will be reflected
|
||||
/// in all linked entities.
|
||||
struct IkarusBlueprint;
|
||||
|
||||
/// \brief Creates a blueprint.
|
||||
/// \param project The project the blueprint is part of.
|
||||
/// \brief Flags for creating a blueprint.
|
||||
enum IkarusBlueprintCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a new blueprint.
|
||||
/// \param project The project to create the blueprint in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the blueprint.
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusBlueprintCreateFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Deletes a blueprint.
|
||||
/// \brief Flags for creating a blueprint from an entity.
|
||||
enum IkarusBlueprintCreateFromEntityFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCreateFromEntityFlags_None = 0,
|
||||
/// \brief The default values of the properties will be set to the values of the source entity.
|
||||
IkarusBlueprintCreateFromEntityFlags_AdoptDefaultValues = 1 << 0,
|
||||
/// \brief The entity will be linked to the blueprint, and all values will be turned into properties.
|
||||
IkarusBlueprintCreateFromEntityFlags_LinkEntity = 1 << 1,
|
||||
};
|
||||
|
||||
/// \brief Creates a new blueprint from an entity.
|
||||
/// \details Each value of the entity will be copied into the blueprint as a property.
|
||||
/// \param entity The entity to create the blueprint from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create_from_entity(
|
||||
struct IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusBlueprintCreateFromEntityFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for copying a blueprint.
|
||||
enum IkarusBlueprintCopyFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCopyFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Copies a blueprint.
|
||||
/// \param blueprint The blueprint to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for copying the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The copied blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusBlueprint * ikarus_blueprint_copy(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusBlueprintCopyFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for deleting a blueprint.
|
||||
enum IkarusBlueprintDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes a blueprint, all associated properties, and their values.
|
||||
/// \param blueprint The blueprint to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for deleting the blueprint.
|
||||
/// \remark Must not be used after deletion.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The blueprint must not be accessed after deletion.
|
||||
IKA_API void ikarus_blueprint_delete(
|
||||
IkarusBlueprint * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusBlueprintDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the ID of a blueprint.
|
||||
/// \param blueprint The blueprint to get the ID of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The ID of the blueprint or 0 if an error occurs.
|
||||
IKA_API int64_t ikarus_blueprint_get_id(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the project a blueprint is part of.
|
||||
/// \brief Gets the project a blueprint belongs to.
|
||||
/// \param blueprint The blueprint to get the project of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project or null if an error occurs.
|
||||
IKA_API IkarusProject * ikarus_blueprint_get_project(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The project the blueprint belongs to.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API struct IkarusProject * ikarus_blueprint_get_project(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the name of a blueprint.
|
||||
|
|
@ -71,79 +127,84 @@ IKA_API IkarusProject * ikarus_blueprint_get_project(
|
|||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name or null if an error occurs.
|
||||
/// \return The name of the blueprint.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API char const * ikarus_blueprint_get_name(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for setting the name of a blueprint.
|
||||
enum IkarusBlueprintSetNameFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintSetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets the name of a blueprint.
|
||||
/// \param blueprint The blueprint to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_blueprint_set_name(
|
||||
IkarusBlueprint * blueprint,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusBlueprint * blueprint,
|
||||
char const * name,
|
||||
IkarusBlueprintSetNameFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the properties of a blueprint.
|
||||
/// \param blueprint The blueprint to get the properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param properties_out The buffer to write the properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of items in the returned array or undefined if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_blueprint_get_property_count
|
||||
IKA_API void ikarus_blueprint_get_properties(
|
||||
IkarusBlueprint const * blueprint,
|
||||
struct IkarusProperty ** properties_out,
|
||||
size_t properties_out_size,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The properties of the blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusProperty ** ikarus_blueprint_get_properties(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
size_t * size_out,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of properties of a blueprint.
|
||||
/// \param blueprint The blueprint to get the number of properties of.
|
||||
/// \param blueprint The blueprint to get the properties count of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of properties or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_property_count(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The number of properties of the blueprint or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_properties_count(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the linked entities of.
|
||||
/// \brief Gets all entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the entities of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param entities_out The buffer to write the entities to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param entities_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of items in the returned array or undefined if an error occurs.
|
||||
/// \remark Ignore if null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_blueprint_get_linked_entity_count
|
||||
IKA_API void ikarus_blueprint_get_linked_entities(
|
||||
IkarusBlueprint const * blueprint,
|
||||
struct IkarusEntity ** entities_out,
|
||||
size_t entities_out_size,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The entities linked to the blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusEntity ** ikarus_blueprint_get_entities(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
size_t * size_out,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the number of linked entities of.
|
||||
/// \param blueprint The blueprint to get the entities count of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of linked entities or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_linked_entity_count(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The number of entities linked to the blueprint or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_entities_count(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \file entity.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \defgroup entities Entities
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
|
|
@ -13,15 +13,13 @@
|
|||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
/// \details Entities store two data: A name and a set of values.
|
||||
/// The name identifies the entity but does not have to be unique. The values
|
||||
/// are the actual information of the entity.
|
||||
/// \details Entities store a number of values associated with a name or property.
|
||||
///
|
||||
/// For documentation on the types and layout of values \see Values.h.
|
||||
/// For documentation on the types and layout of values \see values.h.
|
||||
///
|
||||
/// Entities can be linked to blueprints.
|
||||
/// The entity has a (possibly uninitialized) value for each property of all
|
||||
/// blueprints it is linked to. \see Property.h \see Blueprint.h.
|
||||
/// blueprints it is linked to. \see property.h \see blueprint.h.
|
||||
///
|
||||
/// We distinguish between `EntityValues` and `EntityPropertyValues`.
|
||||
/// `EntityValues` are a direct part of the entity.
|
||||
|
|
@ -29,59 +27,89 @@ IKARUS_BEGIN_HEADER
|
|||
/// via a blueprint.
|
||||
struct IkarusEntity;
|
||||
|
||||
/// \brief Creates an entity.
|
||||
/// \param project The project the entity is part of.
|
||||
/// \brief Flags for creating an entity.
|
||||
enum IkarusEntityCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a new entity.
|
||||
/// \param project The project to create the entity in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created entity or null if an error occurs.
|
||||
IKA_API IkarusEntity * ikarus_entity_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusEntityCreateFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Deletes an entity.
|
||||
/// \brief Flags for deleting an entity.
|
||||
enum IkarusEntityDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes an entity and its values.
|
||||
/// \param entity The entity to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for deleting the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The entity must not be accessed after deletion.
|
||||
IKA_API void
|
||||
ikarus_entity_delete(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
IKA_API void ikarus_entity_delete(
|
||||
IkarusEntity * entity,
|
||||
IkarusEntityDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the id of an entity.
|
||||
/// \param entity The entity to get the id of.
|
||||
/// \brief Flags for copying an entity.
|
||||
enum IkarusEntityCopyFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityCopyFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Copies an entity.
|
||||
/// \param entity The entity to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for copying the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The id of the entity or 0 if an error occurs.
|
||||
IKA_API int64_t
|
||||
ikarus_entity_get_id(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
/// \return The copied entity or null if an error occurs.
|
||||
IKA_API IkarusEntity * ikarus_entity_copy(
|
||||
IkarusEntity * entity,
|
||||
IkarusEntityCopyFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the project an entity is part of.
|
||||
/// \brief Gets the project an entity belongs to.
|
||||
/// \param entity The entity 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 entity is part of or null if an error occurs.
|
||||
IKA_API IkarusProject * ikarus_entity_get_project(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
/// \return The project the entity belongs to.
|
||||
IKA_API struct IkarusProject *
|
||||
ikarus_entity_get_project(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the name of an entity.
|
||||
/// \param entity The entity 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 entity or null if an error occurs.
|
||||
IKA_API char const * ikarus_entity_get_name(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
/// \return The name of the entity.
|
||||
IKA_API char const *
|
||||
ikarus_entity_get_name(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Flags for setting the name of an entity.
|
||||
enum IkarusEntitySetNameFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets the name of an entity.
|
||||
/// \param entity The entity to set the name of.
|
||||
|
|
@ -89,73 +117,27 @@ IKA_API char const * ikarus_entity_get_name(
|
|||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the entity.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_set_name(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusEntitySetNameFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity is linked to a blueprint.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the entity is linked to the blueprint, false otherwise.
|
||||
IKA_API bool ikarus_entity_is_linked_to_blueprint(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \param entity The entity to link.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to link the entity to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is already linked to the blueprint.
|
||||
IKA_API void ikarus_entity_link_to_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Unlinks an entity from a blueprint.
|
||||
/// All values of the blueprints' properties will be deleted.
|
||||
/// \param entity The entity to unlink.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to unlink the entity from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is not linked to the blueprint.
|
||||
IKA_API void ikarus_entity_unlink_from_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets all blueprints an entity is linked to.
|
||||
/// \brief Gets the blueprints an entity is linked to.
|
||||
/// \param entity The entity to get the blueprints of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprints_out The buffer to write the blueprints to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param blueprints_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of blueprints in the returned array
|
||||
/// or undefined if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_entity_get_linked_blueprint_count
|
||||
IKA_API void ikarus_entity_get_linked_blueprints(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusBlueprint ** blueprints_out,
|
||||
size_t blueprints_out_size,
|
||||
IkarusErrorData * error_out
|
||||
IKA_API struct IkarusBlueprint ** ikarus_entity_get_linked_blueprints(
|
||||
IkarusEntity * entity,
|
||||
size_t * size_out,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of blueprints an entity is linked to.
|
||||
|
|
@ -163,156 +145,199 @@ IKA_API void ikarus_entity_get_linked_blueprints(
|
|||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of blueprints or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_linked_blueprint_count(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The number of linked blueprints or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_linked_blueprints_count(
|
||||
IkarusEntity * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity has a value with a given name.
|
||||
/// \param entity The entity to check.
|
||||
/// \brief Flags for linking an entity to a blueprint.
|
||||
enum IkarusEntityLinkBlueprintFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityLinkBlueprintFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \details An uninitialized (default) value is created for each property of the
|
||||
/// blueprint.
|
||||
/// \param entity The entity to link the blueprint to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to check.
|
||||
/// \param blueprint The blueprint to link to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \pre \li Must be in the same project as the entity.
|
||||
/// \remark If the entity is already linked to the blueprint, nothing happens.
|
||||
/// \param flags Flags for linking the entity to the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return False if the entity does not have a value associated with
|
||||
/// the name or if an error occurs, true otherwise.
|
||||
IKA_API bool ikarus_entity_has_value(
|
||||
IkarusEntity const * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
IKA_API void ikarus_entity_link_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusEntityLinkBlueprintFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of an entity.
|
||||
/// \brief Flags for unlinking an entity from a blueprint.
|
||||
enum IkarusEntityUnlinkBlueprintFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityUnlinkBlueprintFlags_None = 0,
|
||||
/// \brief Keep the values associated with the blueprint, transforming them into entity values.
|
||||
IkarusEntityUnlinkBlueprintFlags_KeepValues = 1,
|
||||
};
|
||||
|
||||
/// \brief Unlinks an entity from a blueprint.
|
||||
/// \details All values associated with the blueprint are deleted.
|
||||
/// \param entity The entity to unlink the blueprint from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to unlink from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \remark If the entity is not linked to the blueprint, nothing happens.
|
||||
/// \param flags Flags for unlinking the entity from the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_unlink_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusEntityUnlinkBlueprintFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the values of an entity.
|
||||
/// \param entity The entity to get the values of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The values, in json format of or null if an error occurs.
|
||||
/// The json representation is an array of objects with the following keys:
|
||||
/// - `name`: The name of the value.
|
||||
/// - `value`: The value itself. \see value.h
|
||||
IKA_API char const *
|
||||
ikarus_entity_get_values(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets a value of an entity.
|
||||
/// \param entity The entity to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to get.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be an existing value of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The value's name.
|
||||
/// \pre \li Must not be null.
|
||||
/// \remark Ownership remains with the client.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value of the entity or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_entity_get_value(
|
||||
IkarusEntity const * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The value, in json format of or null if an error occurs. \see value.h
|
||||
IKA_API char const * ikarus_entity_get_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the value of an entity.
|
||||
/// If the entity does not have a value associated with the name, it is created.
|
||||
/// \remark Types are overwritten if the value already exists.
|
||||
/// \brief Flags for setting a value of an entity.
|
||||
enum IkarusEntitySetValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets a value of an entity.
|
||||
/// \details If no value exists for the name, a new one is created.
|
||||
/// Any previous value is overwritten.
|
||||
/// \param entity The entity to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to set.
|
||||
/// \param name The value's name.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param value The new value of the entity.
|
||||
/// \param value The value to set.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be a valid json representation of a value. \see value.h
|
||||
/// \param flags Flags for setting the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_set_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
struct IkarusValue const * value,
|
||||
IkarusErrorData * error_out
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
char const * value,
|
||||
IkarusEntitySetValueFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Removes a value from an entity.
|
||||
/// \pre \li The value must exist.
|
||||
/// \brief Flags for deleting a value of an entity.
|
||||
enum IkarusEntityDeleteValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityDeleteValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes a value of an entity.
|
||||
/// \param entity The entity to delete the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to delete.
|
||||
/// \param name The property's name to delete the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be the name of a value which exists within the property.
|
||||
/// \param flags Flags for deleting the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_remove_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
IKA_API void ikarus_entity_delete_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusEntityDeleteValueFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if a property is linked to an entity.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to check.
|
||||
/// \brief Gets the property values of an entity.
|
||||
/// \param entity The entity to get the property values of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return False if an error occurs or the entity does not have the property,
|
||||
/// true otherwise.
|
||||
IKA_API bool ikarus_entity_has_property(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty const * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the properties an entity is linked to.
|
||||
/// \param entity The entity to get the linked properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param properties_out The buffer to write the linked properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
/// \see ikarus_entity_get_property_count
|
||||
IKA_API void ikarus_entity_get_properties(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty ** properties_out,
|
||||
size_t properties_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of properties an entity is linked to.
|
||||
/// \param entity The entity to get the number of linked properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of properties or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_property_count(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The property values, in msgpack format of or null if an error occurs.
|
||||
/// The format is a map of property pointers (as integers) to values. \see
|
||||
/// value.h
|
||||
IKA_API char const * ikarus_entity_get_property_values(
|
||||
IkarusEntity * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of a property of an entity.
|
||||
/// \details If the entity has never set the value of the property,
|
||||
/// the property's default value is returned.
|
||||
/// \param entity The entity to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \pre \li Must be linked to the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value of the property or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_entity_get_property_value(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty const * property,
|
||||
IkarusErrorData * error_out
|
||||
/// \param entity The entity to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \pre \li Must be linked to the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value, in json format of or null if an error occurs. \see
|
||||
/// value.h
|
||||
IKA_API char const * ikarus_entity_get_property_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for setting the value of a property of an entity.
|
||||
enum IkarusEntitySetPropertyValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetPropertyValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets the value of a property of an entity.
|
||||
/// \param entity The entity to set the property value of.
|
||||
/// \details Any previous value is overwritten.
|
||||
/// \param entity The entity to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param value The new value of the property.
|
||||
/// \pre \li Must be linked to the entity.
|
||||
/// \param value The value to set.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be of the same type as the property.
|
||||
/// \pre \li Must be valid for the property's settings.
|
||||
/// \pre \li Must be a valid json representation of a value. \see value.h
|
||||
/// \pre \li Must be valid for the property's schema. \see schema.h
|
||||
/// \param flags Flags for setting the property value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark If the entity does not have the property, this function fails.
|
||||
IKA_API void ikarus_entity_set_property_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty const * property,
|
||||
struct IkarusValue const * value,
|
||||
IkarusErrorData * error_out
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty * property,
|
||||
char const * value,
|
||||
IkarusEntitySetPropertyValueFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file number_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Number properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusNumberProperty;
|
||||
|
||||
/// \brief Creates a number 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.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param default_value The default value for the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusNumberProperty * ikarus_number_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
struct IkarusNumberValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
#include <ikarus/values/value_type.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 Deletes a property.
|
||||
/// \param property The property to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The property must not be accessed after deletion.
|
||||
IKA_API void ikarus_property_delete(IkarusProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the ID of a property.
|
||||
/// \param property The property to get the ID of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The ID of the property or 0 if an error occurs.
|
||||
IKA_API int64_t ikarus_property_get_id(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the project of a property.
|
||||
/// \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 of the property or null if an error occurs.
|
||||
IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the name of an property.
|
||||
/// \param entity 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 occurs.
|
||||
IKA_API char const * ikarus_property_get_name(IkarusProperty const * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the name of an property.
|
||||
/// \param entity 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.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_set_name(IkarusProperty * entity, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the type info of a property.
|
||||
/// \param property The property to get the type info of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The type info of the property or null if an error occurs.
|
||||
/// \remark Changing the type of a property is not supported. This is because the property would need to change
|
||||
IKA_API IkarusValueType ikarus_property_get_type(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
// there is no `set_type` as we encode type information in the underlying datatype
|
||||
|
||||
/// \briefs Gets a property's cardinality.
|
||||
/// \param property The property to get the cardinality of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The cardinality of the property or false if an error occurs.
|
||||
IKA_API IkarusValueCardinality ikarus_property_get_cardinality(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \briefs Sets a property's default value.
|
||||
/// \param property The property to set the cardinality of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \\param cardinality The new cardinality of the property.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void
|
||||
ikarus_property_set_cardinality(IkarusProperty * property, IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
||||
|
||||
/// \briefs Gets a property's default value.
|
||||
/// \param property The property to get the default value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The default value of the property or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the source blueprint of a property.
|
||||
/// \param property The property to get the source of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The source of the property or null if an error occurs.
|
||||
IKA_API struct IkarusBlueprint * ikarus_property_get_blueprint(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits a property. Calling the appropriate function for the property's type.
|
||||
/// \param property The property to visit.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param toggle_property_visitor The function to call if the property is a toggle property. Skipped if null.
|
||||
/// \param number_property_visitor The function to call if the property is a number property. Skipped if null.
|
||||
/// \param text_property_visitor The function to call if the property is a text property. Skipped if null.
|
||||
/// \param data The data to pass to the functions.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_visit(
|
||||
IkarusProperty * property,
|
||||
void (*toggle_property_visitor)(struct IkarusToggleProperty *, void *),
|
||||
void (*number_property_visitor)(struct IkarusNumberProperty *, void *),
|
||||
void (*text_property_visitor)(struct IkarusTextProperty *, void *),
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file text_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Text properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusTextProperty;
|
||||
|
||||
/// \brief Creates a text 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.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param default_value The default value for the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusTextProperty * ikarus_text_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
struct IkarusTextValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file toggle_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Toggle properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
struct IkarusToggleProperty;
|
||||
|
||||
/// \brief Creates a toggle 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.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusToggleProperty * ikarus_toggle_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
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
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
/// \file project.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
|
@ -15,10 +17,19 @@
|
|||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief An Ikarus project.
|
||||
/// \details A project may only be open once at a time. Opening a project from two different locations Gets undefined
|
||||
/// \details A project may only be open once at a time.
|
||||
/// Opening a project from two different locations results in undefined
|
||||
/// behavior.
|
||||
struct IkarusProject;
|
||||
|
||||
/// \brief Flags for creating a project.
|
||||
enum IkarusProjectCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusProjectCreateFlags_None = 0,
|
||||
/// \brief Allow overwriting existing files.
|
||||
IkarusProjectCreateFlags_AllowOverwrite = 1 << 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a persisted project on the filesystem.
|
||||
/// \param path The path to the project.
|
||||
/// \pre \li Must not be null.
|
||||
|
|
@ -26,126 +37,168 @@ struct IkarusProject;
|
|||
/// \param name The name of the project. Must neither be null nor empty.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created project or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free. Freeing does not delete the project from the filesystem. For that, use
|
||||
/// ikarus_project_delete
|
||||
IKA_API IkarusProject * ikarus_project_create(
|
||||
char const * path,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
/// \remark Must be closed with #ikarus_project_close.
|
||||
IKA_API struct IkarusProject * ikarus_project_create(
|
||||
char const * path,
|
||||
char const * name,
|
||||
IkarusProjectCreateFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Creates a project in memory.
|
||||
/// \brief Flags for creating a project in memory.
|
||||
enum IkarusProjectCreateInMemoryFlags {
|
||||
/// \brief No flags.
|
||||
IkarusProjectCreateInMemoryFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a project in memory. The project is not persisted.
|
||||
/// \param name The name of the project. Must neither be null nor empty.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created project or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free. Freeing does not delete the project from the filesystem. For that, use
|
||||
/// ikarus_project_delete
|
||||
IKA_API IkarusProject *
|
||||
ikarus_project_create_in_memory(char const * name, IkarusErrorData * error_out);
|
||||
/// \remark Must be closed with #ikarus_project_close.
|
||||
IKA_API struct IkarusProject * ikarus_project_create_in_memory(
|
||||
char const * name,
|
||||
IkarusProjectCreateInMemoryFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for opening a project.
|
||||
enum IkarusProjectOpenFlags {
|
||||
/// \brief No flags.
|
||||
IkarusProjectOpenFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Opens an existing project.
|
||||
/// \param path The path to the project.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must point to an existing project on the system.
|
||||
/// \param flags Flags for opening the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The opened project or null if an error occurs.
|
||||
/// \remark Must be freed using ikarus_free. Freeing does not delete the project from the filesystem. For that, use
|
||||
/// ikarus_project_delete
|
||||
IKA_API IkarusProject *
|
||||
ikarus_project_open(char const * path, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the name of a project.
|
||||
/// \param project The project 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 project.
|
||||
/// \remark Ownership remains with libikarus, must not be freed.
|
||||
IKA_API char const * ikarus_project_get_name(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
/// \remark Must be closed with #ikarus_project_close.
|
||||
IKA_API struct IkarusProject * ikarus_project_open(
|
||||
char const * path,
|
||||
IkarusProjectOpenFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the name of a project.
|
||||
/// \param project The project to set the name of.
|
||||
/// \brief Flags for closing a project in memory.
|
||||
enum IkarusProjectCloseFlags {
|
||||
/// \brief No flags.
|
||||
IkarusProjectCloseFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Closes a project. This function must be called to free resources.
|
||||
/// \param project The project to close.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be open.
|
||||
/// \param flags Flags for closing the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The project must not be used after closing.
|
||||
/// \remark Does not delete the project from the filesystem.
|
||||
/// \remark Mutually exclusive with #ikarus_project_delete.
|
||||
IKA_API void ikarus_project_close(
|
||||
struct IkarusProject * project,
|
||||
IkarusProjectCloseFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for deleting a project.
|
||||
enum IkarusProjectDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusProjectDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes a project from the filesystem.
|
||||
/// \param project The project to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param new_name The new name of the project.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for deleting the project.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_project_set_name(
|
||||
IkarusProject * project,
|
||||
char const * new_name,
|
||||
IkarusErrorData * error_out
|
||||
/// \remark The project must not be used after deletion.
|
||||
/// \remark Mutually exclusive with #ikarus_project_close.
|
||||
IKA_API void ikarus_project_delete(
|
||||
struct IkarusProject * project,
|
||||
IkarusProjectDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the name of a project.
|
||||
/// \param project The project to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \returns The name of the project or null if an error occurs.
|
||||
IKA_API char const * ikarus_project_get_name(
|
||||
struct IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the path of a project.
|
||||
/// \param project The project to get the path of.
|
||||
/// \param project The project to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The path of the project.
|
||||
/// \remark Ownership remains with libikarus, must not be freed.
|
||||
/// \returns The path of the project or null if an error occurs.
|
||||
IKA_API char const * ikarus_project_get_path(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the entities of a project.
|
||||
/// \param project The project to get the entities of.
|
||||
/// \brief Gets all entities in a project.
|
||||
/// \param project The project from which to get the entities.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param entities_out The buffer to write the entities to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param entities_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of entities in the returned array
|
||||
/// or undefined if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_project_get_entities(
|
||||
IkarusProject * project,
|
||||
struct IkarusEntity ** entities_out,
|
||||
size_t entities_out_size,
|
||||
IkarusErrorData * error_out
|
||||
/// \returns An array of entities or null if an error occurs.
|
||||
IKA_API struct IkarusEntity ** ikarus_project_get_entities(
|
||||
struct IkarusProject const * project,
|
||||
size_t * size_out,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of entities of a project.
|
||||
/// \param project The project to get the number of entities of.
|
||||
/// \brief Gets how many entities in a project there are.
|
||||
/// \param project The project from which to get the count.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of entities or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_project_get_entity_count(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The count or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_project_get_entities_count(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the blueprints of a project.
|
||||
/// \param project The project to get the blueprints of.
|
||||
/// \brief Gets all blueprints from a project.
|
||||
/// \param project The project from which to get the blueprints.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprints_out The buffer to write the blueprints to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param blueprints_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of blueprints in the returned array
|
||||
/// or undefined if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_project_get_blueprints(
|
||||
IkarusProject * project,
|
||||
struct IkarusBlueprint ** blueprints_out,
|
||||
size_t blueprints_out_size,
|
||||
IkarusErrorData * error_out
|
||||
/// \return An array of blueprints or null if an error occurs.
|
||||
IKA_API struct IkarusBlueprint ** ikarus_project_get_blueprints(
|
||||
struct IkarusProject const * project,
|
||||
size_t * size_out,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of blueprints of a project.
|
||||
/// \param project The project to get the number of blueprints of.
|
||||
/// \brief Gets how many blueprints in a project there are.
|
||||
/// \param project The project from which to get the count.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of blueprints or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_project_get_blueprint_count(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
/// \return The count or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_project_get_blueprints_count(
|
||||
IkarusProject const * project,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
using std::size_t;
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
|
|
|||
48
include/ikarus/values/data.h
Normal file
48
include/ikarus/values/data.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \file data.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \addtogroup values Values
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Data stores the actual information of a value.
|
||||
/// \details Data is schemaless and can store any kind of data. Only when the
|
||||
/// data is combined with a schema does it become a value. \see value.h.
|
||||
/// Given the complexity of data, they are transferred as json.
|
||||
/// The json representation of a data is a map with the following keys:
|
||||
/// - `type` The type of the data. \see IkarusValueDataType. Must be one of the
|
||||
/// following:
|
||||
/// - `Primitive` A primitive value. Has two additional key:
|
||||
/// - `primitive` The type of the primitive. Must be one of the following:
|
||||
/// - `data` The stored data. Must be either a bool, double, or string.
|
||||
/// - `Constant` A constant value. Has no additional keys, as the constant
|
||||
/// value is shared across all values.
|
||||
/// - `List` A list of values. Has the following additional keys:
|
||||
/// - `data` An array of stored data.
|
||||
/// - `Map` A map of key-value pairs. Has the following additional keys:
|
||||
/// - `data` An array of key-value pairs.
|
||||
/// - `Tuple` A tuple of values. Has the following additional keys:
|
||||
/// - `data` An array of stored data.
|
||||
/// Note that each sub-data is also a data, allowing for arbitrarily nested data
|
||||
/// structures.
|
||||
struct IkarusValueData;
|
||||
|
||||
/// \brief The type of data.
|
||||
enum IkarusValueDataType {
|
||||
/// \brief A primitive value. \see IkarusValuePrimitiveType.
|
||||
IkarusValueDataType_Primitive = 1,
|
||||
/// \brief A list of values.
|
||||
IkarusValueDataType_List = 2,
|
||||
/// \brief A map of key-value pairs.
|
||||
IkarusValueDataType_Map = 3,
|
||||
/// \brief A tuple of values.
|
||||
IkarusValueDataType_Tuple = 4,
|
||||
};
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file number_value.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
|
||||
/// \addtogroup values Values
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A numeric value. For example "Age" or "Height".
|
||||
struct IkarusNumberValue;
|
||||
|
||||
/// \brief Creates an empty number value.
|
||||
/// \details If the cardinality is "Single", the value will be initialized with 0.0.
|
||||
/// \param cardinality The cardinality of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value or null if an error occurs.
|
||||
IKA_API IkarusNumberValue * ikarus_number_value_create(IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the underlying data of a number value at a specific index.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to fetch.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The underlying data or NaN if an error occurs.
|
||||
IKA_API double ikarus_number_value_get(IkarusNumberValue const * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the size of the underlying data of a number value.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The size of the underlying data or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_number_value_get_size(IkarusNumberValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the data of a number value at a specific index.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to set.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_number_value_set(IkarusNumberValue * value, size_t idx, double new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Inserts a data into a number value.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to insert.
|
||||
/// \pre \li Must be less than or equal to the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_number_value_insert(IkarusNumberValue * value, size_t idx, double new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Removes a data from a number value.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to remove.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_number_value_remove(IkarusNumberValue * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Clears a number value.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_number_value_clear(IkarusNumberValue * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a number value to a string.
|
||||
/// \param value The number value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted string.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API char const * ikarus_number_value_to_string(IkarusNumberValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Checks if two values are equal.
|
||||
/// \param lhs The left hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param rhs The right hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the values' data are equal, false otherwise.
|
||||
IKA_API bool ikarus_number_value_is_equal(IkarusNumberValue const * lhs, IkarusNumberValue const * rhs, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Creates a copy of a number value.
|
||||
/// \param value The value to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The copied value.
|
||||
IKA_API IkarusNumberValue * ikarus_number_value_copy(IkarusNumberValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a number value to an entity value.
|
||||
/// \param value The number value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted entity value.
|
||||
/// \remark This is the same pointer, so freeing it implies freeing the original value.
|
||||
IKA_API struct IkarusValueData * ikarus_number_value_to_value(IkarusNumberValue * value, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
58
include/ikarus/values/schema.h
Normal file
58
include/ikarus/values/schema.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#pragma once
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \file schema.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \addtogroup values Values
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Schemas define the type of value.
|
||||
/// \details Schemas are used to define the type of value. They are akin to
|
||||
/// classes in programming languages.
|
||||
/// Schemas are used to validate values and structure data.
|
||||
///
|
||||
/// Given the complexity of schemas, they are transferred as json.
|
||||
/// The json representation of a schema is a map with the following keys:
|
||||
/// - `type` The type of the schema. Must be one of the following:
|
||||
/// - `Primitive` A primitive value. Has the following additional keys:
|
||||
/// - `primitive` The type of the primitive value. \see IkarusPrimitiveType.
|
||||
/// - `Constant` A constant value. Has the following additional keys:
|
||||
/// - `value` The constant value, shared across all values of the schema.
|
||||
/// \see value.h. \remark The schema is derived from the value.
|
||||
/// - `List` A list of values. Has the following additional keys:
|
||||
/// - `schema` The schema of the values in the list.
|
||||
/// - `Map` A map of key-value pairs. Has the following additional keys:
|
||||
/// - `key_schema` The schema of the keys.
|
||||
/// - `value_schema` The schema of the values.
|
||||
/// - `Tuple` A tuple of values. Has the following additional keys:
|
||||
/// - `schemas` The schemas of the values in the tuple.
|
||||
struct IkarusSchema;
|
||||
|
||||
/// \brief The type of primitive data.
|
||||
enum IkarusValuePrimitiveType {
|
||||
/// \brief A boolean.
|
||||
IkarusValuePrimitiveType_Toggle = 1,
|
||||
/// \brief A 64-bit floating point number.
|
||||
IkarusValuePrimitiveType_Number = 2,
|
||||
/// \brief An arbitrary length string.
|
||||
IkarusValuePrimitiveType_Text = 3
|
||||
};
|
||||
|
||||
/// \brief The type of schema.
|
||||
enum IkarusValueSchemaType {
|
||||
/// \brief A primitive value. \see IkarusPrimitiveType
|
||||
IkarusValueSchemaType_Primitive = 1,
|
||||
/// \brief A homogeneous list of values.
|
||||
IkarusValueSchemaType_List = 2,
|
||||
/// \brief A mapping from Value->Value.
|
||||
IkarusValueSchemaType_Map = 3,
|
||||
/// \brief A heterogeneous list of values.
|
||||
IkarusValueSchemaType_Tuple = 4
|
||||
};
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file text_value.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
|
||||
/// \addtogroup values Values
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A numeric value. For example "Age" or "Height".
|
||||
struct IkarusTextValue;
|
||||
|
||||
/// \brief Creates an empty text value.
|
||||
/// \details If the cardinality is "Single", the value will be initialized with 0.0.
|
||||
/// \param cardinality The cardinality of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value or null if an error occurs.
|
||||
IKA_API IkarusTextValue * ikarus_text_value_create(IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the underlying data of a text value at a specific index.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to fetch.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The underlying data or NaN if an error occurs.
|
||||
IKA_API char const * ikarus_text_value_get(IkarusTextValue const * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the size of the underlying data of a text value.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The size of the underlying data or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_text_value_get_size(IkarusTextValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the data of a text value at a specific index.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to set.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_text_value_set(IkarusTextValue * value, size_t idx, char const * new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Inserts a data into a text value.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to insert.
|
||||
/// \pre \li Must be less than or equal to the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_text_value_insert(IkarusTextValue * value, size_t idx, char const * new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Removes a data from a text value.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to remove.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_text_value_remove(IkarusTextValue * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Clears a text value.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_text_value_clear(IkarusTextValue * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a text value to a string.
|
||||
/// \param value The text value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted string.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API char const * ikarus_text_value_to_string(IkarusTextValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Checks if two values are equal.
|
||||
/// \param lhs The left hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param rhs The right hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the values' data are equal, false otherwise.
|
||||
IKA_API bool ikarus_text_value_is_equal(IkarusTextValue const * lhs, IkarusTextValue const * rhs, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Creates a copy of a text value.
|
||||
/// \param value The value to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The copied value.
|
||||
IKA_API IkarusTextValue * ikarus_text_value_copy(IkarusTextValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a text value to an entity value.
|
||||
/// \param value The text value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted entity value.
|
||||
/// \remark This is the same pointer, so freeing it implies freeing the original value.
|
||||
IKA_API struct IkarusValueData * ikarus_text_value_to_value(IkarusTextValue * value, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file toggle_value.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
|
||||
/// \addtogroup values Values
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A numeric value. For example "Age" or "Height".
|
||||
struct IkarusToggleValue;
|
||||
|
||||
/// \brief Creates an empty toggle value.
|
||||
/// \details If the cardinality is "Single", the value will be initialized with 0.0.
|
||||
/// \param cardinality The cardinality of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value or null if an error occurs.
|
||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create(IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the underlying data of a toggle value at a specific index.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to fetch.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The underlying data or NaN if an error occurs.
|
||||
IKA_API bool ikarus_toggle_value_get(IkarusToggleValue const * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the size of the underlying data of a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The size of the underlying data or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_toggle_value_get_size(IkarusToggleValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the data of a toggle value at a specific index.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param idx The index of the data to set.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, size_t idx, bool new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Inserts a data into a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to insert.
|
||||
/// \pre \li Must be less than or equal to the size of the value.
|
||||
/// \param new_data The new data.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_toggle_value_insert(IkarusToggleValue * value, size_t idx, bool new_data, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Removes a data from a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param idx The index of the data to remove.
|
||||
/// \pre \li Must be less than the size of the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_toggle_value_remove(IkarusToggleValue * value, size_t idx, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Clears a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Cardinality must be "Multiple".
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_toggle_value_clear(IkarusToggleValue * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a toggle value to a string.
|
||||
/// \param value The toggle value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted string.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API char const * ikarus_toggle_value_to_string(IkarusToggleValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Checks if two values are equal.
|
||||
/// \param lhs The left hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param rhs The right hand side value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the values' data are equal, false otherwise.
|
||||
IKA_API bool ikarus_toggle_value_is_equal(IkarusToggleValue const * lhs, IkarusToggleValue const * rhs, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Creates a copy of a toggle value.
|
||||
/// \param value The value to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The copied value.
|
||||
IKA_API IkarusToggleValue * ikarus_toggle_value_copy(IkarusToggleValue const * value, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Converts a toggle value to an entity value.
|
||||
/// \param value The toggle value to convert.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The converted entity value.
|
||||
/// \remark This is the same pointer, so freeing it implies freeing the original value.
|
||||
IKA_API struct IkarusValueData * ikarus_toggle_value_to_value(IkarusToggleValue * value, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,61 +1,26 @@
|
|||
#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>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \file value.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \defgroup entities Entities
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
|
||||
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
|
||||
);
|
||||
/// \brief Values are data containers for entities.
|
||||
/// \details Values are flexible enough to store any kind of data. They are
|
||||
/// akin to objects in programming languages.
|
||||
/// Each value has a schema that defines the type of the value. \see schema.h
|
||||
/// They also store data appropriate for the schema.
|
||||
///
|
||||
/// Given the complexity of values, they are transferred as json.
|
||||
/// The json representation of a value is a map with the following keys:
|
||||
/// - `schema`: The schema of the value. \see schema.h.
|
||||
/// - `data`: The data of the value. \see data.h.
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file value_cardinality.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
/// \addtogroup values Values
|
||||
/// @{
|
||||
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief The cardinality of a value.
|
||||
enum IkarusValueCardinality {
|
||||
/// \brief Only contains one datapoint
|
||||
IkarusValueCardinality_Single,
|
||||
/// \brief Contains any number of datapoints
|
||||
IkarusValueCardinality_List
|
||||
};
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file value_schema.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
/// \addtogroup values Values
|
||||
/// @{
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Layouts define the structure and constraints of values.
|
||||
/// \details Ikarus lets you define any schema for values and add constraints to them.
|
||||
/// These schemas are assembled hierarchical and are akin to JSON schemas.
|
||||
/// Layouts may be arbitrarily nested and combined e.g.:
|
||||
/// Combination<List<Text>, Number, Complex<"Foo":Toggle,"Bar":Text>
|
||||
struct IkarusValueLayout;
|
||||
/// \brief A fixed datapoint with a fixed layout.
|
||||
/// Example: Age: Union<Number, Constant<Text, "Dead">>
|
||||
struct IkarusValueLayoutConstant;
|
||||
/// \brief A singular datapoint with one of a list of layouts.
|
||||
/// Example: ChestReward: Combination<Item, Gold, Mimic>
|
||||
struct IkarusValueLayoutCombination;
|
||||
/// \brief A collection of datapoints with a homogenous layout.
|
||||
/// Example: Friends: List<Character>
|
||||
struct IkarusValueLayoutList;
|
||||
/// \brief A collection of nameable datapoints with heterogeneous layouts.
|
||||
/// Example: GeoLocation: Complex<"Latitude":Number, "Longitude":Number>
|
||||
struct IkarusValueLayoutComplex;
|
||||
|
||||
/// \brief Defines the type of datapoints.
|
||||
enum IkarusValueDataType {
|
||||
/// \brief Boolean datapoints
|
||||
/// Example: Is the character alive? Yes
|
||||
Toggle,
|
||||
/// \brief Numeric datapoints
|
||||
/// Example: How much does the character weigh? 57kg
|
||||
Number,
|
||||
/// \brief Textual datapoints
|
||||
/// Example: What is the character's maiden name? Sandra
|
||||
Text,
|
||||
/// \brief A colour datapoint
|
||||
/// Example: What colours make up the nation's flag? White/Pink/Blue.
|
||||
/// \remark Not yet implemented
|
||||
Colour,
|
||||
/// \brief A date/time datapoint, interfacing with the calendar and timeline feature.
|
||||
/// Example: When was the city founded? 12th of January 233 at 2:11
|
||||
/// \remark Not yet implemented
|
||||
Time,
|
||||
/// \brief A location datapoint, interfacing with the map feature.
|
||||
/// Example: Where is the city situated? 12.345, 67.890
|
||||
/// \remark Not yet implemented
|
||||
Location,
|
||||
/// \brief An enum-esque datapoint
|
||||
/// Example: Of which rarity is the weapon? Normal/Rare/Legendary
|
||||
/// \remark Not yet implemented
|
||||
Choice,
|
||||
/// \brief A datapoint linking to some other object in Ikarus
|
||||
/// Example: Who wrote this hymn? Peter Parker
|
||||
/// \remark Not yet implemented
|
||||
Reference
|
||||
};
|
||||
|
||||
/// \brief Stores either a schema or a datatype
|
||||
struct IkarusValueSchema;
|
||||
|
||||
/// \see ikarus_value_schema_from_layout_const
|
||||
IkarusValueSchema * ikarus_value_schema_from_layout(
|
||||
IkarusValueLayout * layout,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Creates a value schema from a layout.
|
||||
/// \param layout The layout to create the schema from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created schema or null if an error occurs.
|
||||
IkarusValueSchema const * ikarus_value_schema_from_layout_const(
|
||||
IkarusValueLayout const * layout,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Creates a value schema from a datatype.
|
||||
/// \param type The datatype to create the schema from.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created schema or null if an error occurs.
|
||||
IkarusValueSchema * ikarus_value_schema_from_data_type(
|
||||
IkarusValueDataType type,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Frees a value schema.
|
||||
/// \param schema The schema to free.
|
||||
/// \pre \li Must not be null.
|
||||
/// \remark Must not be accessed after freeing.
|
||||
void ikarus_value_schema_free(IkarusValueSchema * schema);
|
||||
|
||||
/// \see ikarus_value_schema_visit_const
|
||||
void ikarus_value_schema_visit(
|
||||
IkarusValueSchema * schema,
|
||||
void (*layout_visitor)(IkarusValueLayout * layout),
|
||||
void (*data_type_visitor)(IkarusValueDataType type),
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Visits a value schema.
|
||||
/// \param schema The schema to visit.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param layout_visitor The function to call if the schema is a layout. Skipped if null.
|
||||
/// \param data_type_visitor The function to call if the schema is a datatype. Skipped if null.
|
||||
void ikarus_value_schema_visit_const(
|
||||
IkarusValueSchema const * schema,
|
||||
void (*layout_visitor)(IkarusValueLayout const * layout),
|
||||
void (*data_type_visitor)(IkarusValueDataType type),
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Creates a constant layout.
|
||||
/// \param schema The schema of the value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param value The value of the constant.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
IkarusValueLayoutConstant * ikarus_value_layout_constant_create(
|
||||
IkarusValueSchema * schema,
|
||||
struct IkarusValue * value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the underyling schema of a constant layout.
|
||||
/// \param layout The layout to get the underyling schema of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The underlying schema of the layout or null if an error occurs.
|
||||
IkarusValueSchema const * ikarus_value_layout_constant_get_underyling_schema(
|
||||
IkarusValueLayoutConstant const * layout,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the underyling value of a constant layout.
|
||||
/// \param layout The layout to get the underyling value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The underlying value of the layout or null if an error occurs.
|
||||
struct IkarusValue const * ikarus_value_layout_constant_get_underlying_value(
|
||||
IkarusValueLayoutConstant const * layout,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Creates a combination layout.
|
||||
/// \param schemas The schemas of the values.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param schemas_size The number of schemas.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created layout or null if an error occurs.
|
||||
/// \remark The schemas are copied.
|
||||
IkarusValueLayoutCombination * ikarus_value_layout_combination_create(
|
||||
IkarusValueSchema * schemas,
|
||||
size_t schemas_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
void ikarus_value_layout_combination_get_schemas(
|
||||
IkarusValueLayoutCombination const * layout,
|
||||
IkarusValueSchema ** schemas_out,
|
||||
size_t * schemas_size_out,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
size_t ikarus_value_layout_combination_get_schemas_count(
|
||||
IkarusValueLayoutCombination const * layout,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IkarusValueLayoutList * ikarus_value_layout_list_create(
|
||||
IkarusValueSchema * schema,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IkarusValueLayoutComplex * ikarus_value_layout_complex_create(
|
||||
IkarusValueSchema * schemas,
|
||||
size_t schemas_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IkarusValueLayoutComplex * ikarus_value_layout_complex_create_named(
|
||||
IkarusValueSchema * schemas,
|
||||
char const ** names,
|
||||
size_t schemas_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
module ikarus {
|
||||
header "ikarus/persistence/project.h"
|
||||
header "ikarus/objects/entity.h"
|
||||
header "ikarus/objects/blueprint.h"
|
||||
export *
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue