| [807] | 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 |
|
|---|
| 14 | class MarshaledG4HitsCollection;
|
|---|
| 15 |
|
|---|
| 16 | class ShadowedMarshaledG4HitsCollection : public G4HitsCollection{
|
|---|
| 17 | friend class MarshaledG4HitsCollection;
|
|---|
| 18 | };
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | template <class T> class MarshaledG4THitsCollection;
|
|---|
| 22 |
|
|---|
| 23 | template <class T> class ShadowedMarshaledG4THitsCollection : public G4THitsCollection<T>{
|
|---|
| 24 | friend class MarshaledG4THitsCollection<T>;
|
|---|
| 25 | };
|
|---|
| 26 |
|
|---|
| 27 | class MarshaledG4HitsCollection : public MarshaledObj {
|
|---|
| 28 | public:
|
|---|
| 29 | G4HitsCollection* param;
|
|---|
| 30 | ShadowedMarshaledG4HitsCollection* Shadowed_param;
|
|---|
| 31 | public:
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | // Function implementations
|
|---|
| 35 |
|
|---|
| 36 | MarshaledG4HitsCollection(G4HitsCollection* objptr) : MarshaledObj() {
|
|---|
| 37 | msh_isUnmarshalDone = false;
|
|---|
| 38 | this->param = objptr;
|
|---|
| 39 | this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
|
|---|
| 40 | if (objptr == NULL)
|
|---|
| 41 | return;
|
|---|
| 42 |
|
|---|
| 43 | marshal1();
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | MarshaledG4HitsCollection(void *buf, char isUnmarshaling = 'u')
|
|---|
| 47 | : MarshaledObj(buf, isUnmarshaling) {
|
|---|
| 48 | msh_isUnmarshalDone = false;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | ~MarshaledG4HitsCollection() {
|
|---|
| 52 | //if(msh_isUnmarshalDone && this->param != NULL) {
|
|---|
| 53 | //delete this->param;
|
|---|
| 54 | //}
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | G4HitsCollection* unmarshal() {
|
|---|
| 58 | //We don't want to unmarshal the buffer is empty.
|
|---|
| 59 | if(msh_size <= MSH_HEADER_SIZE) {
|
|---|
| 60 | //This is buggy, we can't always assume that
|
|---|
| 61 | //obj == NULL <==> List is empty.
|
|---|
| 62 | return NULL;
|
|---|
| 63 | } else {
|
|---|
| 64 | {
|
|---|
| 65 | param = new G4HitsCollection();
|
|---|
| 66 | }
|
|---|
| 67 | this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
|
|---|
| 68 | this->msh_isUnmarshalDone = true;
|
|---|
| 69 | unmarshal1();
|
|---|
| 70 | return this->param;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | void unmarshalTo(G4HitsCollection* obj) {
|
|---|
| 75 | //We don't want to unmarshal the buffer is empty.
|
|---|
| 76 | if(msh_size <= MSH_HEADER_SIZE) {
|
|---|
| 77 | //This is buggy, we can't always assume that
|
|---|
| 78 | //obj == NULL <==> List is empty.
|
|---|
| 79 | return;
|
|---|
| 80 | } else {
|
|---|
| 81 | this->param = obj;
|
|---|
| 82 | this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
|
|---|
| 83 | this->msh_isUnmarshalDone = true;
|
|---|
| 84 | unmarshal1();
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | void marshal1() {
|
|---|
| 89 | //declare field_size to be the size of this field
|
|---|
| 90 | int msh_currentSize = 0;
|
|---|
| 91 | if (isUnmarshaling())
|
|---|
| 92 | throw "Tried to marshal in obj marked isUnmarshaling == true";
|
|---|
| 93 |
|
|---|
| 94 | //Copy the sizespec into msh_currentSize here:
|
|---|
| 95 | {
|
|---|
| 96 |
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | //Increase the size of buffer if needed
|
|---|
| 100 | 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)
|
|---|
| 101 | //Mark the beginning position for this field, will write the total size of this field here later
|
|---|
| 102 | msh_field_begin = msh_cursor;
|
|---|
| 103 |
|
|---|
| 104 | //Advance cursor of distance = sizeof(int)
|
|---|
| 105 | msh_cursor += sizeof(int);
|
|---|
| 106 |
|
|---|
| 107 | //Now just copy "get" functions here
|
|---|
| 108 | {
|
|---|
| 109 | int copy_off = 0;
|
|---|
| 110 | int elementNum;
|
|---|
| 111 | elementNum = ((G4THitsCollection<ExN02TrackerHit>*)param)->entries();
|
|---|
| 112 | memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
|
|---|
| 113 | copy_off += sizeof(int);
|
|---|
| 114 | for(int index=0;index<elementNum;index++){
|
|---|
| 115 | ExN02TrackerHit* anElement;
|
|---|
| 116 | anElement = (*((G4THitsCollection<ExN02TrackerHit>*)param))[index];
|
|---|
| 117 | MarshaledExN02TrackerHit marEle(anElement);
|
|---|
| 118 | EXTEND_BUFFER(marEle.getBufferSize());
|
|---|
| 119 | memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
|
|---|
| 120 | copy_off += marEle.getBufferSize();
|
|---|
| 121 | }
|
|---|
| 122 | msh_currentSize = copy_off;
|
|---|
| 123 |
|
|---|
| 124 | }
|
|---|
| 125 | //Now advance the cursor
|
|---|
| 126 | msh_cursor += msh_currentSize;
|
|---|
| 127 | //Now set the size of this field
|
|---|
| 128 | int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
|
|---|
| 129 | tmp = (msh_cursor-msh_field_begin) - sizeof(int);
|
|---|
| 130 | memcpy(msh_field_begin, &tmp, sizeof(int));
|
|---|
| 131 |
|
|---|
| 132 | //Now set msh_size
|
|---|
| 133 | msh_size = msh_cursor - msh_buffer;
|
|---|
| 134 | MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void unmarshal1() {
|
|---|
| 138 | //declare currentSize to be the size of this field
|
|---|
| 139 | int msh_currentSize = 0;
|
|---|
| 140 | //copy the size of the current field into currentSize
|
|---|
| 141 | memcpy(&msh_currentSize, msh_cursor, sizeof(int));
|
|---|
| 142 | msh_cursor += sizeof(int);
|
|---|
| 143 | //Now copy the setspec here
|
|---|
| 144 | {
|
|---|
| 145 | int copy_off = 0;
|
|---|
| 146 | int elementNum;
|
|---|
| 147 | memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
|
|---|
| 148 | copy_off += sizeof(int);
|
|---|
| 149 | for(int index=0;index<elementNum;index++){
|
|---|
| 150 | MarshaledExN02TrackerHit marEle(msh_cursor+copy_off);
|
|---|
| 151 | ExN02TrackerHit* anElement = (ExN02TrackerHit* )marEle.unmarshal();
|
|---|
| 152 | copy_off += marEle.getBufferSize();
|
|---|
| 153 | ((G4THitsCollection<ExN02TrackerHit>*)param)->insert((ExN02TrackerHit*)anElement);
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | }
|
|---|
| 157 | msh_cursor += msh_currentSize;
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | };
|
|---|
| 161 | template <class T> class MarshaledG4THitsCollection : public MarshaledObj {
|
|---|
| 162 | public:
|
|---|
| 163 | G4THitsCollection<T>* param;
|
|---|
| 164 | ShadowedMarshaledG4THitsCollection<T>* Shadowed_param;
|
|---|
| 165 | public:
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 | // Function implementations
|
|---|
| 169 |
|
|---|
| 170 | MarshaledG4THitsCollection(G4THitsCollection<T>* objptr) : MarshaledObj() {
|
|---|
| 171 | msh_isUnmarshalDone = false;
|
|---|
| 172 | this->param = objptr;
|
|---|
| 173 | this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
|
|---|
| 174 | if (objptr == NULL)
|
|---|
| 175 | return;
|
|---|
| 176 |
|
|---|
| 177 | marshal1();
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | MarshaledG4THitsCollection(void *buf, char isUnmarshaling = 'u')
|
|---|
| 181 | : MarshaledObj(buf, isUnmarshaling) {
|
|---|
| 182 | msh_isUnmarshalDone = false;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | ~MarshaledG4THitsCollection() {
|
|---|
| 186 | //if(msh_isUnmarshalDone && this->param != NULL) {
|
|---|
| 187 | //delete this->param;
|
|---|
| 188 | //}
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | G4THitsCollection<T>* unmarshal() {
|
|---|
| 192 | //We don't want to unmarshal the buffer is empty.
|
|---|
| 193 | if(msh_size <= MSH_HEADER_SIZE) {
|
|---|
| 194 | //This is buggy, we can't always assume that
|
|---|
| 195 | //obj == NULL <==> List is empty.
|
|---|
| 196 | return NULL;
|
|---|
| 197 | } else {
|
|---|
| 198 | {
|
|---|
| 199 | param = new G4THitsCollection<T>();
|
|---|
| 200 | }
|
|---|
| 201 | this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
|
|---|
| 202 | this->msh_isUnmarshalDone = true;
|
|---|
| 203 | unmarshal1();
|
|---|
| 204 | return this->param;
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | void unmarshalTo(G4THitsCollection<T>* obj) {
|
|---|
| 209 | //We don't want to unmarshal the buffer is empty.
|
|---|
| 210 | if(msh_size <= MSH_HEADER_SIZE) {
|
|---|
| 211 | //This is buggy, we can't always assume that
|
|---|
| 212 | //obj == NULL <==> List is empty.
|
|---|
| 213 | return;
|
|---|
| 214 | } else {
|
|---|
| 215 | this->param = obj;
|
|---|
| 216 | this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
|
|---|
| 217 | this->msh_isUnmarshalDone = true;
|
|---|
| 218 | unmarshal1();
|
|---|
| 219 | }
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | void marshal1() {
|
|---|
| 223 | //declare field_size to be the size of this field
|
|---|
| 224 | int msh_currentSize = 0;
|
|---|
| 225 | if (isUnmarshaling())
|
|---|
| 226 | throw "Tried to marshal in obj marked isUnmarshaling == true";
|
|---|
| 227 |
|
|---|
| 228 | //Copy the sizespec into msh_currentSize here:
|
|---|
| 229 | {
|
|---|
| 230 | //code for size, just dummy code because the size will be set correctly at the end of marshaling code
|
|---|
| 231 |
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | //Increase the size of buffer if needed
|
|---|
| 235 | 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)
|
|---|
| 236 | //Mark the beginning position for this field, will write the total size of this field here later
|
|---|
| 237 | msh_field_begin = msh_cursor;
|
|---|
| 238 |
|
|---|
| 239 | //Advance cursor of distance = sizeof(int)
|
|---|
| 240 | msh_cursor += sizeof(int);
|
|---|
| 241 |
|
|---|
| 242 | //Now just copy "get" functions here
|
|---|
| 243 | {
|
|---|
| 244 | MarshaledG4HitsCollection marParent(param);
|
|---|
| 245 | EXTEND_BUFFER(marParent.getBufferSize());
|
|---|
| 246 | memcpy(msh_cursor,marParent.getBuffer(), marParent.getBufferSize());
|
|---|
| 247 | msh_currentSize = marParent.getBufferSize();
|
|---|
| 248 |
|
|---|
| 249 | }
|
|---|
| 250 | //Now advance the cursor
|
|---|
| 251 | msh_cursor += msh_currentSize;
|
|---|
| 252 | //Now set the size of this field
|
|---|
| 253 | int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
|
|---|
| 254 | tmp = (msh_cursor-msh_field_begin) - sizeof(int);
|
|---|
| 255 | memcpy(msh_field_begin, &tmp, sizeof(int));
|
|---|
| 256 |
|
|---|
| 257 | //Now set msh_size
|
|---|
| 258 | msh_size = msh_cursor - msh_buffer;
|
|---|
| 259 | MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | void unmarshal1() {
|
|---|
| 263 | //declare currentSize to be the size of this field
|
|---|
| 264 | int msh_currentSize = 0;
|
|---|
| 265 | //copy the size of the current field into currentSize
|
|---|
| 266 | memcpy(&msh_currentSize, msh_cursor, sizeof(int));
|
|---|
| 267 | msh_cursor += sizeof(int);
|
|---|
| 268 | //Now copy the setspec here
|
|---|
| 269 | {
|
|---|
| 270 | MarshaledG4HitsCollection marObj(msh_cursor);
|
|---|
| 271 | marObj.unmarshalTo(param);
|
|---|
| 272 |
|
|---|
| 273 | }
|
|---|
| 274 | msh_cursor += msh_currentSize;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | };
|
|---|
| 278 | #endif
|
|---|
| 279 |
|
|---|