1- // Copyright 2016-2023 the nyan authors, LGPLv3+. See copying.md for legal info.
1+ // Copyright 2016-2025 the nyan authors, LGPLv3+. See copying.md for legal info.
22#pragma once
33
44
5- #include < concepts>
65#include < deque>
76#include < memory>
87#include < sstream>
1110#include < vector>
1211
1312#include " api_error.h"
13+ #include " concept.h"
1414#include " config.h"
1515#include " object_notifier_types.h"
1616#include " util.h"
@@ -31,15 +31,6 @@ class Value;
3131class View ;
3232
3333
34- /* *
35- * Type that is either a nyan value or object.
36- * Object is not a value (ObjectValue is), but want to allow an
37- * overloaded conversion for direct object access.
38- */
39- template <typename T>
40- concept ValueLike = std::derived_from<T, Value> || std::is_same_v<T, Object>;
41-
42-
4334/* *
4435 * Handle for accessing a nyan object independent of time.
4536 */
@@ -105,7 +96,7 @@ class Object {
10596 *
10697 * @return Value of the member.
10798 */
108- template <ValueLike T>
99+ template <ValueOrObjectLike T>
109100 std::shared_ptr<T> get (const memberid_t &member, order_t t = LATEST_T) const ;
110101
111102 /* *
@@ -119,7 +110,7 @@ class Object {
119110 *
120111 * @return Value of the member.
121112 */
122- template <ValueLike T, bool may_be_none = true >
113+ template <ValueOrObjectLike T, bool may_be_none = true >
123114 std::optional<std::shared_ptr<T>> get_optional (const memberid_t &member, order_t t = LATEST_T) const ;
124115
125116 /* *
@@ -245,19 +236,30 @@ class Object {
245236 *
246237 * @return true if the member exists for this object, else false.
247238 */
239+ [[deprecated(" Use has_member(..) instead" )]]
248240 bool has (const memberid_t &member, order_t t = LATEST_T) const ;
249241
250242 /* *
251- * Check if this object is a child of the given parent at a given time.
243+ * Check if this object has a member with a given name at a given time.
244+ *
245+ * @param member Identifier of the member.
246+ * @param t Time for which the member existence is checked.
247+ *
248+ * @return true if the member exists for this object, else false.
249+ */
250+ bool has_member (const memberid_t &member, order_t t = LATEST_T) const ;
251+
252+ /* *
253+ * Check if this object is a descendant/child of the given object at a given time.
252254 *
253- * @param other_fqon Identifier of the suspected parent object.
255+ * @param other_fqon Identifier of the suspected parent/ancestor object.
254256 * @param t Time for which the relationship is checked.
255257 *
256- * @return true if the parent 's identifier equals this object's
257- * identifier or that of any of its (transitive) parents,
258- * else false
258+ * @return true if the ancestors 's identifier equals this object's
259+ * identifier or that of any of its (transitive) parents,
260+ * else false
259261 */
260- bool extends (fqon_t other_fqon, order_t t = LATEST_T) const ;
262+ bool extends (const fqon_t & other_fqon, order_t t = LATEST_T) const ;
261263
262264 /* *
263265 * Get the metadata information object for this object.
@@ -335,14 +337,14 @@ class Object {
335337};
336338
337339
338- template <ValueLike T>
340+ template <ValueOrObjectLike T>
339341std::shared_ptr<T> Object::get (const memberid_t &member, order_t t) const {
340342 auto ret = this ->get_optional <T, false >(member, t);
341343 return *ret;
342344}
343345
344346
345- template <ValueLike T, bool may_be_none>
347+ template <ValueOrObjectLike T, bool may_be_none>
346348std::optional<std::shared_ptr<T>> Object::get_optional (const memberid_t &member, order_t t) const {
347349 std::shared_ptr<Value> value = this ->get_value (member, t).get_ptr ();
348350 if constexpr (may_be_none) {
0 commit comments