LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
MarshaledG4THitsCollection.h
Go to the documentation of this file.
1 //
4 //
5 // This file was generated automatically by marshalgen.
6 
7 #ifndef MarshaledG4HitsCollection_H
8 #define MarshaledG4HitsCollection_H
9 
10 
11 #include <G4THitsCollection.hh>
12 //MSH_include_begin
13 #include "ExN04CalorimeterHit.hh"
14 #include "ExN04MuonHit.hh"
15 #include "ExN04TrackerHit.hh"
16 #include "MarshaledExN04CalorimeterHit.h"
17 #include "MarshaledExN04MuonHit.h"
18 #include "MarshaledExN04TrackerHit.h"
19 //MSH_include_end
20 
21 #include <stdio.h>
22 #include <string.h>
23 #include "MarshaledObj.h"
24 
26 
28  friend class MarshaledG4HitsCollection;
29 };
30 
31 
32 template <class T> class MarshaledG4THitsCollection;
33 
34 template <class T> class ShadowedMarshaledG4THitsCollection : public G4THitsCollection<T>{
35  friend class MarshaledG4THitsCollection<T>;
36 };
37 
38  class MarshaledG4HitsCollection : public MarshaledObj {
39 public:
40  G4HitsCollection* param;
41  ShadowedMarshaledG4HitsCollection* Shadowed_param;
42 public:
43 
44 
45 // Function implementations
46 
47 MarshaledG4HitsCollection(G4HitsCollection* objptr) : MarshaledObj() {
48  msh_isUnmarshalDone = false;
49  this->param = objptr;
50  this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
51  if (objptr == NULL)
52  return;
53 
54  marshal1();
55 }
56 
57 MarshaledG4HitsCollection(void *buf, char isUnmarshaling = 'u')
58 : MarshaledObj(buf, isUnmarshaling) {
59  msh_isUnmarshalDone = false;
60 }
61 
63  //if(msh_isUnmarshalDone && this->param != NULL) {
64  //delete this->param;
65  //}
66 }
67 
69  //We don't want to unmarshal the buffer is empty.
70  if(msh_size <= MSH_HEADER_SIZE) {
71  //This is buggy, we can't always assume that
72  //obj == NULL <==> List is empty.
73  return NULL;
74  } else {
75  {
76  param = new G4HitsCollection();
77  }
78  this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
79  this->msh_isUnmarshalDone = true;
80  unmarshal1();
81  return this->param;
82  }
83 }
84 
86  //We don't want to unmarshal the buffer is empty.
87  if(msh_size <= MSH_HEADER_SIZE) {
88  //This is buggy, we can't always assume that
89  //obj == NULL <==> List is empty.
90  return;
91  } else {
92  this->param = obj;
93  this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
94  this->msh_isUnmarshalDone = true;
95  unmarshal1();
96  }
97 }
98 
99 void marshal1() {
100  //declare field_size to be the size of this field
101  int msh_currentSize = 0;
102  if (isUnmarshaling())
103  throw "Tried to marshal in obj marked isUnmarshaling == true";
104 
105  //Copy the sizespec into msh_currentSize here:
106  {
107 
108  }
109 
110  //Increase the size of buffer if needed
111  EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
112  //Mark the beginning position for this field, will write the total size of this field here later
113  msh_field_begin = msh_cursor;
114 
115  //Advance cursor of distance = sizeof(int)
116  msh_cursor += sizeof(int);
117 
118  //Now just copy "get" functions here
119  {
120  int copy_off = 0;
121  int elementNum;
122 
123  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
124  elementNum = ((G4THitsCollection<ExN04CalorimeterHit>*)param)->entries();
125  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
126  elementNum = ((G4THitsCollection<ExN04MuonHit>*)param)->entries();
127  else
128  elementNum = ((G4THitsCollection<ExN04TrackerHit>*)param)->entries();
129 
130  memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
131  copy_off += sizeof(int);
132  for(int index=0;index<elementNum;index++){
133  if(0){}
134  else if((dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL) ){
135  void* anElement;
136 
137  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
138  anElement = (*((G4THitsCollection<ExN04CalorimeterHit>*)param))[index];
139  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
140  anElement = (*((G4THitsCollection<ExN04MuonHit>*)param))[index];
141  else
142  anElement = (*((G4THitsCollection<ExN04TrackerHit>*)param))[index];
143 
144  MarshaledExN04CalorimeterHit marEle((ExN04CalorimeterHit* )anElement);
145  EXTEND_BUFFER(marEle.getBufferSize());
146  memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
147  copy_off += marEle.getBufferSize();
148  }
149  else if( (dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL) ){
150  void* anElement;
151 
152  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
153  anElement = (*((G4THitsCollection<ExN04CalorimeterHit>*)param))[index];
154  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
155  anElement = (*((G4THitsCollection<ExN04MuonHit>*)param))[index];
156  else
157  anElement = (*((G4THitsCollection<ExN04TrackerHit>*)param))[index];
158 
159  MarshaledExN04MuonHit marEle((ExN04MuonHit* )anElement);
160  EXTEND_BUFFER(marEle.getBufferSize());
161  memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
162  copy_off += marEle.getBufferSize();
163  }
164  else if( true ){
165  void* anElement;
166 
167  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
168  anElement = (*((G4THitsCollection<ExN04CalorimeterHit>*)param))[index];
169  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
170  anElement = (*((G4THitsCollection<ExN04MuonHit>*)param))[index];
171  else
172  anElement = (*((G4THitsCollection<ExN04TrackerHit>*)param))[index];
173 
174  MarshaledExN04TrackerHit marEle((ExN04TrackerHit*)anElement);
175  EXTEND_BUFFER(marEle.getBufferSize());
176  memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
177  copy_off += marEle.getBufferSize();
178  }
179  }
180  msh_currentSize = copy_off;
181 
182  }
183  //Now advance the cursor
184  msh_cursor += msh_currentSize;
185  //Now set the size of this field
186  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
187  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
188  memcpy(msh_field_begin, &tmp, sizeof(int));
189 
190  //Now set msh_size
191  msh_size = msh_cursor - msh_buffer;
192  MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
193 }
194 
195 void unmarshal1() {
196  //declare currentSize to be the size of this field
197  int msh_currentSize = 0;
198  //copy the size of the current field into currentSize
199  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
200  msh_cursor += sizeof(int);
201  //Now copy the setspec here
202  {
203  if(0){}
204  else if((dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL) ){
205  int copy_off = 0;
206  int elementNum;
207  memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
208  copy_off += sizeof(int);
209  for(int index=0;index<elementNum;index++){
210  MarshaledExN04CalorimeterHit marEle(msh_cursor+copy_off);
211  ExN04CalorimeterHit* anElement = (ExN04CalorimeterHit* )marEle.unmarshal();
212  copy_off += marEle.getBufferSize();
213 
214  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
215  ((G4THitsCollection<ExN04CalorimeterHit>*)param)->insert((ExN04CalorimeterHit*)anElement);
216  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
217  ((G4THitsCollection<ExN04MuonHit>*)param)->insert((ExN04MuonHit*)anElement);
218  else
219  ((G4THitsCollection<ExN04TrackerHit>*)param)->insert((ExN04TrackerHit*)anElement);
220 
221  }
222  }
223  else if( (dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL) ){
224  int copy_off = 0;
225  int elementNum;
226  memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
227  copy_off += sizeof(int);
228  for(int index=0;index<elementNum;index++){
229  MarshaledExN04MuonHit marEle(msh_cursor+copy_off);
230  ExN04MuonHit* anElement = (ExN04MuonHit* )marEle.unmarshal();
231  copy_off += marEle.getBufferSize();
232 
233  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
234  ((G4THitsCollection<ExN04CalorimeterHit>*)param)->insert((ExN04CalorimeterHit*)anElement);
235  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
236  ((G4THitsCollection<ExN04MuonHit>*)param)->insert((ExN04MuonHit*)anElement);
237  else
238  ((G4THitsCollection<ExN04TrackerHit>*)param)->insert((ExN04TrackerHit*)anElement);
239 
240  }
241  }
242  else if( true ){
243  int copy_off = 0;
244  int elementNum;
245  memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
246  copy_off += sizeof(int);
247  for(int index=0;index<elementNum;index++){
248  MarshaledExN04TrackerHit marEle(msh_cursor+copy_off);
249  ExN04TrackerHit* anElement = (ExN04TrackerHit*)marEle.unmarshal();
250  copy_off += marEle.getBufferSize();
251 
252  if(dynamic_cast<G4THitsCollection<ExN04CalorimeterHit>*>(param)!=NULL)
253  ((G4THitsCollection<ExN04CalorimeterHit>*)param)->insert((ExN04CalorimeterHit*)anElement);
254  else if(dynamic_cast<G4THitsCollection<ExN04MuonHit>*>(param)!=NULL)
255  ((G4THitsCollection<ExN04MuonHit>*)param)->insert((ExN04MuonHit*)anElement);
256  else
257  ((G4THitsCollection<ExN04TrackerHit>*)param)->insert((ExN04TrackerHit*)anElement);
258 
259  }
260  }
261 
262  }
263  msh_cursor += msh_currentSize;
264 }
265 
266 };
267 template <class T> class MarshaledG4THitsCollection : public MarshaledObj {
268 public:
269  G4THitsCollection<T>* param;
271 public:
272 
273 
274 // Function implementations
275 
277  msh_isUnmarshalDone = false;
278  this->param = objptr;
279  this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
280  if (objptr == NULL)
281  return;
282 
283  marshal1();
284 }
285 
286 MarshaledG4THitsCollection(void *buf, char isUnmarshaling = 'u')
287 : MarshaledObj(buf, isUnmarshaling) {
288  msh_isUnmarshalDone = false;
289 }
290 
292  //if(msh_isUnmarshalDone && this->param != NULL) {
293  //delete this->param;
294  //}
295 }
296 
298  //We don't want to unmarshal the buffer is empty.
299  if(msh_size <= MSH_HEADER_SIZE) {
300  //This is buggy, we can't always assume that
301  //obj == NULL <==> List is empty.
302  return NULL;
303  } else {
304  {
305  param = new G4THitsCollection<T>();
306  }
307  this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
308  this->msh_isUnmarshalDone = true;
309  unmarshal1();
310  return this->param;
311  }
312 }
313 
315  //We don't want to unmarshal the buffer is empty.
316  if(msh_size <= MSH_HEADER_SIZE) {
317  //This is buggy, we can't always assume that
318  //obj == NULL <==> List is empty.
319  return;
320  } else {
321  this->param = obj;
322  this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
323  this->msh_isUnmarshalDone = true;
324  unmarshal1();
325  }
326 }
327 
328 void marshal1() {
329  //declare field_size to be the size of this field
330  int msh_currentSize = 0;
331  if (isUnmarshaling())
332  throw "Tried to marshal in obj marked isUnmarshaling == true";
333 
334  //Copy the sizespec into msh_currentSize here:
335  {
336  //code for size, just dummy code because the size will be set correctly at the end of marshaling code
337 
338  }
339 
340  //Increase the size of buffer if needed
341  EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
342  //Mark the beginning position for this field, will write the total size of this field here later
343  msh_field_begin = msh_cursor;
344 
345  //Advance cursor of distance = sizeof(int)
346  msh_cursor += sizeof(int);
347 
348  //Now just copy "get" functions here
349  {
350  MarshaledG4HitsCollection marParent(param);
351  EXTEND_BUFFER(marParent.getBufferSize());
352  memcpy(msh_cursor,marParent.getBuffer(), marParent.getBufferSize());
353  msh_currentSize = marParent.getBufferSize();
354 
355  }
356  //Now advance the cursor
357  msh_cursor += msh_currentSize;
358  //Now set the size of this field
359  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
360  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
361  memcpy(msh_field_begin, &tmp, sizeof(int));
362 
363  //Now set msh_size
364  msh_size = msh_cursor - msh_buffer;
365  MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
366 }
367 
368 void unmarshal1() {
369  //declare currentSize to be the size of this field
370  int msh_currentSize = 0;
371  //copy the size of the current field into currentSize
372  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
373  msh_cursor += sizeof(int);
374  //Now copy the setspec here
375  {
376  MarshaledG4HitsCollection marObj(msh_cursor);
377  marObj.unmarshalTo(param);
378 
379  }
380  msh_cursor += msh_currentSize;
381 }
382 
383 };
384 #endif
385 
MarshaledG4HitsCollection(G4HitsCollection *objptr)
MarshaledG4HitsCollection(void *buf, char isUnmarshaling= 'u')
Float_t tmp
Definition: plot.C:37
void unmarshalTo(G4THitsCollection< T > *obj)
G4THitsCollection< T > * unmarshal()
void unmarshalTo(G4HitsCollection *obj)
MarshaledG4THitsCollection(G4THitsCollection< T > *objptr)
MarshaledG4THitsCollection(void *buf, char isUnmarshaling= 'u')