java.lang.Object
net.ssehub.easy.reasoning.sseReasoner.model.TypeCache

public final class TypeCache extends Object
Implements a type cache to avoid repeatedly identifying, iterating over and collecting constraints for complex types.
Author:
Holger Eichelberger
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Represents a constraint template with related constraint set to add the constraint to.
    class 
    Implements a type cache entry.
    static interface 
    Specifies the interface that an object receiving constraints from this class must provide.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Map<net.ssehub.easy.varModel.model.datatypes.IDatatype,TypeCache.Entry>
     
    static final boolean
    Globally enables or disables type-caching.
    (package private) static final boolean
    Variable-accessor and name-accessor mappings may be transferred back to the current context in one copy step false or step-wise and on-demand only true.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
    Returns whether this type cache contains an entry for type.
    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 given type.
    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 for type.
    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 given context into the cache entry of type.
    void
    transferToContext(net.ssehub.easy.varModel.model.datatypes.IDatatype type, ContextStack contexts, net.ssehub.easy.varModel.model.AbstractVariable var)
    Transfers all accessors stored in TypeCache.Entry.varMap into the actual context in contexts by instantiating them.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ENABLED

      public static final boolean ENABLED
      Globally enables or disables type-caching.
      See Also:
    • ON_DEMAND_ACCESSORS

      static final boolean ON_DEMAND_ACCESSORS
      Variable-accessor and name-accessor mappings may be transferred back to the current context in one copy step false or step-wise and on-demand only true. Only active if #ENABLED.
      See Also:
    • cache

      private Map<net.ssehub.easy.varModel.model.datatypes.IDatatype,TypeCache.Entry> cache
    • substVisitor

      private transient SubstitutionVisitor substVisitor
  • Constructor Details

    • TypeCache

      public TypeCache()
  • Method Details

    • get

      public TypeCache.Entry get(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
      Returns a type cache entry for the given type.
      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 for type.
      Parameters:
      type - the type to look for
      Returns:
      true if type is in the cache, false else
    • 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 for
      var - 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 for type.
      Parameters:
      type - the type to transfer the constraints to
      target - the constraint target receiving instantiated constraints
      register - the variable to register new constraints with
      var - the variable to replace the template variable
      Returns:
      true for transferred, false else
    • 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 given context into the cache entry of type.
      Parameters:
      type - the type
      varMap - 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 in TypeCache.Entry.varMap into the actual context in contexts by instantiating them.
      Parameters:
      type - the type to transfer
      contexts - the target contexts (using the actual one)
      var - the variable to instantiate for