Core Services¶
here you can find the API for services that are related to model creation and model manipulation.
Element Repository (/Factory)¶
- class gaphor.core.modeling.ElementFactory(event_manager: EventManager | None = None, element_dispatcher: ElementDispatcher | None = None)[源代码]¶
The
ElementFactoryis used as a central repository for a model.New model elements should be created by
create.Methods like
selectcan be used to find elements in the model.- select(expression: Callable[[Base], bool]) Iterator[Base][源代码]¶
- select(expression: type[T]) Iterator[T]
- select(expression: None) Iterator[Base]
Iterate elements that comply with expression.
Expressions can be:
None: return all elements.A type: return all elements of that type, or subtypes.
An expression.
- lselect(expression: Callable[[Base], bool] | type[T] | None = None) list[Base][源代码]¶
Like
select, but return a list, instead of an iterator.
- create(type: type[T]) T[源代码]¶
Create a new model element of type
type.This method will only create model elements, not
Presentationelements: those are created byDiagram.
Modeling Language¶
Information on how modeling languages are managed can be found 建模语言.
Event Manager¶
The 事件系统 takes care of dispatches events throughout Gaphor.