Namespaces | |
instanceproperty | |
method | |
Classes | |
class | BinaryWriter |
class | DefaultLinkResolver |
struct | DeserializeResult |
class | Factory |
struct | FileLink |
class | IObjectCreator |
class | JSONWriter |
class | LinkResolver |
class | Object |
class | ObjectCreator |
struct | ObjectLink |
class | ObjectPtr |
class | ObjectPtrBase |
class | ObjectPtrManager |
class | Path |
class | PathElement |
struct | ReadState |
class | ResolvedPath |
class | ResolvedRTTIPathElement |
struct | UnresolvedPointer |
class | Writer |
Typedefs | |
using | OwnedObjectList = std::vector< std::unique_ptr< rtti::Object > > |
using | ObservedObjectList = std::vector< rtti::Object * > |
using | ObjectList = std::vector< Object * > |
using | ObjectSet = std::unordered_set< Object * > |
using | TypeInfo = rttr::type |
using | Enum = rttr::enumeration |
using | Property = rttr::property |
using | Variant = rttr::variant |
using | Instance = rttr::instance |
using | VariantArray = rttr::variant_array_view |
using | VariantMap = rttr::variant_associative_view |
using | UnresolvedPointerList = std::vector< UnresolvedPointer > |
Enumerations | |
enum | EPropertyValidationMode : uint8_t { DisallowMissingProperties, AllowMissingProperties } |
enum | EPointerPropertyMode : uint8_t { NoRawPointers, OnlyRawPointers, AllPointerTypes } |
enum | EPropertyMetaData : uint8_t { Default = 0, Required = 1, FileLink = 2, Embedded = 4, ReadOnly = 8 } |
enum | EPropertyFileType : uint8_t { Any = 0, Image = 1, FragShader = 2, VertShader = 3, ComputeShader = 4, Python = 5, Mesh = 6, Video = 7, ImageSequence = 8, Audio = 9, Font = 10 } |
enum | ETypeCheck : uint8_t { EXACT_MATCH, IS_DERIVED_FROM } |
Functions | |
bool NAPAPI | checkBinaryVersion (const std::string &path) |
bool NAPAPI | deserializeBinary (utility::MemoryStream &stream, Factory &factory, DeserializeResult &result, utility::ErrorState &errorState) |
bool NAPAPI | readBinary (const std::string &path, Factory &factory, DeserializeResult &result, utility::ErrorState &errorState) |
bool NAPAPI | deserializeJSON (const std::string &json, EPropertyValidationMode propertyValidationMode, EPointerPropertyMode pointerPropertyMode, Factory &factory, DeserializeResult &result, utility::ErrorState &errorState) |
bool NAPAPI | deserializeJSONFile (const std::string &path, EPropertyValidationMode propertyValidationMode, EPointerPropertyMode pointerPropertyMode, Factory &factory, DeserializeResult &result, utility::ErrorState &errorState) |
bool NAPAPI | deserializeObjects (const rapidjson::Value &jsonArray, EPropertyValidationMode propertyValidationMode, EPointerPropertyMode pointerPropertyMode, Factory &factory, DeserializeResult &result, utility::ErrorState &errorState) |
std::unique_ptr< nap::rtti::Object > NAPAPI | getObjectFromJSONFile (const std::string &path, EPropertyValidationMode propertyValidationMode, Factory &factory, utility::ErrorState &errorState) |
bool NAPAPI | JSONDocumentFromString (const std::string &json, rapidjson::Document &document, nap::utility::ErrorState &errorState) |
void NAPAPI | copyObject (const rtti::Object &srcObject, rtti::Object &dstObject) |
template<typename T > | |
std::unique_ptr< T > | cloneObject (const T &object, rtti::Factory &factory) |
bool NAPAPI | areObjectsEqual (const rtti::Object &objectA, const rtti::Object &objectB, const rtti::UnresolvedPointerList &unresolvedPointers=UnresolvedPointerList()) |
void NAPAPI | findFileLinks (const rtti::Object &object, std::vector< std::string > &fileLinks) |
void NAPAPI | findObjectLinks (const rtti::Object &object, std::vector< ObjectLink > &objectLinks) |
int NAPAPI | findUnresolvedPointer (const UnresolvedPointerList &unresolvedPointers, const Object *object, const rtti::Path &path) |
void NAPAPI | getPointeesRecursive (const rtti::Object &object, std::vector< rtti::Object * > &pointees) |
uint64_t NAPAPI | getRTTIVersion (const rtti::TypeInfo &type) |
void NAPAPI | getDerivedTypesRecursive (const rtti::TypeInfo &baseType, std::vector< rtti::TypeInfo > &types) |
EPropertyMetaData | operator& (EPropertyMetaData a, EPropertyMetaData b) |
EPropertyMetaData | operator| (EPropertyMetaData a, EPropertyMetaData b) |
bool | isPrimitive (const rtti::TypeInfo &type) |
bool | hasFlag (const rtti::Property &property, EPropertyMetaData flags) |
bool | isFileType (const rtti::Property &property, EPropertyFileType filetype) |
rttr::method | findMethodRecursive (const rtti::TypeInfo &type, const std::string &methodName) |
bool | isTypeMatch (const rtti::TypeInfo &typeA, const rtti::TypeInfo &typeB, ETypeCheck typeCheck) |
bool NAPAPI | serializeObjects (const ObjectList &rootObjects, Writer &writer, utility::ErrorState &errorState) |
bool NAPAPI | serializeObject (rtti::Object &object, Writer &writer, utility::ErrorState &errorState) |
Variables | |
constexpr char | gRTTIBinaryVersion [] = "RTTIBinary-1.1" |
using Enum = rttr::enumeration |
using Instance = rttr::instance |
using ObjectList = std::vector<Object*> |
using ObservedObjectList = std::vector<rtti::Object*> |
using OwnedObjectList = std::vector<std::unique_ptr<rtti::Object> > |
using Property = rttr::property |
using TypeInfo = rttr::type |
using UnresolvedPointerList = std::vector<UnresolvedPointer> |
using Variant = rttr::variant |
using VariantArray = rttr::variant_array_view |
using VariantMap = rttr::variant_associative_view |
|
strong |
The deserializer can operate in two modes: using only raw pointers or without any raw pointers at all. The main distinction between the two modes lie in hotloading: in the normal flow of operation, all objects are managed by ResourceManager and internally by ObjectPtrManager. These classes enable the hotloading of objects and they do so by patching internal pointers in non-raw pointers like ObjectPtr, ResourcePtr, ComponentPtr. In such situations, raw pointers are not allowed. However, ObjectPtr and alike are not thread-safe and they should only be used from the main thread. In cases where objects are deserialized directly without the use of ResourceManager, you can use raw pointers instead of ObjectPtr and alike. By enabling OnlyRawPointers or NoRawPointers, the deserializer verifies the correct use of all pointers throughout deserialization.
Enumerator | |
---|---|
NoRawPointers | Raw pointers cannot be used to point to other object, only ObjectPtr, ResourcePtr or ComponentPtr, otherwise an error will be returned. |
OnlyRawPointers | Only raw pointers can be used to point to other objects, an error will be returned in case of other pointer types. |
AllPointerTypes | All types of pointers are supported; no checking is done on raw or non-raw. |
|
strong |
If EPropertyMetaData::FileLink is set, you can provide a file type. Used for tooling.
Enumerator | |
---|---|
Any | Can point to any file, default. |
Image | Points to an image file, must be used with EPropertyMetaData::FileLink. |
FragShader | Points to a .vert file, must be used with EPropertyMetaData::FileLink. |
VertShader | Points to a .frag file, must be used with EPropertyMetaData::FileLink. |
ComputeShader | Points to a .comp file, must be used with EPropertyMetaData::FileLink. |
Python | Points to a .py file, must be used with EPropertyMetaData::FileLink. |
Mesh | Points to a .mesh file, must be used with EPropertyMetaData::FileLink. |
Video | Points to a video file, must be used with EPropertyMetaData::FileLink. |
ImageSequence | Points to a an image sequence, must be used with EPropertyMetaData::FileLink. |
Audio | Points to an audio file, must be used with EPropertyMetaData::FileLink. |
Font | Points to a true type font, must be used with EPropertyMetaData::FileLink. |
|
strong |
|
strong |
|
strong |
bool NAPAPI nap::rtti::areObjectsEqual | ( | const rtti::Object & | objectA, |
const rtti::Object & | objectB, | ||
const rtti::UnresolvedPointerList & | unresolvedPointers = UnresolvedPointerList() |
||
) |
Tests whether the attributes of two objects have the same values.
objectA | first object to compare attributes from. |
objectB | second object to compare attributes from. |
unresolvedPointers | list of unresolved pointers that should be used for pointer comparisons in case of unresolved pointers. |
bool NAPAPI nap::rtti::checkBinaryVersion | ( | const std::string & | path | ) |
Check whether the binary file at the specified path matches the current binary version (i.e. is up-to-date)
path | path to the binary file. |
std::unique_ptr<T> nap::rtti::cloneObject | ( | const T & | object, |
rtti::Factory & | factory | ||
) |
Creates a new object with the same attributes as it's source.
object | the object to copy rtti attributes from. |
factory | RTTI object factory. |
void NAPAPI nap::rtti::copyObject | ( | const rtti::Object & | srcObject, |
rtti::Object & | dstObject | ||
) |
Copies rtti attributes from one object to another.
srcObject | the object to copy attributes from |
dstObject | the target object |
bool NAPAPI nap::rtti::deserializeBinary | ( | utility::MemoryStream & | stream, |
Factory & | factory, | ||
DeserializeResult & | result, | ||
utility::ErrorState & | errorState | ||
) |
Deserialize a set of objects and their data from the specified stream
stream | the stream to deserialize from |
factory | the RTTI object factory. |
result | The result of the deserialization process |
errorState | contains the error if deserialization fails. |
bool NAPAPI nap::rtti::deserializeJSON | ( | const std::string & | json, |
EPropertyValidationMode | propertyValidationMode, | ||
EPointerPropertyMode | pointerPropertyMode, | ||
Factory & | factory, | ||
DeserializeResult & | result, | ||
utility::ErrorState & | errorState | ||
) |
Deserialize a set of objects and their data from the specified JSON string
json | The JSON string to deserialize |
propertyValidationMode | whether missing required properties should be treated as errors |
pointerPropertyMode | controls ownership of the created objects. Use 'NoRawPointers' in process and 'OnlyRawPointers' out of process. |
factory | RTTI object factory. |
result | the result of the deserialization operation |
errorState | contains the error when de-serialization fails. |
bool NAPAPI nap::rtti::deserializeJSONFile | ( | const std::string & | path, |
EPropertyValidationMode | propertyValidationMode, | ||
EPointerPropertyMode | pointerPropertyMode, | ||
Factory & | factory, | ||
DeserializeResult & | result, | ||
utility::ErrorState & | errorState | ||
) |
Read and deserialize a set of objects and their data from the specified JSON file
path | The JSON file to deserialize |
propertyValidationMode | Whether missing required properties should be treated as errors |
pointerPropertyMode | controls ownership of the created objects. Use 'NoRawPointers' in process and 'OnlyRawPointers' out of process. |
factory | RTTI object factory. |
result | The result of the deserialization operation |
errorState | contains the error when deserialization fails. |
bool NAPAPI nap::rtti::deserializeObjects | ( | const rapidjson::Value & | jsonArray, |
EPropertyValidationMode | propertyValidationMode, | ||
EPointerPropertyMode | pointerPropertyMode, | ||
Factory & | factory, | ||
DeserializeResult & | result, | ||
utility::ErrorState & | errorState | ||
) |
Deserialize a set of objects and their data from the specified JSON string
jsonArray | The JSON value to deserialize |
propertyValidationMode | whether missing required properties should be treated as errors |
pointerPropertyMode | controls ownership of the created objects. Use 'NoRawPointers' in process and 'OnlyRawPointers' out of process. |
factory | RTTI object factory. |
result | the result of the deserialization operation |
errorState | contains the error when de-serialization fails. |
void NAPAPI nap::rtti::findFileLinks | ( | const rtti::Object & | object, |
std::vector< std::string > & | fileLinks | ||
) |
Searches through object's rtti attributes for attribute that have the 'file link' tag.
object | object to find file links from. |
fileLinks | output array containing the filenames. |
rttr::method nap::rtti::findMethodRecursive | ( | const rtti::TypeInfo & | type, |
const std::string & | methodName | ||
) |
Finds method recursively in class and its base classes. Note: this should normally work through the regular rttr::get_method function, but this does not seem to work properly. This function is used as a workaround until we solve the issue.
void NAPAPI nap::rtti::findObjectLinks | ( | const rtti::Object & | object, |
std::vector< ObjectLink > & | objectLinks | ||
) |
Searches through object's rtti attributes for pointer attributes.
object | object to find file links from. |
objectLinks | output array containing the object links |
int NAPAPI nap::rtti::findUnresolvedPointer | ( | const UnresolvedPointerList & | unresolvedPointers, |
const Object * | object, | ||
const rtti::Path & | path | ||
) |
Helper to find the index of the unresolved pointer with the specified object and path combination
unresolvedPointers | The list of UnresolvedPointers to search in |
object | The object that the UnresolvedPointer originates in |
path | The path to the attribute on the object that the UnresolvedPointer originates in |
void NAPAPI nap::rtti::getDerivedTypesRecursive | ( | const rtti::TypeInfo & | baseType, |
std::vector< rtti::TypeInfo > & | types | ||
) |
Recursively get all types derived from the specified type (including the base type itself)
baseType | The type to use as base |
types | The resulting array of types |
std::unique_ptr<nap::rtti::Object> NAPAPI nap::rtti::getObjectFromJSONFile | ( | const std::string & | path, |
EPropertyValidationMode | propertyValidationMode, | ||
Factory & | factory, | ||
utility::ErrorState & | errorState | ||
) |
Read and deserialize the first rtti::object from a JSON file. Ownership is transferred.
path | location of the JSON file on disk. |
propertyValidationMode | property validation mode |
factory | RTTI object creation factory. |
errorState | contains the error if the operation fails. |
Read and deserialize the first rtti::object of type T from a JSON file. Ownership is transferred.
path | location of the JSON file on disk. |
propertyValidationMode | property validation mode |
factory | RTTI object creation factory. |
errorState | contains the error if the operation fails. |
void NAPAPI nap::rtti::getPointeesRecursive | ( | const rtti::Object & | object, |
std::vector< rtti::Object * > & | pointees | ||
) |
Recursively traverses pointers of the given object and puts them in pointees. Basically traverses the object graph beneath object.
object | The root object to start traversing pointers from. |
pointees | The resulting array of objects. |
uint64_t NAPAPI nap::rtti::getRTTIVersion | ( | const rtti::TypeInfo & | type | ) |
Calculate the version number of the specified type
type | The type to calculate the version number for |
bool nap::rtti::hasFlag | ( | const rtti::Property & | property, |
EPropertyMetaData | flags | ||
) |
Helper function to check whether a property has the specified flag set
bool nap::rtti::isFileType | ( | const rtti::Property & | property, |
EPropertyFileType | filetype | ||
) |
Helper function to check whether a property is associated with a specific type of file
bool nap::rtti::isPrimitive | ( | const rtti::TypeInfo & | type | ) |
Helper function to determine whether the specified type is a primitive type (i.e. int, float, string, etc)
bool nap::rtti::isTypeMatch | ( | const rtti::TypeInfo & | typeA, |
const rtti::TypeInfo & | typeB, | ||
ETypeCheck | typeCheck | ||
) |
Helper function to check whether two types match, based on a comparison mode
bool NAPAPI nap::rtti::JSONDocumentFromString | ( | const std::string & | json, |
rapidjson::Document & | document, | ||
nap::utility::ErrorState & | errorState | ||
) |
Parse JSON text from a read-only string.
json | string to parse |
document | output document |
errorState | contains the error if string can't be parsed |
EPropertyMetaData nap::rtti::operator& | ( | EPropertyMetaData | a, |
EPropertyMetaData | b | ||
) |
EPropertyMetaData nap::rtti::operator| | ( | EPropertyMetaData | a, |
EPropertyMetaData | b | ||
) |
bool NAPAPI nap::rtti::readBinary | ( | const std::string & | path, |
Factory & | factory, | ||
DeserializeResult & | result, | ||
utility::ErrorState & | errorState | ||
) |
Deserialize a set of objects and their data from the specified file
path | path to file. |
factory | the RTTI object factory. |
result | The result of the deserialization process. |
errorState | contains the error if deserialization fails. |
bool NAPAPI nap::rtti::serializeObject | ( | rtti::Object & | object, |
Writer & | writer, | ||
utility::ErrorState & | errorState | ||
) |
Serialize a single RTTI object. This function performs all the logic, including traversal. The actual writing is done by the 'type of writer passed in. Object is placed in the root of the document and is NOT part of an 'Objects' array. Use this function to write a single RTTI object, instead of multiple. The object cannot point to other root objects, embedded pointers are allowed.
rootObjects | the objects to write. |
writer | the rtti writer |
errorState | contains the error if writing fails |
bool NAPAPI nap::rtti::serializeObjects | ( | const ObjectList & | rootObjects, |
Writer & | writer, | ||
utility::ErrorState & | errorState | ||
) |
Serialize a set of objects using the given writer. This function performs all the logic, including traversal. The actual writing is done by the 'type of writer passed in. All objects are placed inside the 'Objects' array.
rootObjects | the objects to write. |
writer | the rtti writer |
errorState | contains the error if writing fails |
|
constexpr |