NAP
nap::rtti Namespace Reference

Namespaces

 detail
 

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
 
class  PythonClass
 
class  PythonModule
 
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 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,
  Python = 4, Mesh = 5, Video = 6, ImageSequence = 7,
  Audio = 8, Font = 9
}
 
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 readJSONFile (const std::string &path, EPropertyValidationMode propertyValidationMode, EPointerPropertyMode pointerPropertyMode, Factory &factory, DeserializeResult &result, 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 NAPAPI operator & (EPropertyMetaData a, EPropertyMetaData b)
 
EPropertyMetaData NAPAPI operator| (EPropertyMetaData a, EPropertyMetaData b)
 
bool NAPAPI isPrimitive (const rtti::TypeInfo &type)
 
bool NAPAPI hasFlag (const rtti::Property &property, EPropertyMetaData flags)
 
bool NAPAPI 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)
 

Typedef Documentation

◆ Instance

using Instance = rttr::instance

◆ ObjectList

using ObjectList = std::vector<Object*>

◆ ObjectSet

using ObjectSet = std::unordered_set<Object*>

◆ ObservedObjectList

using ObservedObjectList = std::vector<rtti::Object*>

◆ OwnedObjectList

using OwnedObjectList = std::vector<std::unique_ptr<rtti::Object> >

◆ Property

using Property = rttr::property

◆ TypeInfo

using TypeInfo = rttr::type

◆ UnresolvedPointerList

◆ Variant

using Variant = rttr::variant

◆ VariantArray

using VariantArray = rttr::variant_array_view

◆ VariantMap

using VariantMap = rttr::variant_associative_view

Enumeration Type Documentation

◆ EPointerPropertyMode

enum EPointerPropertyMode : uint8_t
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.

◆ EPropertyFileType

enum EPropertyFileType : uint8_t
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.

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.

◆ EPropertyMetaData

enum EPropertyMetaData : uint8_t
strong

Controls how an RTTI property is interpreted

Enumerator
Default 

Uses the (class) default if the property isn't set.

Required 

Load will fail if the property isn't set.

FileLink 

Defines a relationship with an external file.

Embedded 

An embedded pointer.

ReadOnly 

A read only property in Python.

◆ EPropertyValidationMode

enum EPropertyValidationMode : uint8_t
strong
Enumerator
DisallowMissingProperties 

When a required property is missing from the file, an error will be returned.

AllowMissingProperties 

When a required property is missing from the file, no errors will be returned.

◆ ETypeCheck

enum ETypeCheck : uint8_t
strong

Selects whether the type check should be an exact type match or whether the type should be derived from the given type.

Enumerator
EXACT_MATCH 

The type needs to be of the exact same kind.

IS_DERIVED_FROM 

The type is derived from the specified type.

Function Documentation

◆ areObjectsEqual()

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.

Parameters
objectAfirst object to compare attributes from.
objectBsecond object to compare attributes from.
unresolvedPointerslist of unresolved pointers that should be used for pointer comparisons in case of unresolved pointers.

◆ checkBinaryVersion()

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)

Parameters
pathpath to the binary file.
Returns
true if the binary versions of the types in the file are up-to-date, false if not.

◆ cloneObject()

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.

Parameters
objectthe object to copy rtti attributes from.
factoryRTTI object factory.
Returns
the cloned object

◆ copyObject()

void NAPAPI nap::rtti::copyObject ( const rtti::Object srcObject,
rtti::Object dstObject 
)

Copies rtti attributes from one object to another.

Parameters
srcObjectthe object to copy attributes from
dstObjectthe target object

◆ deserializeBinary()

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

Parameters
streamthe stream to deserialize from
factorythe RTTI object factory.
resultThe result of the deserialization process
errorStatecontains the error if deserialization fails.
Returns
true if deserialization succeeded, false if not. In case of failure, errorState contains detailed error info.

◆ deserializeJSON()

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

Parameters
jsonThe JSON to deserialize
propertyValidationModewhether missing required properties should be treated as errors
pointerPropertyModecontrols ownership of the created objects. Use 'NoRawPointers' in process and 'OnlyRawPointers' out of process.
factoryRTTI object factory.
resultthe result of the deserialization operation
errorStatecontains the error when de-serialization fails.
Returns
true if deserialization succeeded, false if not. In case of failure the errorState contains detailed error info.

◆ findFileLinks()

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.

Parameters
objectobject to find file links from.
fileLinksoutput array containing the filenames.

◆ findMethodRecursive()

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.

◆ findObjectLinks()

void NAPAPI nap::rtti::findObjectLinks ( const rtti::Object object,
std::vector< ObjectLink > &  objectLinks 
)

Searches through object's rtti attributes for pointer attributes.

Parameters
objectobject to find file links from.
objectLinksoutput array containing the object links

◆ findUnresolvedPointer()

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

Parameters
unresolvedPointersThe list of UnresolvedPointers to search in
objectThe object that the UnresolvedPointer originates in
pathThe path to the attribute on the object that the UnresolvedPointer originates in
Returns
The index of the UnresolvedPointer in the specified list. -1 if not found.

◆ getDerivedTypesRecursive()

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)

Parameters
baseTypeThe type to use as base
typesThe resulting array of types

◆ getPointeesRecursive()

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.

Parameters
objectThe root object to start traversing pointers from.
pointeesThe resulting array of objects.

◆ getRTTIVersion()

uint64_t NAPAPI nap::rtti::getRTTIVersion ( const rtti::TypeInfo type)

Calculate the version number of the specified type

Parameters
typeThe type to calculate the version number for
Returns
The version number

◆ hasFlag()

bool NAPAPI nap::rtti::hasFlag ( const rtti::Property property,
EPropertyMetaData  flags 
)

Helper function to check whether a property has the specified flag set

◆ isFileType()

bool NAPAPI nap::rtti::isFileType ( const rtti::Property property,
EPropertyFileType  filetype 
)

Helper function to check whether a property has the specified flag set

◆ isPrimitive()

bool NAPAPI 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)

◆ isTypeMatch()

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

◆ operator &()

EPropertyMetaData NAPAPI nap::rtti::operator& ( EPropertyMetaData  a,
EPropertyMetaData  b 
)

◆ operator|()

EPropertyMetaData NAPAPI nap::rtti::operator| ( EPropertyMetaData  a,
EPropertyMetaData  b 
)

◆ readBinary()

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

Parameters
pathpath to file.
factorythe RTTI object factory.
resultThe result of the deserialization process.
errorStatecontains the error if deserialization fails.
Returns
true if deserialization succeeded, false if not. In case of failure, errorState contains detailed error info.

◆ readJSONFile()

bool NAPAPI nap::rtti::readJSONFile ( 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

Parameters
pathThe JSON file to deserialize
propertyValidationModeWhether missing required properties should be treated as errors
pointerPropertyModecontrols ownership of the created objects. Use 'NoRawPointers' in process and 'OnlyRawPointers' out of process.
factoryRTTI object factory.
resultThe result of the deserialization operation
errorStatecontains the error when deserialization fails.
Returns
true if deserialization succeeded, false if not. In case of failure the errorState contains detailed error info.

◆ serializeObjects()

bool NAPAPI nap::rtti::serializeObjects ( const ObjectList rootObjects,
Writer writer,
utility::ErrorState errorState 
)

Serialize a set of objects to the specified writer. This function does all the traversal logic, the actual writing is done by the RTTIWriter passed in.