Class

io.chymyst.jc

GuardPresent

Related Doc: package jc

Permalink

final case class GuardPresent(vars: Array[Array[Symbol]], staticGuard: Option[() ⇒ Boolean], crossGuards: Array[CrossMoleculeGuard]) extends GuardPresenceFlag with Product with Serializable

Indicates whether guard conditions are required for this reaction to start.

The guard is parsed into a flat conjunction of guard clauses, which are then analyzed for cross-dependencies between molecules.

For example, consider the reaction

go { case a(x) + b(y) + c(z) if x > n && y > 0 && y > z && n > 1 => ...}

Here n is an integer constant defined outside the reaction. The conditions for starting this reaction is that a(x) has value x such that x > n; that b(y) has value y such that y > 0; that c(z) has value z such that y > z; and finally that n > 1, independently of any molecule values. The condition n > 1 is a static guard. The condition x > n restricts only the molecule a(x) and therefore can be moved out of the guard into the per-molecule conditional inside InputMoleculeInfo for that molecule. Similarly, the condition y > 0 can be moved out of the guard. However, the condition y > z relates two different molecule values; it is a cross-molecule guard.

Any guard condition given by the reaction code will be converted to the Conjunctive Normal Form, and split into a static guard, a set of per-molecule conditionals, and a set of cross-molecule guards.

vars

The list of all pattern variables used by the guard condition. Each element of this list is a list of variables used by one guard clause. In the example shown above, this will be List(List('y, 'z)) because all other conditions are moved out of the guard.

staticGuard

The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

crossGuards

A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be

indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () }))
Linear Supertypes
Serializable, Serializable, Product, Equals, GuardPresenceFlag, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GuardPresent
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. GuardPresenceFlag
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new GuardPresent(vars: Array[Array[Symbol]], staticGuard: Option[() ⇒ Boolean], crossGuards: Array[CrossMoleculeGuard])

    Permalink

    vars

    The list of all pattern variables used by the guard condition. Each element of this list is a list of variables used by one guard clause. In the example shown above, this will be List(List('y, 'z)) because all other conditions are moved out of the guard.

    staticGuard

    The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

    crossGuards

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be

    indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () }))

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. val crossGuards: Array[CrossMoleculeGuard]

    Permalink

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard.

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be

    indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () }))
  7. def effectivelyAbsent: Boolean

    Permalink

    Checks whether the reaction has no cross-molecule guard conditions.

    Checks whether the reaction has no cross-molecule guard conditions.

    For example, go { case a(x) + b(y) if x > y => } has a cross-molecule guard condition, whereas go { case a(x) + b(y) if x == 1 && y == 2 => } has no cross-molecule guard conditions because its guard condition can be split into a conjunction of guard conditions that each constrain the value of a single molecule.

    returns

    true if the reaction has no guard condition, or if it has guard conditions that can be split between molecules; false if the reaction has a cross-molecule guard condition.

    Definition Classes
    GuardPresentGuardPresenceFlag
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. val staticGuard: Option[() ⇒ Boolean]

    Permalink

    The conjunction of all the clauses of the guard that are independent of pattern variables.

    The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

  16. def staticGuardFails: Boolean

    Permalink

    Checks whether the reaction should not start because its static guard is present and returns false.

    Checks whether the reaction should not start because its static guard is present and returns false.

    returns

    true if the reaction's static guard returns false. false if the reaction has no static guard, or if the static guard returns true.

    Definition Classes
    GuardPresentGuardPresenceFlag
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. val toString: String

    Permalink
    Definition Classes
    GuardPresent → AnyRef → Any
  19. val vars: Array[Array[Symbol]]

    Permalink

    The list of all pattern variables used by the guard condition.

    The list of all pattern variables used by the guard condition. Each element of this list is a list of variables used by one guard clause. In the example shown above, this will be List(List('y, 'z)) because all other conditions are moved out of the guard.

  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from GuardPresenceFlag

Inherited from AnyRef

Inherited from Any

Ungrouped