Documentation Language: Swift

Framework

ECore

A pure Swift implementation of https://eclipse.dev/emf/ for Model-Driven Engineering.

Overview

ECore provides a complete implementation of the https://eclipse.dev/emf/ Ecore metamodelling system in pure Swift. Use it to define metamodels, create model instances, and serialise models to XMI or JSON format.

The framework follows the EMF/Ecore specification based on the https://www.omg.org/mof/ standard, providing familiar concepts for developers experienced with Eclipse-based modelling tools whilst offering a modern, type-safe Swift API.

Key Features

Quick Example

import ECore

// Load a metamodel from XMI
let parser = XMIParser()
let resource = try await parser.parse(URL(fileURLWithPath: "Company.ecore"))
let package = resource.rootObjects.first as! EPackage

// Find an EClass
let employeeClass = package.eClassifiers.first { $0.name == "Employee" } as! EClass

// Create a dynamic instance
let employee = DynamicEObject(eClass: employeeClass)
employee.eSet("name", value: "Alice")
employee.eSet("salary", value: 50000)

// Save to a new resource
let outputResource = Resource()
outputResource.add(employee)
let serialiser = XMISerializer()
try serialiser.save(resource: outputResource, to: URL(fileURLWithPath: "employees.xmi"))

Topics

Essentials

A
Getting Started with ECore

Learn how to add ECore to your project and create your first metamodel.

A
Understanding Ecore

Learn the fundamental concepts of the Ecore metamodelling framework.

Core Types

P
EObject

Base protocol for all Ecore model elements.

S
DynamicEObject

A dynamic implementation of EObject that stores feature values generically.

S
EClass

A class in the Ecore metamodel.

S
EPackage

A package in the Ecore metamodel.

Structural Features

P
EStructuralFeature

A structural feature (attribute or reference) in the Ecore metamodel.

S
EAttribute

An attribute in the Ecore metamodel.

S
EReference

A reference in the Ecore metamodel.

Classifiers

P
EClassifier

A classifier (type) in the Ecore metamodel.

S
EDataType

A data type in the Ecore metamodel.

S
EEnum

An enumeration type in the Ecore metamodel.

S
EEnumLiteral

A literal value within an enumeration.

Resources and Serialisation

?
Resource

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

?
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)

Commands and Editing

C
EMFCommand

Protocol defining a command that can be executed, undone, and redone.

C
CommandStack

Actor managing the execution and undo/redo history of EMF commands.

C
BasicEditingDomain

Actor providing basic editing domain functionality for model modification coordination.

Query and Execution

?
ECoreExecutionEngine

Core execution engine providing model navigation and query capabilities.

S
ECoreQuery

Query framework for ECore models inspired by OCL.

P
IModel

Protocol abstracting model access for transformation engines.

Supporting Types

S
EFactory

A factory for creating instances of model elements.

P
EModelElement

Base protocol for model elements that can have annotations.

P
ENamedElement

Base protocol for model elements that have a name.

Classes

C
AddCommand

Command to add a value to a many-valued structural feature.

C
CompoundCommand

Command that executes multiple commands as a single atomic operation.

?
ECoreDelegateRegistry

Registry for delegates.

?
ECoreQueryEvaluator

Query evaluator that converts string expressions to executable code.

C
RemoveCommand

Command to remove a value from a many-valued structural feature.

C
SetCommand

Command to set a property value on an EObject.

Protocols

P
ECoreOperationDelegate

Delegate for handling ECore operations.

P
ECoreSettingDelegate

Delegate for derived feature computation.

P
ECoreValidationDelegate

Delegate for validating ECore constraints.

P
EOperation

An operation in the Ecore metamodel.

P
EditingDomainObserver

Protocol for observing editing domain changes.

P
IReferenceModel

Protocol for reference models (metamodels).

P
ResourceFactory

Protocol for factories that can create and load resources.

Structures

S
CommandStackStatistics

Performance and usage statistics for command stack operations.

S
EAnnotation

An annotation on a model element.

S
EAttributeClassifier

Metaclass for EAttribute.

S
EClassClassifier

The metaclass for EClass.

S
ECoreQueryParser

Simple query parser for basic expressions.

S
ECoreValidationError

Validation error information.

S
EDataTypeClassifier

Metaclass for EDataType.

S
EEnumClassifier

Metaclass for EEnum.

S
EEnumLiteralClassifier

Metaclass for EEnumLiteral.

S
EFactoryClassifier

Metaclass for EFactory.

S
EObjectStorage

Internal storage for feature values in an EObject.

S
EOperationInfo

EOperation information for delegate operations.

S
EPackageClassifier

Metaclass for EPackage.

S
EParameterInfo

EParameter information for operation parameters.

S
EReferenceClassifier

Metaclass for EReference.

S
EcoreModel

Default implementation wrapping Resource.

S
EcoreReferenceModel

Reference model implementation for EPackages.

S
EcoreTypeProvider

Type provider for ECore type operations.

S
EditingDomainStatistics

Statistics for editing domain operations.

S
ResourceProxy

A proxy representing an unresolved cross-resource reference

S
XPathResolver

Resolves XPath-style fragment identifiers to object IDs

Enumerations

E
BooleanString

Boolean string representations used in XMI serialisation.

E
EClassifierResolver

Helper type for resolving EClassifier types from DynamicEObject instances.

E
ECoreExecutionError

Errors that can occur during execution.

E
ECoreExpression

Expression types supported by the execution engine.

E
ECoreExpressionValue

Wrapper for EcoreValue types in expressions.

E
ECoreQueryError

Errors that can occur during query parsing.

E
EMFCommandError

Errors that can occur during command execution, undo, or redo operations.

E
EMFCommandResult

Common result types for EMF commands.

E
EMFCommandState

The current state of a command in its lifecycle.

E
EStructuralFeatureResolver

Helper type for resolving EStructuralFeature types from DynamicEObject instances.

E
EcoreClassifier

Ecore metamodel classifier names.

E
EcoreDataType

Ecore built-in data type names.

E
EcoreURI

URI constants for Ecore built-in types and namespaces.

E
EditingDomainEvent

Events that can occur in an editing domain.

E
ErrorMessage

Standardised error messages for Ecore operations.

E
JSONError

Errors that can occur during JSON parsing

E
JSONSerializationError

Errors that can occur during JSON serialization

E
LoggingCategory

Logging categories for structured logging in Ecore operations.

E
XMIAttribute

XMI attribute names used in Ecore metamodel serialisation.

E
XMIElement

XMI element names used in Ecore metamodel structure.

E
XMIError

Errors that can occur during XMI parsing

E
XMLNamespace

XML namespace attribute names used in document parsing.

See Also

Related Documentation