The class Collection.
Collection c1;
Collection *c2= new Collection;
To copy a specified collection in an other collection, use:
Collection *c1, *c2; ... *c1=*c2;
Collection *c2; ... Collection *c3=c2->Clone();
c1.Delete();
SETVALUE( name, type, value ) (type is from Pandore basic types: Uchar, Slong, Ulong, Float... - int is not allowed)
;SETARRAY( name, type, pointer_to_array, number_of_items ) (type is from Pandore basic types: Uchar, Slong, Ulong, Float... - int is not allowed)
;SETPOBJECT( name, type, pointer_to_object )
;SETPARRAY( name, type, pointer_to_object, number_of_items )
.The easiest way to get a data from a collection is to use the following macros:
GETVALUE( name, type )
;GETARRAY( name, type )
+ GETARRAYSIZE( name, type )
;GETPOBJECT( name, type )
;GETPARRAY( name, type )
+ GETPARRAYSIZE( name, type )
.Examples:
Collection col; Float f=1.2; col.SETVALUE("foo",Float,f); f=col.GETVALUE("foo",Float);
Collection col; Ushort *t1 = new Ushort[15]; *t2; col.SETARRAY("bar",Ushort,t1,15); int x=col.GETARRAYSIZE("bar",Ushort); t2=col.GETARRAY("bar",Ushort);
Collection col; Imc3duc *im1=new Imc3duc(25,45,260), *im2; col.SETPOBJECT("foo",Imc3duc,im1) im2=col.GETPOBJECT("foo",Imc3duc)
Collection col; Point2d **p1, **p2; p1=new Point2d*[12]; for (int i=0; i<12; i++) p1[i]=new Point2d(i,i); col.SETPARRAY("bar",Point2d,p1,12); p2=(Point2d**)col.GETPARRAY("bar",Point2d);
SETARRAY
, SETPOBJECT
and SETPARRAY
do not make a copy of the data, it is just a reference to the object. Consequently, the following example generates an error because p1 is a local array that is deleted at the end of the function Bar. Errc Bar( Collection &cold ) {
Point2d p1[12];
cold.SETPARRAY("foo",Point2d,p1,12);
}
NbOf()
returns the number of components and GETNARRAYS()
returns the list of arrays. For example: Collection col; Long minsize, size; std::string type; col.NbOf("foo",type,size,minsize); if (type == "Array:Char") { Char **foo=cold.GETNARRAYS("foo",Char,size,minsize) for (int i=0; i<size; i++) { Char* foo_i=foo[i]; for (c=0; c<minsize; c++) { < ... using foo_i[c] ... > } } }
Collection col;
col.SaveFile("foobar.pan");
To load a collection, just use:
Collection col;
col2.LoadFile("foobar.pan");