29 #ifndef __ARCSARRAY_H__
30 #define __ARCSARRAY_H__
32 #include <arcs/arcsfactory.h>
58 for (
unsigned int i = 0; i < size; i++)
59 data[i] = ref.data[i];
66 void setSize(
unsigned int s)
68 unsigned int oldSize = size;
73 if (s < oldSize && oldData != 0)
75 for (i = 0; i < s; i++)
80 for (i = 0; i < oldSize; i++)
88 unsigned int getSize() {
return size; }
90 X& operator[] (
const unsigned int i) { assert(i < size);
return data[i]; }
97 for (
unsigned int i = 0; i < size; i++)
98 data[i] = ref.data[i];
104 bool allocate() {
if ( data)
delete[] data; data =
new X[size];
return data != 0; }
137 virtual QString
getTypeName()
const {
return baseType() +
"Array";}
139 virtual QString
toString(QVariant v);
143 virtual QString separator()
const {
return ":" ; }
144 virtual QString baseType()
const = 0;
153 return QString::null;
157 return QString::null;
162 for (
unsigned int i = 0; i < array.getSize() ; i++)
164 QVariant v = QVariant::fromValue(array[i]);
177 return QVariant::fromValue(array);
183 QStringList lst = s.split(separator());
185 array.setSize(lst.count());
187 for (
int i = 0; i < lst.count() ; i++)
191 if (var.canConvert<X>())
192 array[i] = var.value<X>();
195 return QVariant::fromValue(array);
198 #endif // __ARCSARRAY_H__
static ARCSFactory * getInstance()
Returns the instance of the singleton ARCSFactory.
Template class to implement array serialization.
virtual QVariant parseString(QString s)
Should create data from their string representation.
A singleton handling all needed factories in ARCS runtime.
Template class to implement arrays.
virtual QString toString(QVariant v)
Should return a string representation of data.
Generic class describing how type factories should be implemented.
virtual QString getTypeName() const
Should return the name of the type factory.
QString dataSerialize(QVariant var)
Serializes data from their QVariant counterpart.
QVariant dataDeserialize(QString type, QString representation)
Deserialize data from their string representation.