Class TypeCache
java.lang.Object
net.ssehub.easy.reasoning.sseReasoner.model.TypeCache
Implements a type cache to avoid repeatedly identifying, iterating over and collecting constraints for complex
types.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classRepresents a constraint template with related constraint set to add the constraint to.classImplements a type cache entry.static interfaceSpecifies the interface that an object receiving constraints from this class must provide. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<net.ssehub.easy.varModel.model.datatypes.IDatatype, TypeCache.Entry> static final booleanGlobally enables or disables type-caching.(package private) static final booleanVariable-accessor and name-accessor mappings may be transferred back to the current context in one copy stepfalseor step-wise and on-demand onlytrue.private SubstitutionVisitor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(net.ssehub.easy.varModel.model.datatypes.IDatatype type) Returns whether this type cache contains an entry fortype.createEntryFor(net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.AbstractVariable var) Creates a type cache entry.get(net.ssehub.easy.varModel.model.datatypes.IDatatype type) Returns a type cache entry for the giventype.booleantransferConstraints(net.ssehub.easy.varModel.model.datatypes.IDatatype type, TypeCache.IConstraintTarget target, net.ssehub.easy.varModel.confModel.IDecisionVariable register, net.ssehub.easy.varModel.model.AbstractVariable var) Transfers collected constraints fortype.voidtransferContext(net.ssehub.easy.varModel.model.datatypes.IDatatype type, Map<net.ssehub.easy.varModel.model.AbstractVariable, net.ssehub.easy.varModel.cst.ConstraintSyntaxTree> varMap, Map<String, net.ssehub.easy.varModel.cst.ConstraintSyntaxTree> nameMap) Transfers the mappings of the givencontextinto the cache entry oftype.voidtransferToContext(net.ssehub.easy.varModel.model.datatypes.IDatatype type, ContextStack contexts, net.ssehub.easy.varModel.model.AbstractVariable var) Transfers all accessors stored inTypeCache.Entry.varMapinto the actual context incontextsby instantiating them.
-
Field Details
-
ENABLED
public static final boolean ENABLEDGlobally enables or disables type-caching.- See Also:
-
ON_DEMAND_ACCESSORS
static final boolean ON_DEMAND_ACCESSORSVariable-accessor and name-accessor mappings may be transferred back to the current context in one copy stepfalseor step-wise and on-demand onlytrue. Only active if#ENABLED.- See Also:
-
cache
-
substVisitor
-
-
Constructor Details
-
TypeCache
public TypeCache()
-
-
Method Details
-
get
Returns a type cache entry for the giventype.- Parameters:
type- the type to return the cache entry for- Returns:
- the cache entry, may be null for none
-
contains
public boolean contains(net.ssehub.easy.varModel.model.datatypes.IDatatype type) Returns whether this type cache contains an entry fortype.- Parameters:
type- the type to look for- Returns:
trueiftypeis in the cache,falseelse
-
createEntryFor
public TypeCache.Entry createEntryFor(net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.AbstractVariable var) Creates a type cache entry.- Parameters:
type- the type to create the entry forvar- the template varible- Returns:
- the created entry
-
transferConstraints
public boolean transferConstraints(net.ssehub.easy.varModel.model.datatypes.IDatatype type, TypeCache.IConstraintTarget target, net.ssehub.easy.varModel.confModel.IDecisionVariable register, net.ssehub.easy.varModel.model.AbstractVariable var) Transfers collected constraints fortype.- Parameters:
type- the type to transfer the constraints totarget- the constraint target receiving instantiated constraintsregister- the variable to register new constraints withvar- the variable to replace the template variable- Returns:
truefor transferred,falseelse
-
transferContext
public void transferContext(net.ssehub.easy.varModel.model.datatypes.IDatatype type, Map<net.ssehub.easy.varModel.model.AbstractVariable, net.ssehub.easy.varModel.cst.ConstraintSyntaxTree> varMap, Map<String, net.ssehub.easy.varModel.cst.ConstraintSyntaxTree> nameMap) Transfers the mappings of the givencontextinto the cache entry oftype.- Parameters:
type- the typevarMap- the variable-accessor mapping (optional, may be null)nameMap- the name-accessor mapping (optional, may be null)
-
transferToContext
public void transferToContext(net.ssehub.easy.varModel.model.datatypes.IDatatype type, ContextStack contexts, net.ssehub.easy.varModel.model.AbstractVariable var) Transfers all accessors stored inTypeCache.Entry.varMapinto the actual context incontextsby instantiating them.- Parameters:
type- the type to transfercontexts- the target contexts (using the actual one)var- the variable to instantiate for
-