Documentation Language: Swift

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

?
init(id:eClass:)

Creates a new dynamic object.

Instance Properties

V
eClass

The class (metaclass) of this object.

V
id

Unique identifier for this object.

Instance Methods

F
eGet(_:)

Reflectively retrieves the value of a feature by name.

F
eGet(_:)

Reflectively retrieves the value of a feature.

F
eIsSet(_:)

Checks whether a feature has been explicitly set.

F
eIsSet(_:)

Checks whether a feature has been explicitly set by name.

F
eSet(_:_:)

Reflectively sets the value of a feature.

F
eSet(_:value:)

Reflectively sets the value of a feature by name.

F
eUnset(_:)

Unsets a feature by name, returning it to its default value.

F
eUnset(_:)

Unsets a feature, returning it to its default value.

F
getFeatureNames()

Get all feature names that have been set on this object.

F
hash(into:)

Hashes the essential components of this object.

Type Aliases

T
DynamicEObject.Classifier

The type of classifier for dynamic objects.

Default Implementations

Relationships

Conforms To

See Also

Core Types

P
EObject

Base protocol for all Ecore model elements.

S
EClass

A class in the Ecore metamodel.

S
EPackage

A package in the Ecore metamodel.