QDaq  0.2.6
Qt-based Data Aqcuisition
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Slots | List of all members
VectorPrototype Class Reference

The prototype for the Vector class. More...

#include <vectorprototype.h>

Inherits QObject, and QScriptable.

Public Slots

bool equals (const QDaqVector &other)
 Returns true if this Vector is equal to other.
 
QScriptValue valueOf () const
 Return the data stored by the object.
 
void push (const QScriptValue &val)
 Push a number, a Vector or a numeric Array at the end.
 
void pop ()
 Remove the last element.
 
void resize (int n)
 Resize to n elements keeping the first n.
 

Detailed Description

The prototype for the Vector class.

The Vector javascript class represents an array of floating point numbers. It is essentially a QtScript wrapper for the QDaqVector C++ class. Thus, when Qt-slots of QDaq classes are called from QtScript code, a QDaqVector passed as an argument or as return value is converted to a JS object of class Vector.

Elements of a Vector can be accesed by the [] operator and the "length" property gives the number of elements.

New elements are added at the end of the Vector with the function push().

The property called "capacity" defines for how many elements there is memory allocated.

The "circular" property is a boolean value. If it is true then the Vector is a ring or circular buffer with maximum size equal to its capacity. In a circular vector, when the capacity has been reached, insertion of a new element causes deletion of the oldest element.

A Vector can be created in QDaq scripts by the new operator in 3 possible ways:

var x1 = new Vector(10); // An empty Vector of capacity 10
var x2 = new Vector([1,2,3]); // A Vector from a numeric Array
var x3 = new Vector(x2); // x3 is a copy of x2
x2[0] // returns 1
x3.length // returns 3

The VectorPrototype class defines a number of usefull functions for handling Vector objects in script code.

Definition at line 46 of file vectorprototype.h.


The documentation for this class was generated from the following files: