This is an old revision of the document!
Table of Contents
shl
The left shift operator (Β« operator$shl) is overloaded for several object mostly to symbolize the forwarding of an information into an object.
Dataset
The left shift operator can be used to add values to a Dataset or a DatasetRef. Every left shift describes a new column in a row of the dataset.
dataset("test") << 1 << 2; dataset("test") << 11 << 12;
this results in:
| 1 | 1 | 2 |
| 2 | 11 | 12 |
module A(float len, float fact); protected void init () [ Axiom ==> A(2,5) A(5,1) A(1,1); ] public void run () { dataset("test") << (*a:A*).getId() << a[len] << a[fact] << a[len]*a[fact]; }
Lists
Similar to the datasets the left shift operator is defined for GroIMP's list objects.
- de.grogra.xl.util.ByteList
- de.grogra.xl.util.ShortList
- de.grogra.xl.util.CharList
- de.grogra.xl.util.IntList
- de.grogra.xl.util.LongList
- de.grogra.xl.util.FloatList
- de.grogra.xl.util.DoubleList
- java.util.List
- e.g ArrayList
The difference to the datasets its that this lists are only one dimensional, therefore all elements are added in a chain/list.
import de.grogra.xl.util.FloatList; ... FloatList x = new FloatList(); x << 1 << 2 << 3; x << 4 << 5; println(x);//de.grogra.xl.util.FloatList@8194d89f{1.0, 2.0, 3.0, 4.0, 5.0}
PrintWriter
The left shift can also be used to βsendβ information to a java PrintWriter object (java.io.PrintWriter). This can be used to create output files:
module A(float len, float fact); protected void init () [ Axiom ==> A(2,5) A(5,1) A(1,1); ] public void run () { java.io.PrintWriter output = new java.io.PrintWriter("/home/tim/pwTest.txt"); output << (*a:A*).getId() << "," << a[len] << "," << a[fact] << "," << a[len]*a[fact] << "\n"; output.close(); }
Or it can be used with the out object, a static PrintWriter that represents the XL console.
In this case out << "test" is the same as print("test");
Node Transformations
The left shift can be used to forward the transformation matrix (Matrix4d) of a node that extends Null(de.grogra.imp3d.objects.Null) to another Null extending node.
This can be used to rewrite a node while keeping the applied local transformation.
protected void init () [ Axiom ==> Box; ] public void run () [ b:Box ==> Sphere.(b >> $); ]
In the example above the box can be moved/rotated/scaled with the UI tools and after the run function is executed the Box is in the same position. The same effect can be described explicitly with b:Box ==> Sphere.($[transform]=b[transform]);.
This also works with Matrix4d objects as input or output.
VVQueue
The shl operator can be used to add a GRSVertex as a neighbor to a VVQueue.
