Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarshaledObj Class Reference

#include <MarshaledObj.h>

Inheritance diagram for MarshaledObj:

Public Member Functions

 MarshaledObj ()
 
 MarshaledObj (void *buf, char chIsUnmarshaling)
 
 ~MarshaledObj ()
 
bool isUnmarshaling ()
 
void EXTEND_BUFFER (int size)
 
void resizeBuffer (size_t new_size)
 
int getBufferSize ()
 
char * getBuffer ()
 
void marshalPrimitive (void *p, int size)
 
void unmarshalPrimitive (void *p, int size)
 
 MarshaledObj ()
 
 MarshaledObj (void *buf, char chIsUnmarshaling)
 
 ~MarshaledObj ()
 
bool isUnmarshaling ()
 
void EXTEND_BUFFER (int size)
 
void resizeBuffer (size_t new_size)
 
int getBufferSize ()
 
char * getBuffer ()
 
void marshalPrimitive (void *p, int size)
 
void unmarshalPrimitive (void *p, int size)
 

Static Public Member Functions

static int ROUND_UP (int x)
 
static int ROUND_UP (int x)
 

Protected Attributes

int msh_typechoice
 
char * msh_buffer
 
char * msh_field_begin
 
size_t msh_size
 
char * msh_cursor
 
size_t msh_extent
 
bool msh_isUnmarshalDone
 

Detailed Description

Definition at line 27 of file MarshaledObj.h.

Constructor & Destructor Documentation

MarshaledObj::MarshaledObj ( )
inline

Definition at line 38 of file MarshaledObj.h.

38  {
39  msh_extent = 128;
41  msh_isUnmarshalDone = false;
42 
43  msh_buffer = (char *)malloc(msh_extent);
45 
48 
49  msh_typechoice = 0;
50  int totalsize = msh_cursor-msh_buffer;
51 
53  MSH_SET_TOTALSIZE(totalsize);
54  }
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
size_t msh_extent
Definition: MarshaledObj.h:117
#define MSH_SET_TYPECHOICE(X)
Definition: MarshaledObj.h:21
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_buffer
Definition: MarshaledObj.h:104
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file MarshaledObj.h.

62  {
63  msh_isUnmarshalDone = false;
64 
65  if(chIsUnmarshaling != 'u') {
66  printf("MarshaledObj(void*, char): wrong argument\n");
67  return;
68  }
69 
70  //msh_extent = ROUND_UP(*(int *)buf + sizeof(int));
72 
75 
76  msh_buffer = (char *)malloc(msh_extent);
78 
79  memcpy(msh_buffer, (char *)buf, msh_extent);
82 
83  //MSH_SET_TYPECHOICE(msh_typechoice);
84 
85  }
#define MSH_GET_TOTALSIZE(X, BUF)
Definition: MarshaledObj.h:24
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
static int ROUND_UP(int x)
Definition: MarshaledObj.h:32
size_t msh_extent
Definition: MarshaledObj.h:117
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
#define MSH_GET_TYPECHOICE(X, BUF)
Definition: MarshaledObj.h:23
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file MarshaledObj.h.

87  {
88  if ( ! isUnmarshaling() )
90  }
bool isUnmarshaling()
Definition: MarshaledObj.h:92
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

MarshaledObj::MarshaledObj ( )
inline

Definition at line 38 of file MarshaledObj.h.

38  {
39  msh_extent = 128;
41  msh_isUnmarshalDone = false;
42 
43  msh_buffer = (char *)malloc(msh_extent);
45 
48 
49  msh_typechoice = 0;
50  int totalsize = msh_cursor-msh_buffer;
51 
53  MSH_SET_TOTALSIZE(totalsize);
54  }
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
size_t msh_extent
Definition: MarshaledObj.h:117
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
char * msh_buffer
Definition: MarshaledObj.h:104
#define MSH_SET_TYPECHOICE(X)
Definition: MarshaledObj.h:21
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file MarshaledObj.h.

62  {
63  msh_isUnmarshalDone = false;
64 
65  if(chIsUnmarshaling != 'u') {
66  printf("MarshaledObj(void*, char): wrong argument\n");
67  return;
68  }
69 
70  //msh_extent = ROUND_UP(*(int *)buf + sizeof(int));
72 
75 
76  msh_buffer = (char *)malloc(msh_extent);
78 
79  memcpy(msh_buffer, (char *)buf, msh_extent);
82 
83  //MSH_SET_TYPECHOICE(msh_typechoice);
84 
85  }
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
static int ROUND_UP(int x)
Definition: MarshaledObj.h:32
#define MSH_GET_TYPECHOICE(X, BUF)
Definition: MarshaledObj.h:23
size_t msh_extent
Definition: MarshaledObj.h:117
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_GET_TOTALSIZE(X, BUF)
Definition: MarshaledObj.h:24
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file MarshaledObj.h.

87  {
88  if ( ! isUnmarshaling() )
90  }
bool isUnmarshaling()
Definition: MarshaledObj.h:92
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

Member Function Documentation

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

Definition at line 122 of file MarshaledObj.h.

122  {
123  msh_size += size;
124  if(msh_size > msh_extent){
126  }
127  }
size_t msh_extent
Definition: MarshaledObj.h:117
void resizeBuffer(size_t new_size)
Definition: MarshaledObj.h:129
size_t msh_size
Definition: MarshaledObj.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

Definition at line 122 of file MarshaledObj.h.

122  {
123  msh_size += size;
124  if(msh_size > msh_extent){
126  }
127  }
size_t msh_extent
Definition: MarshaledObj.h:117
void resizeBuffer(size_t new_size)
Definition: MarshaledObj.h:129
size_t msh_size
Definition: MarshaledObj.h:110

Here is the call graph for this function:

char* MarshaledObj::getBuffer ( )
inline

Definition at line 149 of file MarshaledObj.h.

149  {
150  return msh_buffer;
151  }
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the caller graph for this function:

char* MarshaledObj::getBuffer ( )
inline

Definition at line 149 of file MarshaledObj.h.

149  {
150  return msh_buffer;
151  }
char * msh_buffer
Definition: MarshaledObj.h:104
int MarshaledObj::getBufferSize ( )
inline

Definition at line 145 of file MarshaledObj.h.

145  {
146  return msh_size;
147  }
size_t msh_size
Definition: MarshaledObj.h:110

Here is the caller graph for this function:

int MarshaledObj::getBufferSize ( )
inline

Definition at line 145 of file MarshaledObj.h.

145  {
146  return msh_size;
147  }
size_t msh_size
Definition: MarshaledObj.h:110
bool MarshaledObj::isUnmarshaling ( )
inline

Definition at line 92 of file MarshaledObj.h.

92  {
93  return (msh_extent <= 0);
94  }
size_t msh_extent
Definition: MarshaledObj.h:117
bool MarshaledObj::isUnmarshaling ( )
inline

Definition at line 92 of file MarshaledObj.h.

92  {
93  return (msh_extent <= 0);
94  }
size_t msh_extent
Definition: MarshaledObj.h:117

Here is the caller graph for this function:

void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

Definition at line 154 of file MarshaledObj.h.

154  {
155  int msh_currentSize;
156  if (isUnmarshaling())
157  throw "Tried to marshal in object marked isUnmarshaling = true";
158  msh_currentSize = size;
159  EXTEND_BUFFER(msh_currentSize + sizeof(int));
160 
161  // *(int *)msh_cursor = msh_currentSize;
162  memcpy(msh_cursor, &msh_currentSize, sizeof(int));
163  msh_cursor += sizeof(int);
164  memcpy(msh_cursor, p, size);
165  msh_cursor += msh_currentSize;
167 
169  }
const char * p
Definition: xmltok.h:285
bool isUnmarshaling()
Definition: MarshaledObj.h:92
size_t msh_size
Definition: MarshaledObj.h:110
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void EXTEND_BUFFER(int size)
Definition: MarshaledObj.h:122
char * msh_cursor
Definition: MarshaledObj.h:113
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

Definition at line 154 of file MarshaledObj.h.

154  {
155  int msh_currentSize;
156  if (isUnmarshaling())
157  throw "Tried to marshal in object marked isUnmarshaling = true";
158  msh_currentSize = size;
159  EXTEND_BUFFER(msh_currentSize + sizeof(int));
160 
161  // *(int *)msh_cursor = msh_currentSize;
162  memcpy(msh_cursor, &msh_currentSize, sizeof(int));
163  msh_cursor += sizeof(int);
164  memcpy(msh_cursor, p, size);
165  msh_cursor += msh_currentSize;
167 
169  }
const char * p
Definition: xmltok.h:285
bool isUnmarshaling()
Definition: MarshaledObj.h:92
size_t msh_size
Definition: MarshaledObj.h:110
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void EXTEND_BUFFER(int size)
Definition: MarshaledObj.h:122
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_cursor
Definition: MarshaledObj.h:113
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the call graph for this function:

void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file MarshaledObj.h.

129  {
130  int msh_displacement = msh_cursor - msh_buffer;
131  int field_displacement = msh_field_begin - msh_buffer;
132 
133  while(new_size > msh_extent)
134  msh_extent *= 2;
135 
136  msh_buffer = (char *)realloc( msh_buffer, msh_extent);
137  MSH_ASSERT(msh_buffer);
138 
139  msh_cursor = msh_buffer + msh_displacement;
140  msh_field_begin = msh_buffer + field_displacement;
141  }
size_t msh_extent
Definition: MarshaledObj.h:117
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
char * msh_buffer
Definition: MarshaledObj.h:104

Here is the caller graph for this function:

void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file MarshaledObj.h.

129  {
130  int msh_displacement = msh_cursor - msh_buffer;
131  int field_displacement = msh_field_begin - msh_buffer;
132 
133  while(new_size > msh_extent)
134  msh_extent *= 2;
135 
136  msh_buffer = (char *)realloc( msh_buffer, msh_extent);
137  MSH_ASSERT(msh_buffer);
138 
139  msh_cursor = msh_buffer + msh_displacement;
140  msh_field_begin = msh_buffer + field_displacement;
141  }
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_cursor
Definition: MarshaledObj.h:113
char * msh_buffer
Definition: MarshaledObj.h:104
static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file MarshaledObj.h.

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
tuple x
Definition: test.py:50
static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file MarshaledObj.h.

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
tuple x
Definition: test.py:50

Here is the caller graph for this function:

void MarshaledObj::unmarshalPrimitive ( void p,
int  size 
)
inline

Definition at line 171 of file MarshaledObj.h.

171  {
172  int msh_currentSize;
173  //memcpy(&msh_currentSize, msh_cursor, sizeof(int));
174  /* in case *msh_cursor is invalid, use "size" not to crash the memory */
175  msh_currentSize = size;
176  msh_cursor += sizeof(int);
177  memcpy(p, msh_cursor, msh_currentSize);
178  msh_cursor += msh_currentSize;
179  //msh_size = msh_cursor - msh_buffer;
180  }
const char * p
Definition: xmltok.h:285
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
char * msh_cursor
Definition: MarshaledObj.h:113

Here is the call graph for this function:

void MarshaledObj::unmarshalPrimitive ( void p,
int  size 
)
inline

Definition at line 171 of file MarshaledObj.h.

171  {
172  int msh_currentSize;
173  //memcpy(&msh_currentSize, msh_cursor, sizeof(int));
174  /* in case *msh_cursor is invalid, use "size" not to crash the memory */
175  msh_currentSize = size;
176  msh_cursor += sizeof(int);
177  memcpy(p, msh_cursor, msh_currentSize);
178  msh_cursor += msh_currentSize;
179  //msh_size = msh_cursor - msh_buffer;
180  }
const char * p
Definition: xmltok.h:285
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
char * msh_cursor
Definition: MarshaledObj.h:113

Here is the call graph for this function:

Member Data Documentation

char * MarshaledObj::msh_buffer
protected

Definition at line 104 of file MarshaledObj.h.

char * MarshaledObj::msh_cursor
protected

Definition at line 113 of file MarshaledObj.h.

size_t MarshaledObj::msh_extent
protected

Definition at line 117 of file MarshaledObj.h.

char * MarshaledObj::msh_field_begin
protected

Definition at line 107 of file MarshaledObj.h.

bool MarshaledObj::msh_isUnmarshalDone
protected

Definition at line 119 of file MarshaledObj.h.

size_t MarshaledObj::msh_size
protected

Definition at line 110 of file MarshaledObj.h.

int MarshaledObj::msh_typechoice
protected

Definition at line 101 of file MarshaledObj.h.


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