QDaq
0.2.6
Qt-based Data Aqcuisition
|
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. | |
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:
The VectorPrototype class defines a number of usefull functions for handling Vector objects in script code.
Definition at line 46 of file vectorprototype.h.