UNPKG

sprotty

Version:

A next-gen framework for graphical views

69 lines 3.57 kB
/******************************************************************************** * Copyright (c) 2017-2024 TypeFox and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { SModelElement, SModelRoot } from 'sprotty-protocol/lib/model'; import { FactoryRegistry } from '../../utils/registry'; import { SChildElementImpl, SModelElementImpl, SModelRootImpl, SParentElementImpl, FeatureSet } from './smodel'; /** * Model element classes registered here are considered automatically when constructring a model from its schema. */ export declare class SModelRegistry extends FactoryRegistry<SModelElementImpl, void> { constructor(registrations: SModelElementRegistration[]); protected getDefaultFeatures(constr: SModelElementConstructor): ReadonlyArray<symbol> | undefined; } /** * A model factory transforms a serializable model schema into the model representation that is used * internally by sprotty. */ export interface IModelFactory { createElement(schema: SModelElement | SModelElementImpl, parent?: SParentElementImpl): SChildElementImpl; createRoot(schema: SModelRoot | SModelRootImpl): SModelRootImpl; createSchema(element: SModelElementImpl): SModelElement; } /** * The default model factory creates SModelRoot for the root element and SChildElement for all other * model elements. */ export declare class SModelFactory implements IModelFactory { protected readonly registry: SModelRegistry; createElement(schema: SModelElement | SModelElementImpl, parent?: SParentElementImpl): SChildElementImpl; createRoot(schema: SModelRoot | SModelRootImpl): SModelRootImpl; createSchema(element: SModelElementImpl): SModelElement; protected initializeElement(element: SModelElementImpl, schema: SModelElement | SModelElementImpl): SModelElementImpl; protected isReserved(element: SModelElementImpl, propertyName: string): boolean; protected initializeParent(parent: SParentElementImpl, schema: SModelElement | SParentElementImpl): SParentElementImpl; protected initializeChild(child: SChildElementImpl, schema: SModelElement, parent?: SParentElementImpl): SChildElementImpl; protected initializeRoot(root: SModelRootImpl, schema: SModelRoot | SModelRootImpl): SModelRootImpl; } export declare const EMPTY_ROOT: Readonly<SModelRoot>; /** * Used to bind a model element type to a class constructor in the SModelRegistry. */ export interface SModelElementRegistration { type: string; constr: SModelElementConstructor; features?: CustomFeatures; isOverride?: boolean; } export interface SModelElementConstructor { DEFAULT_FEATURES?: ReadonlyArray<symbol>; new (): SModelElementImpl; } export interface CustomFeatures { enable?: symbol[]; disable?: symbol[]; } export declare function createFeatureSet(defaults: ReadonlyArray<symbol>, custom?: CustomFeatures): FeatureSet; //# sourceMappingURL=smodel-factory.d.ts.map