forge.util
Class RelationFactory<R,U extends R,T extends R,A extends U,O>

java.lang.Object
  extended by forge.util.RelationFactory<R,U,T,A,O>
All Implemented Interfaces:
ProgramElement

public abstract class RelationFactory<R,U extends R,T extends R,A extends U,O>
extends java.lang.Object
implements ProgramElement

Implementation support for factories that construct relations with Kodkod TupleSets.


Constructor Summary
protected RelationFactory(ForgeProgram program)
           
 
Method Summary
protected  O atom(int i)
          Returns the ith atom in the universe.
protected  kodkod.instance.TupleSet closureTupleSet(kodkod.engine.bool.BooleanMatrix m)
          Returns TupleSet that is the closure of a matrix.
protected  kodkod.instance.TupleSet differenceTupleSet(kodkod.engine.bool.BooleanMatrix m1, kodkod.engine.bool.BooleanMatrix m2)
          Returns TupleSet that is the difference of two matrices.
 U empty()
          Returns the empty set relation.
 R empty(int arity)
          Returns the empty relation of the given arity.
protected  kodkod.instance.TupleSet emptyTupleSet(int arity)
          Returns an empty TupleSet of the given arity.
protected  kodkod.instance.TupleSet intersectTupleSet(kodkod.engine.bool.BooleanMatrix m1, kodkod.engine.bool.BooleanMatrix m2)
          Returns TupleSet that is the intersection of two matrices.
protected  kodkod.instance.TupleSet joinTupleSet(kodkod.engine.bool.BooleanMatrix m1, kodkod.engine.bool.BooleanMatrix m2)
          Returns TupleSet that is the join of two matrices.
protected  java.util.List<A> listOfAtoms(kodkod.instance.TupleSet tuples)
          Wraps the given singleton TupleSet as a list of atoms.
protected  R make(kodkod.instance.TupleSet tuples)
          Makes a relation from a TupleSet.
protected  kodkod.instance.Bounds makeBounds()
          Returns a new bounds object with the universe.
protected  T makeTuple(kodkod.instance.TupleSet tuples)
          Makes a tuple relation from a TupleSet.
protected  U makeUnary(kodkod.instance.TupleSet tuples)
          Makes a unary relation from a TupleSet.
protected abstract  R newBig(kodkod.instance.TupleSet tuples)
          Constructs a new instance of a TupleSet with a size > 1 and arity > 1.
protected abstract  T newTuple(kodkod.instance.TupleSet tuples)
          Constructs a new instance of a TupleSet with a size > 1 and arity = 1.
protected abstract  U newUnary(kodkod.instance.TupleSet tuples)
          Constructs a new instance of a TupleSet with a size = 1 and arity > 1.
protected  kodkod.instance.TupleSet overrideTupleSet(kodkod.engine.bool.BooleanMatrix m1, kodkod.engine.bool.BooleanMatrix m2)
          Returns TupleSet that is the override of two matrices.
 ForgeProgram program()
          Returns the program to which this element belongs.
protected  kodkod.instance.TupleSet projectTupleSet(kodkod.engine.bool.BooleanMatrix m, int... columns)
          Returns TupleSet that is the projection of a matrix over some columns.
protected  java.util.Set<A> setOfAtoms(kodkod.instance.TupleSet tuples)
          Wraps the given TupleSet of unary tuples as a set of atoms.
protected  java.util.Set<T> setOfTuples(kodkod.instance.TupleSet tuples)
          Wraps the given TupleSet as a set of tuples.
protected  void setUniverse(java.util.Set<O> atoms)
           
protected  kodkod.instance.TupleSet singletonTupleSet(O atom)
          Returns a singleton TupleSet containing the given atom.
protected  kodkod.instance.TupleSet singletonTupleSet(kodkod.instance.Tuple tuple)
          Returns a singleton TupleSet containing the given tuple.
protected abstract  A toAtom(O object)
          Converts an object stored in the universe to an atom.
protected  kodkod.engine.bool.BooleanMatrix toBooleanMatrix(kodkod.instance.TupleSet tuples)
          Converts a TupleSet to a BooleanMatrix.
protected  kodkod.instance.Tuple tuple(A... atoms)
          Constructs a Tuple with the given atoms.
protected  kodkod.instance.TupleSet unionTupleSet(kodkod.engine.bool.BooleanMatrix m1, kodkod.engine.bool.BooleanMatrix m2)
          Returns TupleSet that is the union of two matrices.
 kodkod.instance.Universe universe()
          Return the kodkod universe used by this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationFactory

protected RelationFactory(ForgeProgram program)
Method Detail

setUniverse

protected final void setUniverse(java.util.Set<O> atoms)

program

public final ForgeProgram program()
Description copied from interface: ProgramElement
Returns the program to which this element belongs.

Specified by:
program in interface ProgramElement

universe

public final kodkod.instance.Universe universe()
Return the kodkod universe used by this factory.


empty

public final U empty()
Returns the empty set relation.


empty

public final R empty(int arity)
Returns the empty relation of the given arity.


newBig

protected abstract R newBig(kodkod.instance.TupleSet tuples)
Constructs a new instance of a TupleSet with a size > 1 and arity > 1.


newUnary

protected abstract U newUnary(kodkod.instance.TupleSet tuples)
Constructs a new instance of a TupleSet with a size = 1 and arity > 1.


newTuple

protected abstract T newTuple(kodkod.instance.TupleSet tuples)
Constructs a new instance of a TupleSet with a size > 1 and arity = 1.


toAtom

protected abstract A toAtom(O object)
Converts an object stored in the universe to an atom.


make

protected final R make(kodkod.instance.TupleSet tuples)
Makes a relation from a TupleSet.


makeUnary

protected final U makeUnary(kodkod.instance.TupleSet tuples)
Makes a unary relation from a TupleSet.


makeTuple

protected final T makeTuple(kodkod.instance.TupleSet tuples)
Makes a tuple relation from a TupleSet.


setOfTuples

protected final java.util.Set<T> setOfTuples(kodkod.instance.TupleSet tuples)
Wraps the given TupleSet as a set of tuples.


setOfAtoms

protected final java.util.Set<A> setOfAtoms(kodkod.instance.TupleSet tuples)
Wraps the given TupleSet of unary tuples as a set of atoms.


listOfAtoms

protected final java.util.List<A> listOfAtoms(kodkod.instance.TupleSet tuples)
Wraps the given singleton TupleSet as a list of atoms.


makeBounds

protected final kodkod.instance.Bounds makeBounds()
Returns a new bounds object with the universe.


atom

protected final O atom(int i)
Returns the ith atom in the universe.


tuple

protected final kodkod.instance.Tuple tuple(A... atoms)
Constructs a Tuple with the given atoms.


emptyTupleSet

protected final kodkod.instance.TupleSet emptyTupleSet(int arity)
Returns an empty TupleSet of the given arity.


singletonTupleSet

protected final kodkod.instance.TupleSet singletonTupleSet(O atom)
Returns a singleton TupleSet containing the given atom.


singletonTupleSet

protected final kodkod.instance.TupleSet singletonTupleSet(kodkod.instance.Tuple tuple)
Returns a singleton TupleSet containing the given tuple.


closureTupleSet

protected final kodkod.instance.TupleSet closureTupleSet(kodkod.engine.bool.BooleanMatrix m)
Returns TupleSet that is the closure of a matrix.


projectTupleSet

protected final kodkod.instance.TupleSet projectTupleSet(kodkod.engine.bool.BooleanMatrix m,
                                                         int... columns)
Returns TupleSet that is the projection of a matrix over some columns.


joinTupleSet

protected final kodkod.instance.TupleSet joinTupleSet(kodkod.engine.bool.BooleanMatrix m1,
                                                      kodkod.engine.bool.BooleanMatrix m2)
Returns TupleSet that is the join of two matrices.


overrideTupleSet

protected final kodkod.instance.TupleSet overrideTupleSet(kodkod.engine.bool.BooleanMatrix m1,
                                                          kodkod.engine.bool.BooleanMatrix m2)
Returns TupleSet that is the override of two matrices.


unionTupleSet

protected final kodkod.instance.TupleSet unionTupleSet(kodkod.engine.bool.BooleanMatrix m1,
                                                       kodkod.engine.bool.BooleanMatrix m2)
Returns TupleSet that is the union of two matrices.


differenceTupleSet

protected final kodkod.instance.TupleSet differenceTupleSet(kodkod.engine.bool.BooleanMatrix m1,
                                                            kodkod.engine.bool.BooleanMatrix m2)
Returns TupleSet that is the difference of two matrices.


intersectTupleSet

protected final kodkod.instance.TupleSet intersectTupleSet(kodkod.engine.bool.BooleanMatrix m1,
                                                           kodkod.engine.bool.BooleanMatrix m2)
Returns TupleSet that is the intersection of two matrices.


toBooleanMatrix

protected final kodkod.engine.bool.BooleanMatrix toBooleanMatrix(kodkod.instance.TupleSet tuples)
Converts a TupleSet to a BooleanMatrix.