LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MarshaledG4HitsCollection Class Reference

#include "MarshaledG4THitsCollection.h"

Inheritance diagram for MarshaledG4HitsCollection:

Public Member Functions

 MarshaledG4HitsCollection (G4HitsCollection *objptr)
 
 MarshaledG4HitsCollection (void *buf, char isUnmarshaling= 'u')
 
 ~MarshaledG4HitsCollection ()
 
G4HitsCollectionunmarshal ()
 
void unmarshalTo (G4HitsCollection *obj)
 
void marshal1 ()
 
void unmarshal1 ()
 
 MarshaledG4HitsCollection (G4HitsCollection *objptr)
 
 MarshaledG4HitsCollection (void *buf, char isUnmarshaling= 'u')
 
 ~MarshaledG4HitsCollection ()
 
G4HitsCollectionunmarshal ()
 
void unmarshalTo (G4HitsCollection *obj)
 
void marshal1 ()
 
void unmarshal1 ()
 

Public Attributes

G4HitsCollectionparam
 
ShadowedMarshaledG4HitsCollectionShadowed_param
 

Detailed Description

Definition at line 30 of file MarshaledG4THitsCollection.h.

Constructor & Destructor Documentation

MarshaledG4HitsCollection::MarshaledG4HitsCollection ( G4HitsCollection objptr)
inline

Definition at line 39 of file MarshaledG4THitsCollection.h.

39  : MarshaledObj() {
40  msh_isUnmarshalDone = false;
41  this->param = objptr;
43  if (objptr == NULL)
44  return;
45 
46  marshal1();
47 }
ShadowedMarshaledG4HitsCollection * Shadowed_param
MarshaledG4HitsCollection::MarshaledG4HitsCollection ( void *  buf,
char  isUnmarshaling = 'u' 
)
inline

Definition at line 49 of file MarshaledG4THitsCollection.h.

50 : MarshaledObj(buf, isUnmarshaling) {
51  msh_isUnmarshalDone = false;
52 }
MarshaledG4HitsCollection::~MarshaledG4HitsCollection ( )
inline

Definition at line 54 of file MarshaledG4THitsCollection.h.

54  {
55  //if(msh_isUnmarshalDone && this->param != NULL) {
56  //delete this->param;
57  //}
58 }
MarshaledG4HitsCollection::MarshaledG4HitsCollection ( G4HitsCollection objptr)
inline

Definition at line 47 of file MarshaledG4THitsCollection.h.

47  : MarshaledObj() {
48  msh_isUnmarshalDone = false;
49  this->param = objptr;
51  if (objptr == NULL)
52  return;
53 
54  marshal1();
55 }
ShadowedMarshaledG4HitsCollection * Shadowed_param
MarshaledG4HitsCollection::MarshaledG4HitsCollection ( void *  buf,
char  isUnmarshaling = 'u' 
)
inline

Definition at line 57 of file MarshaledG4THitsCollection.h.

58 : MarshaledObj(buf, isUnmarshaling) {
59  msh_isUnmarshalDone = false;
60 }
MarshaledG4HitsCollection::~MarshaledG4HitsCollection ( )
inline

Definition at line 62 of file MarshaledG4THitsCollection.h.

62  {
63  //if(msh_isUnmarshalDone && this->param != NULL) {
64  //delete this->param;
65  //}
66 }

Member Function Documentation

void MarshaledG4HitsCollection::marshal1 ( )
inline

Definition at line 91 of file MarshaledG4THitsCollection.h.

References tmp.

91  {
92  //declare field_size to be the size of this field
93  int msh_currentSize = 0;
94  if (isUnmarshaling())
95  throw "Tried to marshal in obj marked isUnmarshaling == true";
96 
97  //Copy the sizespec into msh_currentSize here:
98  {
99 
100  }
101 
102  //Increase the size of buffer if needed
103  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)
104  //Mark the beginning position for this field, will write the total size of this field here later
105  msh_field_begin = msh_cursor;
106 
107  //Advance cursor of distance = sizeof(int)
108  msh_cursor += sizeof(int);
109 
110  //Now just copy "get" functions here
111  {
112  int copy_off = 0;
113  int elementNum;
114  elementNum = ((G4THitsCollection<ExN02TrackerHit>*)param)->entries();
115  memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
116  copy_off += sizeof(int);
117  for(int index=0;index<elementNum;index++){
118  ExN02TrackerHit* anElement;
119  anElement = (*((G4THitsCollection<ExN02TrackerHit>*)param))[index];
120  MarshaledExN02TrackerHit marEle(anElement);
121  EXTEND_BUFFER(marEle.getBufferSize());
122  memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
123  copy_off += marEle.getBufferSize();
124  }
125  msh_currentSize = copy_off;
126 
127  }
128  //Now advance the cursor
129  msh_cursor += msh_currentSize;
130  //Now set the size of this field
131  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
132  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
133  memcpy(msh_field_begin, &tmp, sizeof(int));
134 
135  //Now set msh_size
136  msh_size = msh_cursor - msh_buffer;
137  MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
138 }
Float_t tmp
Definition: plot.C:35
void MarshaledG4HitsCollection::marshal1 ( )
inline

Definition at line 99 of file MarshaledG4THitsCollection.h.

References tmp.

99  {
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 }
Float_t tmp
Definition: plot.C:35
G4HitsCollection* MarshaledG4HitsCollection::unmarshal ( )
inline

Definition at line 60 of file MarshaledG4THitsCollection.h.

References G4HitsCollection::G4HitsCollection().

60  {
61  //We don't want to unmarshal the buffer is empty.
62  if(msh_size <= MSH_HEADER_SIZE) {
63  //This is buggy, we can't always assume that
64  //obj == NULL <==> List is empty.
65  return NULL;
66  } else {
67  {
68  param = new G4HitsCollection();
69  }
71  this->msh_isUnmarshalDone = true;
72  unmarshal1();
73  return this->param;
74  }
75 }
ShadowedMarshaledG4HitsCollection * Shadowed_param
G4HitsCollection* MarshaledG4HitsCollection::unmarshal ( )
inline

Definition at line 68 of file MarshaledG4THitsCollection.h.

References G4HitsCollection::G4HitsCollection().

68  {
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  }
79  this->msh_isUnmarshalDone = true;
80  unmarshal1();
81  return this->param;
82  }
83 }
ShadowedMarshaledG4HitsCollection * Shadowed_param
void MarshaledG4HitsCollection::unmarshal1 ( )
inline

Definition at line 140 of file MarshaledG4THitsCollection.h.

140  {
141  //declare currentSize to be the size of this field
142  int msh_currentSize = 0;
143  //copy the size of the current field into currentSize
144  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
145  msh_cursor += sizeof(int);
146  //Now copy the setspec here
147  {
148  int copy_off = 0;
149  int elementNum;
150  memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
151  copy_off += sizeof(int);
152  for(int index=0;index<elementNum;index++){
153  MarshaledExN02TrackerHit marEle(msh_cursor+copy_off);
154  ExN02TrackerHit* anElement = (ExN02TrackerHit* )marEle.unmarshal();
155  copy_off += marEle.getBufferSize();
156  ((G4THitsCollection<ExN02TrackerHit>*)param)->insert((ExN02TrackerHit*)anElement);
157  }
158 
159  }
160  msh_cursor += msh_currentSize;
161 }
void MarshaledG4HitsCollection::unmarshal1 ( )
inline

Definition at line 195 of file MarshaledG4THitsCollection.h.

195  {
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 }
void MarshaledG4HitsCollection::unmarshalTo ( G4HitsCollection obj)
inline

Definition at line 77 of file MarshaledG4THitsCollection.h.

Referenced by MarshaledG4THitsCollection< T >::unmarshal1().

77  {
78  //We don't want to unmarshal the buffer is empty.
79  if(msh_size <= MSH_HEADER_SIZE) {
80  //This is buggy, we can't always assume that
81  //obj == NULL <==> List is empty.
82  return;
83  } else {
84  this->param = obj;
86  this->msh_isUnmarshalDone = true;
87  unmarshal1();
88  }
89 }
ShadowedMarshaledG4HitsCollection * Shadowed_param
void MarshaledG4HitsCollection::unmarshalTo ( G4HitsCollection obj)
inline

Definition at line 85 of file MarshaledG4THitsCollection.h.

85  {
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;
94  this->msh_isUnmarshalDone = true;
95  unmarshal1();
96  }
97 }
ShadowedMarshaledG4HitsCollection * Shadowed_param

Member Data Documentation

G4HitsCollection * MarshaledG4HitsCollection::param

Definition at line 32 of file MarshaledG4THitsCollection.h.

ShadowedMarshaledG4HitsCollection * MarshaledG4HitsCollection::Shadowed_param

Definition at line 33 of file MarshaledG4THitsCollection.h.


The documentation for this class was generated from the following file: