Class Script

java.lang.Object
org.btrplace.btrpsl.Script

public class Script
extends Object
A btrplace script that contains the declaration of VMs, nodes, and constraints.
Author:
Fabien Hermenier
  • Field Details

  • Constructor Details

    • Script

      public Script()
      Make a new script with a given identifier.
  • Method Details

    • setFullyQualifiedName

      public void setFullyQualifiedName​(String n)
      Set the fully qualified name of the script.
      Parameters:
      n - the fully qualified name
    • getNamespace

      public String getNamespace()
      Get the namespace the script belongs to
      Returns:
      the namespace name or null
    • getlocalName

      public String getlocalName()
      Get the local name of the script.
      Returns:
      a non-empty String
    • id

      public String id()
      Get the unique string identifier of the script.
      Returns:
      a non-empty string
    • getVMs

      public Set<VM> getVMs()
      Get the VMs declared in the script.
      Returns:
      a set of nodes that may be empty
    • getNodes

      public Set<Node> getNodes()
      Get the VMs declared in the script.
      Returns:
      a set of nodes that may be empty
    • addConstraint

      public boolean addConstraint​(SatConstraint c)
      Add a constraint to a script.
      Parameters:
      c - the constraint
      Returns:
      true iff the constraint has been added
    • getConstraints

      public Set<SatConstraint> getConstraints()
      Get the constraints declared in the script.
      Returns:
      a set of constraints that may be empty
    • add

      public boolean add​(Collection<BtrpElement> elems)
      Add a collection of nodes or elements.
      Parameters:
      elems - the elements to add
      Returns:
      true iff at least one element has been added
    • add

      public boolean add​(BtrpElement el)
      Add a VM or a node to the script.
      Parameters:
      el - the element to add
      Returns:
      true if the was was added
    • getImportables

      public List<BtrpOperand> getImportables​(String ns)
      Get all the operand a given script can import
      Parameters:
      ns - the script namespace
      Returns:
      a list of importable operand, may be empty
    • getImportable

      public BtrpOperand getImportable​(String label, String namespace)
      Get the exported operand from its label.
      Parameters:
      label - the operand label
      namespace - the namespace of the script that ask for this operand.
      Returns:
      the operand if exists or null
    • getImportable

      public BtrpOperand getImportable​(String label)
      Get the exported variable. The variable must be importable by anyone.
      Parameters:
      label - the label that denotes the variable
      Returns:
      null if the label does not point to a variable or if the variable as some restrictions wrt. its access
    • canImport

      public boolean canImport​(String label, String namespace)
      Indicates whether a namespace can import an exported variable or not. To be imported, the label must point to an exported variable, with no import restrictions or with a given namespace compatible with the restrictions.
      Parameters:
      label - the label to import
      namespace - the namespace of the script asking for the variable
      Returns:
      true if the variable can be imported. false otherwise}
    • addExportable

      public void addExportable​(String name, BtrpOperand e, Set<String> scopes)
      Add an external operand that can be accessed from several given scopes. A scope is a namespace that can ends with a wildcard ('*'). In this situation. The beginning of the scope is considered
      Parameters:
      name - the name of the exported operand
      e - the operand to add
      scopes - the namespaces of the scripts that can use this variable. null to allow anyone
    • fullyQualifiedSymbolName

      public String fullyQualifiedSymbolName​(String name)
      Get the fully qualified name of a symbol.
      Parameters:
      name - the symbol name
      Returns:
      the fully qualified symbol name.
    • getExported

      public Set<String> getExported()
      Get the set of exported operands label.
      Returns:
      a set of label that may be empty
    • getDependencies

      public List<Script> getDependencies()
      Get the direct dependencies of this script.
      Returns:
      the list of dependencies for this script.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • prettyDependencies

      public String prettyDependencies()
      Textual representation for the dependencies.
      Returns:
      a String containing the dependency tree.