ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarshaledG4THitsCollection.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MarshaledG4THitsCollection.h
1 // This file was generated automatically by marshalgen.
2 
3 #ifndef MarshaledG4HitsCollection_H
4 #define MarshaledG4HitsCollection_H
5 
6 
7 #include <G4THitsCollection.hh>
8 
9 
10 #include <stdio.h>
11 #include <string.h>
12 #include "MarshaledObj.h"
13 
15 
17  friend class MarshaledG4HitsCollection;
18 };
19 
20 
21 template <class T> class MarshaledG4THitsCollection;
22 
23 template <class T>
25  friend class MarshaledG4THitsCollection<T>;
26 };
27 
29 public:
32 public:
33 
34 
35 // Function implementations
36 
38  msh_isUnmarshalDone = false;
39  this->param = objptr;
41  if (objptr == NULL)
42  return;
43 
44  marshal1();
45 }
46 
47 MarshaledG4HitsCollection(void *buf, char chIsUnmarshaling = 'u')
48 : MarshaledObj(buf, chIsUnmarshaling) {
49  msh_isUnmarshalDone = false;
50 }
51 
53  //if(msh_isUnmarshalDone && this->param != NULL) {
54  //delete this->param;
55  //}
56 }
57 
59  //We don't want to unmarshal the buffer is empty.
60  if(msh_size <= MSH_HEADER_SIZE) {
61  //This is buggy, we can't always assume that
62  //obj == NULL <==> List is empty.
63  return NULL;
64  } else {
65  {
66  param = new G4HitsCollection();
67  }
69  this->msh_isUnmarshalDone = true;
70  unmarshal1();
71  return this->param;
72  }
73 }
74 
76  //We don't want to unmarshal the buffer is empty.
77  if(msh_size <= MSH_HEADER_SIZE) {
78  //This is buggy, we can't always assume that
79  //obj == NULL <==> List is empty.
80  return;
81  } else {
82  this->param = obj;
84  this->msh_isUnmarshalDone = true;
85  unmarshal1();
86  }
87 }
88 
89 void marshal1() {
90  //declare field_size to be the size of this field
91  int msh_currentSize = 0;
92  if (isUnmarshaling())
93  throw "Tried to marshal in obj marked isUnmarshaling == true";
94 
95  //Copy the sizespec into msh_currentSize here:
96  {
97 
98  }
99 
100  //Increase the size of buffer if needed
101  EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int));
102  // 4 bytes for the total size of field, 4 bytes for the number
103  // of elements in the array (in the case of array marshaling)
104  //Mark the beginning position for this field, will write the total
105  // size of this field here later
107 
108  //Advance cursor of distance = sizeof(int)
109  msh_cursor += sizeof(int);
110 
111  //Now just copy "get" functions here
112  {
113  int copy_off = 0;
114  int elementNum;
115  elementNum = ((G4THitsCollection<ExN02TrackerHit>*)param)->entries();
116  memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
117  copy_off += sizeof(int);
118  for(int index=0;index<elementNum;index++){
119  ExN02TrackerHit* anElement;
120  anElement = (*((G4THitsCollection<ExN02TrackerHit>*)param))[index];
121  MarshaledExN02TrackerHit marEle(anElement);
122  EXTEND_BUFFER(marEle.getBufferSize());
123  memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
124  copy_off += marEle.getBufferSize();
125  }
126  msh_currentSize = copy_off;
127 
128  }
129  //Now advance the cursor
130  msh_cursor += msh_currentSize;
131  //Now set the size of this field
132  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
133  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
134  memcpy(msh_field_begin, &tmp, sizeof(int));
135 
136  //Now set msh_size
139 }
140 
141 void unmarshal1() {
142  //declare currentSize to be the size of this field
143  int msh_currentSize = 0;
144  //copy the size of the current field into currentSize
145  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
146  msh_cursor += sizeof(int);
147  //Now copy the setspec here
148  {
149  int copy_off = 0;
150  int elementNum;
151  memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
152  copy_off += sizeof(int);
153  for(int index=0;index<elementNum;index++){
154  MarshaledExN02TrackerHit marEle(msh_cursor+copy_off);
155  ExN02TrackerHit* anElement = (ExN02TrackerHit* )marEle.unmarshal();
156  copy_off += marEle.getBufferSize();
157  ((G4THitsCollection<ExN02TrackerHit>*)param)->insert((ExN02TrackerHit*)anElement);
158  }
159 
160  }
161  msh_cursor += msh_currentSize;
162 }
163 
164 };
165 template <class T> class MarshaledG4THitsCollection : public MarshaledObj {
166 public:
169 public:
170 
171 
172 // Function implementations
173 
175  msh_isUnmarshalDone = false;
176  this->param = objptr;
178  if (objptr == NULL)
179  return;
180 
181  marshal1();
182 }
183 
184 MarshaledG4THitsCollection(void *buf, char chIsUnmarshaling = 'u')
185 : MarshaledObj(buf, chIsUnmarshaling) {
186  msh_isUnmarshalDone = false;
187 }
188 
190  //if(msh_isUnmarshalDone && this->param != NULL) {
191  //delete this->param;
192  //}
193 }
194 
196  //We don't want to unmarshal the buffer is empty.
197  if(msh_size <= MSH_HEADER_SIZE) {
198  //This is buggy, we can't always assume that
199  //obj == NULL <==> List is empty.
200  return NULL;
201  } else {
202  {
203  param = new G4THitsCollection<T>();
204  }
206  this->msh_isUnmarshalDone = true;
207  unmarshal1();
208  return this->param;
209  }
210 }
211 
213  //We don't want to unmarshal the buffer is empty.
214  if(msh_size <= MSH_HEADER_SIZE) {
215  //This is buggy, we can't always assume that
216  //obj == NULL <==> List is empty.
217  return;
218  } else {
219  this->param = obj;
221  this->msh_isUnmarshalDone = true;
222  unmarshal1();
223  }
224 }
225 
226 void marshal1() {
227  //declare field_size to be the size of this field
228  int msh_currentSize = 0;
229  if (isUnmarshaling())
230  throw "Tried to marshal in obj marked isUnmarshaling == true";
231 
232  //Copy the sizespec into msh_currentSize here:
233  {
234  //code for size, just dummy code because the size will be set correctly
235  // at the end of marshaling code
236 
237  }
238 
239  //Increase the size of buffer if needed
240  EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int));
241  // 4 bytes for the total size of field, 4 bytes for the number
242  // of elements in the array (in the case of array marshaling)
243  //Mark the beginning position for this field, will write the total
244  //size of this field here later
246 
247  //Advance cursor of distance = sizeof(int)
248  msh_cursor += sizeof(int);
249 
250  //Now just copy "get" functions here
251  {
252  MarshaledG4HitsCollection marParent(param);
253  EXTEND_BUFFER(marParent.getBufferSize());
254  memcpy(msh_cursor,marParent.getBuffer(), marParent.getBufferSize());
255  msh_currentSize = marParent.getBufferSize();
256 
257  }
258  //Now advance the cursor
259  msh_cursor += msh_currentSize;
260  //Now set the size of this field
261  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
262  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
263  memcpy(msh_field_begin, &tmp, sizeof(int));
264 
265  //Now set msh_size
268 }
269 
270 void unmarshal1() {
271  //declare currentSize to be the size of this field
272  int msh_currentSize = 0;
273  //copy the size of the current field into currentSize
274  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
275  msh_cursor += sizeof(int);
276  //Now copy the setspec here
277  {
279  marObj.unmarshalTo(param);
280 
281  }
282  msh_cursor += msh_currentSize;
283 }
284 
285 };
286 #endif
287