ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarshaledG4String.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MarshaledG4String.h
1 
2 
3 //
4 // This file was generated automatically by marshalgen.
5 
6 #ifndef MarshaledG4String_H
7 #define MarshaledG4String_H
8 
9 
10 #include <G4String.hh>
11 
12 
13 #include <stdio.h>
14 #include <string.h>
15 #include "MarshaledObj.h"
16 
17  class MarshaledG4String;
18 
19  class ShadowedMarshaledG4String : public G4String{
20  friend class MarshaledG4String;
21 };
22 
23  class MarshaledG4String : public MarshaledObj {
24 public:
25  G4String* param;
27 public:
28 
29 
30 // Function implementations
31 
33  msh_isUnmarshalDone = false;
34  this->param = objptr;
36  if (objptr == NULL)
37  return;
38 
39  marshal1();
40 }
41 
42 MarshaledG4String(void *buf, char isUnmarshaling = 'u')
44  msh_isUnmarshalDone = false;
45 }
46 
48  //if(msh_isUnmarshalDone && this->param != NULL) {
49  //delete this->param;
50  //}
51 }
52 
54  //We don't want to unmarshal the buffer is empty.
55  if(msh_size <= MSH_HEADER_SIZE) {
56  //This is buggy, we can't always assume that
57  //obj == NULL <==> List is empty.
58  return NULL;
59  } else {
60  {
61  param = new G4String();
62  }
64  this->msh_isUnmarshalDone = true;
65  unmarshal1();
66  return this->param;
67  }
68 }
69 
70 void unmarshalTo(G4String* obj) {
71  //We don't want to unmarshal the buffer is empty.
72  if(msh_size <= MSH_HEADER_SIZE) {
73  //This is buggy, we can't always assume that
74  //obj == NULL <==> List is empty.
75  return;
76  } else {
77  this->param = obj;
79  this->msh_isUnmarshalDone = true;
80  unmarshal1();
81  }
82 }
83 
84 void marshal1() {
85  //declare field_size to be the size of this field
86  int msh_currentSize = 0;
87  if (isUnmarshaling())
88  throw "Tried to marshal in obj marked isUnmarshaling == true";
89 
90  //Copy the sizespec into msh_currentSize here:
91  {
92  int size = param->size()+1;
93  while(size%8) size++;
94  msh_currentSize = size;
95  }
96 
97  //Increase the size of buffer if needed
98  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)
99  //Mark the beginning position for this field, will write the total size of this field here later
101 
102  //Advance cursor of distance = sizeof(int)
103  msh_cursor += sizeof(int);
104 
105  //Now just copy "get" functions here
106  {
107  memcpy(msh_cursor, param->c_str(), param->size());
108  *(msh_cursor+param->size()) = '\0';
109 
110  }
111  //Now advance the cursor
112  msh_cursor += msh_currentSize;
113  //Now set the size of this field
114  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
115  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
116  memcpy(msh_field_begin, &tmp, sizeof(int));
117 
118  //Now set msh_size
121 }
122 
123 void unmarshal1() {
124  //declare currentSize to be the size of this field
125  int msh_currentSize = 0;
126  //copy the size of the current field into currentSize
127  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
128  msh_cursor += sizeof(int);
129  //Now copy the setspec here
130  {
131  G4String* s = new G4String(msh_cursor);
132  memcpy(param, s, sizeof(G4String));
133 
134  }
135  msh_cursor += msh_currentSize;
136 }
137 
138 };
139 #endif
140