NAP
Public Member Functions | Protected Types | Protected Member Functions | List of all members
LinkResolver Class Referenceabstract

#include <rtti/linkresolver.h>

Public Member Functions

virtual ~LinkResolver ()=default
 
bool resolveLinks (const UnresolvedPointerList &unresolvedPointers, utility::ErrorState &errorState)
 

Protected Types

enum  EInvalidLinkBehaviour { TreatAsError, Ignore }
 

Protected Member Functions

virtual ObjectfindTarget (const std::string &targetID)=0
 
virtual EInvalidLinkBehaviour onInvalidLink (const UnresolvedPointer &unresolvedPointer)=0
 

Description

Base class for resolving links after deserialization. The base class contains logic for determining target ID. The derived class should perform the lookup of the target object in its data structures. Custom pointers are supported through exposed RTTI functions on pointer objects: a static function 'translateTargetID' will convert any ID to a target ID and the member function 'assign' will assign the pointer value to the pointer object.

Inheritance diagram for LinkResolver:
[legend]

Member Enumeration Documentation

◆ EInvalidLinkBehaviour

enum EInvalidLinkBehaviour
strongprotected
Enumerator
TreatAsError 

When an invalid link is encountered, treat it as an error and do not continue.

Ignore 

When an invalid link is encountered, ignore it and continue resolving other links. Note that this leaves the pointer in an unresolved state, meaning it will be a nullptr.

Constructor & Destructor Documentation

◆ ~LinkResolver()

virtual ~LinkResolver ( )
virtualdefault

Member Function Documentation

◆ findTarget()

virtual Object* findTarget ( const std::string &  targetID)
protectedpure virtual

Called by resolveLinks to resolve a target ID to target object. Derived classes should implement this to perform the lookup.

Parameters
targetIDThe ID to resolve. This ID could be retrieved straight from deserialization or transformed through the static translateTargetID function on the type.
Returns
nullptr if the target could not be resolved, otherwise the resolved target object.

◆ onInvalidLink()

virtual EInvalidLinkBehaviour onInvalidLink ( const UnresolvedPointer unresolvedPointer)
protectedpure virtual

Called when an invalid link is encountered. The return value determines what kind of behavior to exhibit for an unresolved link.

Parameters
unresolvedPointerThe UnresolvedPointer that could not be resolved. Can be used to notify the user of this event
Returns
The behavior to exhibit for an unresolved link

◆ resolveLinks()

bool resolveLinks ( const UnresolvedPointerList unresolvedPointers,
utility::ErrorState errorState 
)

Performs the resolving of pointers. Will call findTarget for each pointer.

Parameters
unresolvedPointersThe pointers to resolve
errorStateContains error information if the function returns false.
Returns
true if link resolution succeeded, false if not.