Documentation Language: Swift

Class

ResourceSet

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

@globalActor actor ResourceSet

Overview

ResourceSets provide a container for multiple resources, enabling complex models that span multiple files or logical units. They maintain a registry of metamodels by namespace URI and provide cross-resource reference resolution capabilities.

Thread Safety

ResourceSets are thread-safe actors that coordinate access to multiple resources and provide atomic cross-resource operations.

Example

let resourceSet = ResourceSet()

// Register a metamodel
resourceSet.registerMetamodel(companyPackage, uri: "http://company/1.0")

// Create resources
let modelResource = resourceSet.createResource(uri: "models/company.xmi")
let instanceResource = resourceSet.createResource(uri: "instances/acme.xmi")

// Cross-resource references are automatically resolved

Topics

Initializers

?
init()

Initialises a new resource set with empty registries.

Instance Methods

F
convertURI(_:)

Converts a logical URI to its physical equivalent.

F
count()

Gets the number of resources in this resource set.

F
createResource(uri:)

Creates a new resource with the specified URI.

F
getMetamodel(uri:)

Gets a metamodel package by its namespace URI.

F
getMetamodelURIs()

Gets all registered metamodel URIs.

F
getResource(uri:)

Gets a resource by its URI, loading it if necessary.

F
getResourceFactory(for:)

Gets a resource factory for a given URI.

F
getResources()

Gets all resources in this resource set.

F
loadJSONResource(uri:)

Load a JSON resource from a file URL

F
loadXMIResource(uri:)

Load an XMI resource from a file URL

F
mapURI(from:to:)

Maps a logical URI to a physical URI.

F
normaliseURI(_:)

Normalises a URI by applying registered conversions and cleanup.

F
registerMetamodel(_:uri:)

Registers a metamodel package with its namespace URI.

F
registerResourceFactory(_:for:)

Registers a resource factory for handling specific file extensions or URI patterns.

F
removeResource(_:)

Removes a resource from this resource set.

F
removeResource(uri:)

Removes a resource by its URI from this resource set.

F
resolve(_:)

Resolves an object by its identifier across all resources in the set.

F
resolveByURI(_:)

Resolves an object by its URI across all resources in the set.

F
resolveOpposite(_:)

Resolves the opposite reference for a bidirectional reference across all resources.

F
resolveOppositeSync(_:)

Synchronous version for internal use within Resource

F
unregisterMetamodel(uri:)

Unregisters a metamodel by its namespace URI.

F
updateOpposite(targetId:oppositeRefId:sourceId:add:)

Updates the opposite side of a bidirectional reference across resources.

Type Properties

?
shared

Global resource set actor for thread-safe operations.

Default Implementations

Relationships

Conforms To

See Also

Resources and Serialisation

?
Resource

A resource manages model objects and provides EMF-compliant 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)