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