Class AbstractResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.common.AbstractResolvableModel<V,M>
-
- Type Parameters:
V- the actual type of variable declarationM- the actual type of model
- All Implemented Interfaces:
IModel,IModelData,IModelListener<Project>,ICompoundReceiver,IParameterizable<V>,IResolvableModel<V,M>,ITypedefReceiver,IMetaType,ITypedModel
public abstract class AbstractResolvableModel<V extends IMetaParameterDeclaration,M extends IModel> extends java.lang.Object implements IResolvableModel<V,M>, IModelListener<Project>, ITypedefReceiver, ICompoundReceiver
A basic implementation ofIResolvableModel. It registers itself as model listener in order to be informed when advices are updated causing the model to be flagged as dirty (direct reload may cause uncoordinated model reloads).- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractResolvableModel(Imports<M> imports, TypeRegistry registry, Advice[] advices)Creates an abstract resolvable model.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddCompound(Compound compound)Adds a compound.voidaddImport(ModelImport<M> imp)Add a project import to this model.voidaddRuntimeImport(ModelImport<M> imp)Adds a runtime model import.voidaddTypedef(Typedef typedef)Adds a typedef.protected Imports<M>createImports()Creates an empty imports instance (in case that a specialized instance shall be used).voiddispose()Shall be called at the end of the lifetime of the model in order to clean up references such as listeners.AdvicegetAdvice(int index)Get the advice at the specified index.intgetAdviceCount()Get the number of advices of this model.CompoundgetCompound(int index)Get the compound at the specified index.CompoundgetCompound(java.lang.String name)Returns the compound declaration with given name.intgetCompoundCount()Get the number of compounds defined in this model.ModelImport<M>getImport(int index)Returns the model import specified byindex.protected Imports<M>getImports()Returns the imports instance.intgetImportsCount()Returns the number of imports.java.lang.ObjectgetIvmlElement(java.lang.String name)Returns whether the givennameresolves to an IVML element.TypedefgetTypedef(int index)Get the typedef at the specified index.TypedefgetTypedef(java.lang.String name)Returns the typedef with given name.intgetTypedefCount()Get the number of typedefs of this model.TypeRegistrygetTypeRegistry()Returns the responsible type registry.booleanisDirty()Returns whether this model has become dirty, e.g., due to updates of the underlying adviced models.voidnotifyReplaced(Project oldModel, Project newModel)Is called to notify thatoldModelis replaced bynewModel.private voidprocessModelListeners(boolean add)Processes the model listeners for the advices.protected abstract voidreload()Causes a reload of this model.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IMetaType
addPlaceholderOperation, checkConversion, enableDynamicDispatch, findConversion, getBaseType, getCandidates, getField, getFieldCount, getGenericParameterCount, getGenericParameterType, getName, getOperation, getOperationsCount, getQualifiedName, getSuperType, isActualTypeOf, isAssignableFrom, isBasicType, isInternal, isPlaceholder
-
Methods inherited from interface net.ssehub.easy.basics.modelManagement.IModel
getIndentationConfiguration, getName, getRestrictionEvaluationContext, getSuper, getVersion, setVersion
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.common.IParameterizable
getParameter, getParameter, getParameterCount, getRequiredParameterCount
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.common.IResolvableModel
getExtensionType, getExtensionTypesCount, getParent, getVariableDeclaration, getVariableDeclarationCount, isImplicit
-
-
-
-
Constructor Detail
-
AbstractResolvableModel
protected AbstractResolvableModel(Imports<M> imports, TypeRegistry registry, Advice[] advices)
Creates an abstract resolvable model.- Parameters:
imports- the importsregistry- the registry which is responsible for this typeadvices- the advices (may be null)
-
-
Method Detail
-
processModelListeners
private void processModelListeners(boolean add)
Processes the model listeners for the advices.- Parameters:
add- add or remove the model listeners
-
getImportsCount
public int getImportsCount()
Description copied from interface:IModelReturns the number of imports.- Specified by:
getImportsCountin interfaceIModel- Returns:
- the number of imports
-
getImport
public ModelImport<M> getImport(int index)
Description copied from interface:IModelReturns the model import specified byindex.
-
createImports
protected Imports<M> createImports()
Creates an empty imports instance (in case that a specialized instance shall be used).- Returns:
- the created instance
-
addImport
public void addImport(ModelImport<M> imp)
Add a project import to this model.- Parameters:
imp- The additional project import.
-
addRuntimeImport
public void addRuntimeImport(ModelImport<M> imp)
Description copied from interface:IResolvableModelAdds a runtime model import.- Specified by:
addRuntimeImportin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
imp- the import
-
getImports
protected Imports<M> getImports()
Returns the imports instance.- Returns:
- the imports instance
-
getTypeRegistry
public TypeRegistry getTypeRegistry()
Description copied from interface:IResolvableModelReturns the responsible type registry.- Specified by:
getTypeRegistryin interfaceIMetaType- Specified by:
getTypeRegistryin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Returns:
- the type registry
-
getAdviceCount
public int getAdviceCount()
Get the number of advices of this model.- Returns:
- The number of advices of this model.
-
getAdvice
public Advice getAdvice(int index)
Get the advice at the specified index.- Parameters:
index- The 0-based index of the advice to be returned.- Returns:
- The advice parameter at the given index.
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getAdviceCount()
-
getTypedefCount
public int getTypedefCount()
Description copied from interface:IResolvableModelGet the number of typedefs of this model.- Specified by:
getTypedefCountin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Returns:
- The number of typedefs of this model.
-
getTypedef
public Typedef getTypedef(int index)
Description copied from interface:IResolvableModelGet the typedef at the specified index.- Specified by:
getTypedefin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
index- The 0-based index of the typedef to be returned.- Returns:
- The typedef parameter at the given index.
-
addTypedef
public void addTypedef(Typedef typedef)
Description copied from interface:ITypedefReceiverAdds a typedef.- Specified by:
addTypedefin interfaceITypedefReceiver- Parameters:
typedef- the typedef to be added
-
getTypedef
public Typedef getTypedef(java.lang.String name)
Description copied from interface:IResolvableModelReturns the typedef with given name.- Specified by:
getTypedefin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
name- the name- Returns:
- the typedef (may be null for none)
-
addCompound
public void addCompound(Compound compound)
Description copied from interface:ICompoundReceiverAdds a compound.- Specified by:
addCompoundin interfaceICompoundReceiver- Parameters:
compound- the compound to be added
-
getCompound
public Compound getCompound(java.lang.String name)
Description copied from interface:IResolvableModelReturns the compound declaration with given name.- Specified by:
getCompoundin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
name- the name- Returns:
- the compound (may be null for none)
-
getCompoundCount
public int getCompoundCount()
Description copied from interface:IResolvableModelGet the number of compounds defined in this model.- Specified by:
getCompoundCountin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Returns:
- The number of compounds of this model.
-
getCompound
public Compound getCompound(int index)
Description copied from interface:IResolvableModelGet the compound at the specified index.- Specified by:
getCompoundin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
index- The 0-based index of the compound to be returned.- Returns:
- The compound at the given index.
-
dispose
public void dispose()
Description copied from interface:IModelShall be called at the end of the lifetime of the model in order to clean up references such as listeners.
-
isDirty
public boolean isDirty()
Returns whether this model has become dirty, e.g., due to updates of the underlying adviced models.- Returns:
trueif this model has become dirty and shall be at least reloaded before execution,falseelse
-
notifyReplaced
public void notifyReplaced(Project oldModel, Project newModel)
Description copied from interface:IModelListenerIs called to notify thatoldModelis replaced bynewModel. The listener registrations foroldModelwill be adjusted accordingly.
Do not modify the the listeners ofoldModelornewModelduring this method.- Specified by:
notifyReplacedin interfaceIModelListener<V extends IMetaParameterDeclaration>- Parameters:
oldModel- the old model being replacednewModel- the new model (the replacement)
-
getIvmlElement
public java.lang.Object getIvmlElement(java.lang.String name)
Description copied from interface:IResolvableModelReturns whether the givennameresolves to an IVML element.- Specified by:
getIvmlElementin interfaceIResolvableModel<V extends IMetaParameterDeclaration,M extends IModel>- Parameters:
name- the name to be resolved- Returns:
- the IVML element (value, containable model element), null else
-
reload
protected abstract void reload()
Causes a reload of this model.
-
-