Structure
DynamicEObject
A dynamic implementation of EObject that stores feature values generically.
struct DynamicEObject
Overview
This type provides a basic object implementation that can represent instances of any EClass. Feature values are stored in a dictionary and accessed reflectively.
Usage
In a complete EMF implementation, code generation would create specific typed classes for each EClass. This dynamic implementation serves as a fallback and for testing.
Example
let employeeClass = EClass(name: "Employee")
let nameAttr = EAttribute(name: "name", eType: stringType)
var employee = DynamicEObject(eClass: employeeClass)
employee.eSet(nameAttr, "Alice")
if let name = employee.eGet(nameAttr) as? EString {
print("Employee name: \(name)")
}
JSON Serialization
DynamicEObject conforms to Codable and can be serialized to/from JSON. The JSON format matches pyecore’s format:
{
"eClass": "http://package.uri#//ClassName",
"attributeName": "value",
"referenceName": { ... }
}
Topics
Operators
Compares two dynamic objects for equality.
Initializers
Creates a new dynamic object.
Instance Properties
Instance Methods
Reflectively retrieves the value of a feature by name.
Reflectively retrieves the value of a feature.
Checks whether a feature has been explicitly set.
Checks whether a feature has been explicitly set by name.
Reflectively sets the value of a feature.
Reflectively sets the value of a feature by name.
Unsets a feature by name, returning it to its default value.
Unsets a feature, returning it to its default value.
Get all feature names that have been set on this object.
Hashes the essential components of this object.
Type Aliases
The type of classifier for dynamic objects.