The ObjectPath class. More...

Detailed Description

The ObjectPath class.

A path in the QObject hierarchy, using names and identifiers. See {IdentifiedObject}.

If the object id is not known at compile time a path may be created using ObjectPath::pathFromObject.

Example:

ObjectPath p{ {"MyObject", 0}, {"SomeSubObjectInACollection", 27} };
The ObjectPath class.
Definition: ObjectPath.hpp:37

Note : this class is mostly superseded by Path<T> which adds type-safety.

Public Member Functions

QString toString () const noexcept
 
 ObjectPath (std::vector< ObjectIdentifier > vec) noexcept
 
 ObjectPath (std::initializer_list< ObjectIdentifier > lst) noexcept
 
 ObjectPath (const ObjectPath &obj) noexcept
 
 ObjectPath (ObjectPath &&obj) noexcept
 
ObjectPathoperator= (ObjectPath &&obj) noexcept
 
ObjectPathoperator= (const ObjectPath &obj) noexcept
 
template<class T >
T & find (const score::DocumentContext &ctx) const
 find the object described by the ObjectPath More...
 
template<class T >
T * try_find (const score::DocumentContext &ctx) const noexcept
 Tries to find an object. More...
 
const ObjectIdentifierVector & vec () const noexcept
 
ObjectIdentifierVector & vec () noexcept
 
void resetCache () const noexcept
 

Static Public Member Functions

static ObjectPath pathBetweenObjects (const QObject *const parent_obj, const QObject *target_object)
 

Friends

ObjectIdentifierVector::iterator begin (ObjectPath &path) noexcept
 
ObjectIdentifierVector::iterator end (ObjectPath &path) noexcept
 
bool operator== (const ObjectPath &lhs, const ObjectPath &rhs) noexcept
 
bool operator!= (const ObjectPath &lhs, const ObjectPath &rhs) noexcept
 

Member Function Documentation

◆ find()

template<class T >
T& ObjectPath::find ( const score::DocumentContext ctx) const
inline

find the object described by the ObjectPath

Returns
A pointer to the object, or nullptr if it is not found

This search starts from qApp.

Todo:

(maybe) a way to specify custom ways of finding an object (for instance if obj->blurb() == Ding::someDing)

search starting from another object, for more performance.

◆ try_find()

template<class T >
T* ObjectPath::try_find ( const score::DocumentContext ctx) const
inlinenoexcept

Tries to find an object.

Returns
null if the object does not exist.

The documentation for this class was generated from the following files: