Documentation Language: Swift

Structure

EFactory

A factory for creating instances of model elements.

struct EFactory

Overview

EFactory provides the factory pattern for creating instances of classes defined in a metamodel package. Each factory is associated with a specific EPackage and can create instances of the classes in that package.

Key Capabilities

Example

let companyPackage = EPackage(
    name: "company",
    nsURI: "http://example.org/company",
    nsPrefix: "company"
)

let factory = EFactory(ePackage: companyPackage)

// Create an Employee instance (in practice, would return a proper object)
if let employeeClass = companyPackage.getEClass("Employee") {
    let employee = factory.create(employeeClass)
    print("Created instance of \(employee.eClass.name)")
}

// Parse a string into an Int
let intType = EDataType(name: "EInt")
if let value = factory.createFromString(intType, "42") as? Int {
    print("Parsed value: \(value)")
}

Important Note

This basic implementation creates generic EObject instances. In a complete implementation, factories would be code-generated or use dynamic proxies to create specific typed instances with proper feature storage.

Topics

Operators

?
==(_:_:)

Compares two factories for equality.

Initializers

?
init(id:name:ePackage:eAnnotations:)

Creates a new factory.

Instance Properties

V
eAnnotations

Annotations attached to this factory.

V
eClass

The metaclass describing this factory.

V
ePackage

The package that this factory creates instances for.

V
id

Unique identifier for this factory.

V
name

The name of this factory.

Instance Methods

F
convertToString(_:_:)

Converts a value to a string literal for the given data type.

F
create(_:)

Creates an instance of the specified class.

F
createFromString(_:_:)

Creates a value from a string literal for the given data type.

F
eGet(_:)

Reflectively retrieves the value of a feature.

F
eIsSet(_:)

Checks whether a feature has been explicitly set.

F
eSet(_:_:)

Reflectively sets the value of a feature.

F
eUnset(_:)

Unsets a feature, returning it to its default value.

F
hash(into:)

Hashes the essential components of this factory.

Type Aliases

T
EFactory.Classifier

The type of classifier for this factory.

Default Implementations

Relationships

Conforms To

See Also

Supporting Types

P
EModelElement

Base protocol for model elements that can have annotations.

P
ENamedElement

Base protocol for model elements that have a name.