module
ReflectionProvides utilities useful for handling type-erased data.
Files
- file comparison.hpp
- Function cubos::
core:: reflection:: compare. - file cstring.hpp
- Reflection declaration for C-strings.
- file glm.hpp
- Reflection declarations for external glm types.
- file map.hpp
- Reflection declaration for
std::map
. - file primitives.hpp
- Reflection declarations for primitive types.
- file string.hpp
- Reflection declaration for
std::string
. - file string_view.hpp
- Reflection declaration for
std::string_view
. - file unordered_map.hpp
- Reflection declaration for
std::unordered_map
. - file uuid.hpp
- Reflection declaration for uuids::uuid.
- file vector.hpp
- Reflection declaration for
std::vector
. - file reflect.hpp
- Function cubos::
core:: reflection:: reflect and related macros. - file array.hpp
- Class cubos::
core:: reflection:: ArrayTrait. - file constructible.hpp
- Class cubos::
core:: reflection:: ConstructibleTrait. - file constructible_utils.hpp
- Utilities for cubos::
core:: reflection:: ConstructibleTrait. - file dictionary.hpp
- Class cubos::
core:: reflection:: DictionaryTrait. - file enum.hpp
- Class cubos::
core:: reflection:: EnumTrait. - file fields.hpp
- Class cubos::
core:: reflection:: FieldsTrait. - file inherits.hpp
- Class cubos::
core:: reflection:: InheritsTrait. - file mask.hpp
- Class cubos::
core:: reflection:: MaskTrait. - file nullable.hpp
- Class cubos::
core:: reflection:: NullableTrait. - file string_conversion.hpp
- Class cubos::
core:: reflection:: StringConversionTrait. - file type.hpp
- Class cubos::
core:: reflection:: Type. - file type_client.hpp
- Class cubos::
core:: reflection:: TypeClient. - file type_registry.hpp
- Class cubos::
core:: reflection:: TypeRegistry. - file type_server.hpp
- Class cubos::
core:: reflection:: TypeServer.
Classes
-
template<typename T>struct cubos::core::reflection::Reflect
- Defines the reflection function for the given type
T
. - class cubos::core::reflection::ArrayTrait
- Exposes array-like functionality of a type.
- class cubos::core::reflection::ConstructibleTrait
- Describes how a reflected type may be constructed and destructed.
- class cubos::core::reflection::DictionaryTrait
- Exposes dictionary-like functionality of a type.
- class cubos::core::reflection::EnumTrait
- Provides enumeration functionality to an enumerated type.
- class cubos::core::reflection::FieldsTrait
- Describes the fields of a reflected type.
- class cubos::core::reflection::InheritsTrait
- Provides inheritance relationship between types.
- class cubos::core::reflection::MaskTrait
- Provides mask functionality to an enum mask type.
- class cubos::core::reflection::NullableTrait
- Used to manipulate values of null-representable types.
- class cubos::core::reflection::StringConversionTrait
- Stores functions for converting a type to and from a string.
- class cubos::core::reflection::Type
- Describes a reflected type.
- class cubos::core::reflection::TypeClient
- Manages the client-side of a reflection channel on top of a stream.
- class cubos::core::reflection::TypeRegistry
- Stores a set of types which can be accessed by name.
- class cubos::core::reflection::TypeServer
- Used to setup a TypeChannel on top of a stream, from the server side.
Functions
-
auto makeAnonymousType(const char* name,
const char* file,
std::size_t size,
std::size_t alignment,
void(*)(void*) destructor) -> CUBOS_
CORE_ API const Type& - Creates a new reflection type with a unique name created from a type name and a file path, and with a minimal ConstructibleTrait.
-
template<typename T>auto reflect() -> const Type&
- Reflects the given type
T
. -
template<typename T>auto autoConstructibleTrait() -> ConstructibleTrait
- Returns a ConstructibleTrait with the default, copy and move constructors, set only if the type has them.
Defines
- #define CUBOS_PACK(...)
- Helper macro used to pass arguments with commas to other macros, wrapped in parentheses.
- #define CUBOS_REFLECT
- Declares the static reflection methods.
- #define CUBOS_REFLECT_IMPL(T)
- Defines a reflection method for a non-templated type.
- #define CUBOS_REFLECT_TEMPLATE_IMPL(args, T)
- Similar to CUBOS_
REFLECT_ IMPL but tailored to templated types. - #define CUBOS_REFLECT_EXTERNAL_DECL_TEMPLATE(api, T)
- Declares a specialization of cubos::
core:: reflection:: Reflect for a templated type. - #define CUBOS_REFLECT_EXTERNAL_DECL(api, T)
- Declares a specialization of cubos::
core:: reflection:: Reflect for a type. - #define CUBOS_REFLECT_EXTERNAL_IMPL(T)
- Implements a specialization of cubos::
core:: reflection:: Reflect for a type. - #define CUBOS_REFLECT_EXTERNAL_TEMPLATE(args, T)
- Both declares and implements a specialization of cubos::
core:: reflection:: Reflect for a type. - #define CUBOS_ANONYMOUS_REFLECT(...)
- Defines minimal reflection for a type private to a compilation unit.
Function documentation
CUBOS_ CORE_ API const Type& makeAnonymousType(const char* name,
const char* file,
std::size_t size,
std::size_t alignment,
void(*)(void*) destructor)
#include <core/reflection/reflect.hpp>
Creates a new reflection type with a unique name created from a type name and a file path, and with a minimal ConstructibleTrait.
Parameters | |
---|---|
name | Type name. |
file | Path of the file where the type is defined. |
size | Type size in bytes. |
alignment | Type alignment in bytes. |
destructor | Type destructor. |
#include <core/reflection/reflect.hpp>
template<typename T>
const Type& reflect()
Reflects the given type T
.
Template parameters | |
---|---|
T | Type to reflect. |
Returns | Type information. |
Fails to compile if the type does not implement reflection, or, in the case of external types, if its reflection specialization has not been included.
template<typename T>
ConstructibleTrait autoConstructibleTrait()
Returns a ConstructibleTrait with the default, copy and move constructors, set only if the type has them.
Template parameters | |
---|---|
T | Type. |
Returns | ConstructibleTrait. |
Define documentation
#define CUBOS_PACK(...)
#include <core/reflection/reflect.hpp>
Helper macro used to pass arguments with commas to other macros, wrapped in parentheses.
#define FOO(T) T foo; FOO(int); // expands to int foo; FOO(std::map<int, int>); // error: too many arguments to macro 'FOO' // Instead, use CUBOS_PACK: #define FOO(T) CUBOS_PACK T foo; FOO((int)); // expands to CUBOS_PACK(int) foo, which expands to int foo; FOO((std::map<int, int>)); // expands to CUBOS_PACK(std::map<int, int>) foo, which expands to // std::map<int, int> foo;
#define CUBOS_REFLECT
#include <core/reflection/reflect.hpp>
Declares the static reflection methods.
// my_type.hpp #include <cubos/core/reflection/reflect.hpp> struct MyType { // declares `static const Type& reflectGet()` and `static const Type& reflectMake()` CUBOS_REFLECT; };
#define CUBOS_REFLECT_IMPL(T)
#include <core/reflection/reflect.hpp>
Defines a reflection method for a non-templated type.
Parameters | |
---|---|
T | Type to reflect. |
// my_type.cpp #include "my_type.hpp" CUBOS_REFLECT_IMPL(MyType) // defines `const Type& MyType::reflectGet()` and `const Type& MyType::reflectMake()`. { return /* create your type here */; }
#define CUBOS_REFLECT_TEMPLATE_IMPL(args,
T)
#include <core/reflection/reflect.hpp>
Similar to CUBOS_
Parameters | |
---|---|
args | Template arguments. |
T | Type to reflect. |
// templated_type.cpp #include "templated_type.hpp" CUBOS_REFLECT_IMPL((typename T), (TemplatedType<T>)) { return /* create your type here */; }
#define CUBOS_REFLECT_EXTERNAL_DECL_TEMPLATE(api,
T)
#include <core/reflection/reflect.hpp>
Declares a specialization of cubos::
Parameters | |
---|---|
api | API macro to use. Set to CUBOS_ |
T | Type to reflect. |
// templated_type_reflection.hpp #include <cubos/core/reflection/reflect.hpp> template <typename T> CUBOS_REFLECT_EXTERNAL_DECL_TEMPLATE(TemplatedType<T>);
#define CUBOS_REFLECT_EXTERNAL_DECL(api,
T)
#include <core/reflection/reflect.hpp>
Declares a specialization of cubos::
Parameters | |
---|---|
api | API macro to use. Set to CUBOS_ |
T | Type to reflect. |
// not_my_type_reflection.hpp #include <cubos/core/reflection/reflect.hpp> CUBOS_REFLECT_EXTERNAL_DECL(CUBOS_CORE_API, NotMyType);
#define CUBOS_REFLECT_EXTERNAL_IMPL(T)
#include <core/reflection/reflect.hpp>
Implements a specialization of cubos::
Parameters | |
---|---|
T | Type to reflect. |
// not_my_type_reflection.cpp #include "not_my_type_reflection.hpp" CUBOS_REFLECT_EXTERNAL_IMPL(NotMyType) { return /* create your type here */; }
#define CUBOS_REFLECT_EXTERNAL_TEMPLATE(args,
T)
#include <core/reflection/reflect.hpp>
Both declares and implements a specialization of cubos::
Parameters | |
---|---|
args | Template parameters, wrapped in parentheses. |
T | Type to reflect, wrapped in parentheses. |
// templated_type_reflection.hpp #include <cubos/core/reflection/reflect.hpp> CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename T), (TemplatedType<T>)) { return /* create your type here */; }
#define CUBOS_ANONYMOUS_REFLECT(...)
#include <core/reflection/reflect.hpp>
Defines minimal reflection for a type private to a compilation unit.
Equivalent to CUBOS_
// my_type.cpp #include <cubos/core/reflection/reflect.hpp> namespace { struct State { CUBOS_ANONYMOUS_REFLECT(State); }; }