MarshaledG4String.h
Go to the documentation of this file.
1 // This file was generated automatically by marshalgen.
2 //
3 /// \file parallel/ParN02/AnnotatedFiles/MarshaledG4String.h
4 /// \brief Definition of the MaraledG4String class
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 
24 public:
25  G4String* param;
27 public:
28 
29 
30 // Function implementations
31 
32 MarshaledG4String(G4String* objptr) : MarshaledObj() {
33  msh_isUnmarshalDone = false;
34  this->param = objptr;
35  this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
36  if (objptr == NULL)
37  return;
38 
39  marshal1();
40 }
41 
42 MarshaledG4String(void *buf, char isUnmarshaling = 'u')
43 : MarshaledObj(buf, isUnmarshaling) {
44  msh_isUnmarshalDone = false;
45 }
46 
48  //if(msh_isUnmarshalDone && this->param != NULL) {
49  //delete this->param;
50  //}
51 }
52 
53 G4String* unmarshal() {
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  }
63  this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
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;
78  this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
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
100  msh_field_begin = msh_cursor;
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
119  msh_size = msh_cursor - msh_buffer;
120  MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
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 
Float_t tmp
Definition: plot.C:36
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
MarshaledG4String(G4String *objptr)
const XML_Char * s
Definition: expat.h:262
#define MSH_SET_TYPECHOICE(X)
Definition: MarshaledObj.h:21
void unmarshalTo(G4String *obj)
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
ShadowedMarshaledG4String * Shadowed_param
G4String * unmarshal()
MarshaledG4String(void *buf, char isUnmarshaling= 'u')