Documentation Language: Swift

Class

Resource

A resource manages model objects and provides EMF-compliant reference resolution.

@globalActor actor Resource

Overview

Resources serve as containers for model objects, providing identity-based storage and resolution capabilities. They enable cross-reference resolution, URI-based addressing, and proper object lifecycle management following EMF patterns.

Thread Safety

Resources are thread-safe actors that manage concurrent access to model objects and provide atomic reference resolution operations.

Example

let resource = Resource(uri: "http://example.com/mymodel")

// Add objects to resource
let person = DynamicEObject(eClass: personClass)
resource.add(person)

// Resolve references by ID
if let resolved = resource.resolve(person.id) {
    print("Found object: \(resolved)")
}

Topics

Initializers

?
init(uri:enableDebugging:)

Initialises a new resource with the specified URI.

Instance Properties

V
debug

Enable debug output.

V
resourceSet

The resource set that owns this resource, if any.

V
uri

The URI identifying this resource.

Instance Methods

F
add(_:)

Adds an object to this resource.

F
clear()

Removes all objects from this resource.

F
contains(id:)

Checks if this resource contains an object with the specified identifier.

F
count()

Gets the number of objects in this resource.

F
createEAttribute(from:)

Create an EAttribute from a DynamicEObject with full cross-reference resolution.

F
createEClass(from:shouldIgnoreUnresolvedFeatures:)

Create an EClass from a DynamicEObject with full cross-reference resolution.

F
createEEnum(from:shouldIgnoreUnresolvedLiterals:)

Create an EEnum from a DynamicEObject with full cross-reference resolution.

F
createEPackage(from:shouldIgnoreUnresolvedClassifiers:)

Create an EPackage from a DynamicEObject with full cross-reference resolution.

F
createEReference(from:)

Create an EReference from a DynamicEObject with full cross-reference resolution.

F
eGet(objectId:feature:)

Gets a feature value from an object managed by this resource.

F
eSet(objectId:feature:value:)

Modifies a feature value on an object managed by this resource.

F
enableDebugging(_:)

Enable or disable debug mode.

F
getAllInstancesOf(_:)

Gets all instances of a specific EClass in this resource.

F
getAllObjects()

Gets all objects contained in this resource. Gets all objects in this resource in insertion order.

F
getFeatureNames(objectId:)

Get all feature names for an object

F
getObject(_:)

Gets an object by its ID, used for ATL lazy binding resolution.

F
getRootObjects()

Gets all root objects in this resource.

F
register(_:)

Registers an object with this resource without adding it as a root object.

F
remove(_:)

Removes an object from this resource.

F
remove(id:)

Removes an object from this resource by its identifier.

F
resolve(_:)

Resolves an object by its identifier.

F
resolve(_:as:)

Resolves an object by its identifier with a specific type.

F
resolveByPath(_:)

Resolves an object by its URI path within this resource.

F
resolveOpposite(_:)

Resolves the opposite reference for a bidirectional reference.

F
resolvePendingOppositeReferences()

Resolve pending opposite references after all EReference objects are created.

F
resolveReference(_:from:)

Resolves a reference to its target objects.

F
resolvingDataType(_:)

Resolve a data type reference for an EAttribute.

F
resolvingFeature(_:)

Resolve the concrete EStructuralFeature type from a DynamicEObject.

F
resolvingReferenceType(_:)

Resolve a reference type for an EReference.

F
resolvingType(_:)

Resolves the concrete EClassifier type from a DynamicEObject.

F
setResourceSet(_:)

Sets the resource set that owns this resource.

Type Properties

?
shared

Global resource actor for thread-safe operations.

Default Implementations

Relationships

Conforms To

See Also

Resources and Serialisation

?
ResourceSet

A resource set manages multiple resources and enables cross-resource reference resolution.

?
XMIParser

Parser for XMI (XML Metadata Interchange) files

S
XMISerializer

Serialises EMF objects to XMI (XML Metadata Interchange) format

?
JSONParser

Parser for JSON files in emfjson/pyecore format

S
JSONSerializer

Serializes EMF objects to JSON format (emfjson/pyecore compatible)