载入中...
搜索中...
未找到
ReflectedPropertyModel.cpp
浏览该文件的文档.
123 if (sharedCode == "property_access.property.read-only") return "property_access.script.read-only";
155 : runtime_(&runtime), instance_(std::move(instance)), observers_(std::make_shared<ObserverState>()) {
173 descriptor.category = member.attrString("category", ownerClass(*runtime_, schema_.typeId, member.name));
192Value ReflectedPropertyModel::convertValue(const std::string &path, const ReflectedValue &value) const {
239 if (!descriptor) return rejected("property_access.script.missing", "Property is not reflected");
256 if (reflected.empty()) return rejected("property_access.script.type", "Unsupported property value type");
275 if (reflected.empty()) return rejected("property_access.script.type", "Unsupported property value type");
298 std::erase_if(state->entries, [id](const ObserverState::Entry &entry) { return entry.id == id; });
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:286
bool arrayRemove(const ssq::Object &instance, const std::string &name, size_t index) const
Removes one element of an array member (shifts the rest).
Definition Runtime.cpp:928
std::vector< ReflectedMember > reflectInstance(const ssq::Object &instance) const
Inspects a live instance: own + inherited members with current values.
Definition Runtime.cpp:710
ReflectedValue tableGet(const ssq::Object &instance, const std::string &name, const std::string &key) const
Value of a table member key; empty when missing.
Definition Runtime.cpp:977
bool writeProperty(const ssq::Object &instance, const std::string &name, const ReflectedValue &value) const
Writes one property of a live instance.
Definition Runtime.cpp:773
ssq::Object readObjectProperty(const ssq::Object &instance, const std::string &name) const
Reads a live object-valued property (nested instance).
Definition Runtime.cpp:832
bool tableRemove(const ssq::Object &instance, const std::string &name, const std::string &key) const
Removes a key from a table member.
Definition Runtime.cpp:1036
bool tableSet(const ssq::Object &instance, const std::string &name, const std::string &key, const ReflectedValue &value) const
Sets a key of a table member (creates the key when missing).
Definition Runtime.cpp:998
bool arrayAppend(const ssq::Object &instance, const std::string &name, const ReflectedValue &value) const
Appends an element to an array member.
Definition Runtime.cpp:911
std::string classNameOf(const ssq::Object &instance) const
Name of the script class of a live instance ("" when unknown).
Definition Runtime.cpp:1204
ReflectedValue readProperty(const ssq::Object &instance, const std::string &name) const
Reads one property of a live instance.
Definition Runtime.cpp:757
size_t arraySize(const ssq::Object &instance, const std::string &name) const
Element count of an array member (0 when missing/not an array).
Definition Runtime.cpp:851
bool arraySet(const ssq::Object &instance, const std::string &name, size_t index, const ReflectedValue &value) const
Replaces one element of an array member.
Definition Runtime.cpp:887
ReflectedValue arrayGet(const ssq::Object &instance, const std::string &name, size_t index) const
Element value of an array member; empty when out of range.
Definition Runtime.cpp:867
std::vector< std::string > tableKeys(const ssq::Object &instance, const std::string &name) const
String keys of a table member.
Definition Runtime.cpp:951
Move-only RAII token that owns one observer registration.
Definition Subscription.h:27
std::function< void(const PropertyChange &)> ChangeCallback
Definition PropertyAccess.h:185
~ReflectedPropertyModel() override
Reflected property model.
ReflectedPropertyModel(Runtime &runtime, ssq::Object instance)
Bind one live script instance to the shared property-access contract.
Definition ReflectedPropertyModel.cpp:154
Result< void > write(const std::string &path, const eve::Value &value) override
Writes .
Definition ReflectedPropertyModel.cpp:237
void rebuildSchema()
Rebuild reflection metadata after a script reload.
Definition ReflectedPropertyModel.cpp:162
void refresh()
Pull live values and notify observers for changed properties.
Definition ReflectedPropertyModel.cpp:302
Subscription subscribe(ChangeCallback callback) override
Subscribe.
Definition ReflectedPropertyModel.cpp:292
std::optional< eve::Value > read(const std::string &path) const override
Reads .
Definition ReflectedPropertyModel.cpp:232
Definition PropertyAccess.cpp:7
Result< void > rejected(std::string rule, std::string message, DiagnosticCode code=DiagnosticCode::PreconditionViolation)
Build a rejected write/validation result with a stable rule string.
Definition PropertyAccess.h:107
std::string_view diagnosticRule(const Diagnostic &diagnostic)
Return the projected property-access rule id, or empty when absent.
Definition PropertyAccess.h:125
eve::Subscription Subscription
Compatibility alias for the common observer lifetime token.
Definition PropertyAccess.h:174
@ EditorOnly
PropertyKind
Semantic property kind used by renderer-independent presenters.
Definition PropertyAccess.h:21
@ ReadOnlyText
enum EVENGINE_API_FOUNDATION ReflectedValueKind
Runtime value kind read from a live script instance slot.
Definition Runtime.h:114
Definition Container.h:602
Immutable notification emitted after a model property changes.
Definition PropertyAccess.h:160
One stable property description consumed by any UI shell.
Definition PropertyAccess.h:74
eve::OptionalRef< const PropertyDescriptor > find(const std::string &path) const
Find a property by stable path, or an empty immediate borrow.
Definition PropertyAccess.cpp:9
std::vector< PropertyDescriptor > properties
Definition PropertyAccess.h:91
Definition ReflectedPropertyModel.cpp:146
ChangeCallback callback
Definition ReflectedPropertyModel.cpp:148
Definition ReflectedPropertyModel.cpp:145
std::uint64_t nextId
Definition ReflectedPropertyModel.cpp:150
std::vector< Entry > entries
Definition ReflectedPropertyModel.cpp:151