1 package org.lcsim.lcio;
2
3 import hep.io.sio.SIOInputStream;
4 import hep.io.sio.SIOOutputStream;
5 import hep.io.sio.SIORef;
6 import java.io.IOException;
7 import java.util.ListIterator;
8 import org.lcsim.event.MCParticle;
9
10
11
12
13
14 class SIOReferencesBlockHandler extends AbstractBlockHandler
15 {
16 private String type;
17 private Class classForType;
18 SIOReferencesBlockHandler(String type, Class classForType)
19 {
20 this.type = type;
21 this.classForType = classForType;
22 }
23 public String getType() { return type; }
24 public Class getClassForType() { return classForType; }
25
26 LCIOCallback addCollectionElements(LCIOEvent event, final LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
27 {
28 for (int i = 0; i < n; i++) collection.add(in.readPntr());
29 return new LCIOCallback()
30 {
31 public void callback()
32 {
33 for (ListIterator iter = collection.listIterator(); iter.hasNext(); )
34 {
35 SIORef ref = (SIORef) iter.next();
36 iter.set(ref.getObject());
37 }
38 }
39 };
40 }
41
42 void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException
43 {
44 out.writePntr(element);
45 }
46 }