2 #include <score/model/path/ObjectIdentifier.hpp>
3 #include <score/tools/SafeCast.hpp>
9 #include <score_lib_base_export.h>
11 #include <initializer_list>
12 #include <type_traits>
16 struct DocumentContext;
38 friend ObjectIdentifierVector::iterator begin(
ObjectPath& path) noexcept
40 return path.m_objectIdentifiers.begin();
43 friend ObjectIdentifierVector::iterator end(
ObjectPath& path) noexcept
45 return path.m_objectIdentifiers.end();
50 return lhs.m_objectIdentifiers == rhs.m_objectIdentifiers;
55 return lhs.m_objectIdentifiers != rhs.m_objectIdentifiers;
61 QString toString()
const noexcept;
63 explicit ObjectPath(std::vector<ObjectIdentifier> vec) noexcept
64 : m_objectIdentifiers{std::move(vec)}
68 ObjectPath(std::initializer_list<ObjectIdentifier> lst) noexcept
69 : m_objectIdentifiers(lst)
74 : m_objectIdentifiers{obj.m_objectIdentifiers}
79 : m_objectIdentifiers{std::move(obj.m_objectIdentifiers)}
85 m_objectIdentifiers = std::move(obj.m_objectIdentifiers);
92 m_objectIdentifiers = obj.m_objectIdentifiers;
98 pathBetweenObjects(
const QObject*
const parent_obj,
const QObject* target_object);
113 if(!m_cache.isNull())
115 return *safe_cast<T*>(m_cache.data());
119 auto ptr = safe_cast<typename std::remove_const<T>::type*>(find_impl(ctx));
135 if(!m_cache.isNull())
137 return safe_cast<T*>(m_cache.data());
142 =
static_cast<typename std::remove_const<T>::type*
>(find_impl_unsafe(ctx));
153 const ObjectIdentifierVector& vec() const noexcept {
return m_objectIdentifiers; }
155 ObjectIdentifierVector& vec() noexcept {
return m_objectIdentifiers; }
157 void resetCache() const noexcept { m_cache = {}; }
166 ObjectIdentifierVector m_objectIdentifiers;
167 mutable QPointer<QObject> m_cache;
170 SCORE_LIB_BASE_EXPORT
void
172 inline uint qHash(
const ObjectPath& obj, uint seed)
174 return qHash(obj.toString(), seed);
187 std::size_t operator()(
const ObjectPath& path)
const;
The ObjectIdentifier class.
Definition: ObjectIdentifier.hpp:21
The ObjectPath class.
Definition: ObjectPath.hpp:37
T * try_find(const score::DocumentContext &ctx) const noexcept
Tries to find an object.
Definition: ObjectPath.hpp:131
T & find(const score::DocumentContext &ctx) const
find the object described by the ObjectPath
Definition: ObjectPath.hpp:110
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DocumentContext.hpp:18