comparison m-toolbox/html_help/help/ug/collection_objects_content.html @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 <p>
2 Collection objects serve as merely a wrapper for a cell-array of LTPDA User Objects. The point of this is to provide
3 a way to put together user objects of different classes in to a collection which can be saved/loaded/submitted/retrieved, etc.
4 </p>
5 <p>
6 You can create a <tt>collection</tt> object like:
7 <div class="fragment"><pre>
8 >> c = collection
9 ---- collection 1 ----
10 name: none
11 num objs: 0
12 description:
13 UUID: a339a156-956b-4657-96ef-9ea4feef8101
14 ----------------------
15
16 </pre></div>
17 You can then add objects to the collection by doing:
18 <div class="fragment"><pre>
19 >> c.addObjects(ao(1))
20 M: running ao/ao
21 M: constructing from values
22 M: running collection/addObjects
23 M: running ao/char
24 ---- collection 1 ----
25 name: none
26 num objs: 1
27 01: ao | None/cdata(Ndata=[1x1])
28 description:
29 UUID: c1f0200f-ad98-4fd6-beae-2dcdabb33515
30 ----------------------
31
32 </pre></div>
33 or
34 <div class="fragment"><pre>
35 >> c.addObjects(pzmodel(1, 10, 100), mfir())
36 M: running collection/addObjects
37 M: running ao/char
38 ---- collection 1 ----
39 name: none
40 num objs: 3
41 01: ao | None/cdata(Ndata=[1x1])
42 02: pzmodel | pzmodel(None)
43 03: mfir | none(fs=, ntaps=0.00, a=[])
44 description:
45 UUID: e7f02380-5650-4788-b819-f7fa7ee50a7d
46 ----------------------
47
48 </pre></div>
49 </p>
50 <p>
51 You can then extract objects from the collection using <tt>getObjectAtIndex</tt> or get an array of all
52 objects of a particular class using <tt>getObjectsOfClass</tt>. Objects can be removed from the collection using
53 <tt>removeObjectAtIndex</tt>.
54 </p>
55 <p>
56 Since a <tt>collection</tt> object is an LTPDA User Object, it has history tracking capabilities. That means that everytime you
57 add or remove an object to/from the collection, a history step is added. For example, the history of our collection above looks like:
58 <img src="images/collection_history.png" alt="Collection history" border="3">
59 </p>