Geant4  10.02.p03
MarshaledObj Class Reference

#include <MarshaledObj.h>

Inheritance diagram for MarshaledObj:
Collaboration 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
 

Private Member Functions

const MarshaledObjoperator= (const MarshaledObj &right)
 
const MarshaledObjoperator= (const MarshaledObj &right)
 

Static Private Attributes

static const int WORD_SIZE = sizeof(long)
 

Detailed Description

Definition at line 27 of file ParN02/include/MarshaledObj.h.

Constructor & Destructor Documentation

◆ MarshaledObj() [1/4]

MarshaledObj::MarshaledObj ( )
inline

Definition at line 38 of file ParN02/include/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_SET_TYPECHOICE(X)
#define MSH_ASSERT(X)
#define MSH_HEADER_SIZE
#define MSH_SET_TOTALSIZE(X)

◆ MarshaledObj() [2/4]

MarshaledObj::MarshaledObj ( void *  buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file ParN02/include/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)
static int ROUND_UP(int x)
printf("%d Experimental points found\, nlines)
#define MSH_ASSERT(X)
#define MSH_GET_TYPECHOICE(X, BUF)
#define MSH_HEADER_SIZE
Here is the call graph for this function:

◆ ~MarshaledObj() [1/2]

MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file ParN02/include/MarshaledObj.h.

Here is the call graph for this function:

◆ MarshaledObj() [3/4]

MarshaledObj::MarshaledObj ( )
inline

Definition at line 38 of file ParN04/include/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
#define MSH_ASSERT(X)
#define MSH_SET_TOTALSIZE(X)
#define MSH_SET_TYPECHOICE(X)

◆ MarshaledObj() [4/4]

MarshaledObj::MarshaledObj ( void *  buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file ParN04/include/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
#define MSH_ASSERT(X)
static int ROUND_UP(int x)
printf("%d Experimental points found\, nlines)
#define MSH_GET_TYPECHOICE(X, BUF)
#define MSH_GET_TOTALSIZE(X, BUF)
Here is the call graph for this function:

◆ ~MarshaledObj() [2/2]

MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file ParN04/include/MarshaledObj.h.

Here is the call graph for this function:

Member Function Documentation

◆ EXTEND_BUFFER() [1/2]

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

Definition at line 122 of file ParN02/include/MarshaledObj.h.

122  {
123  msh_size += size;
124  if(msh_size > msh_extent){
126  }
127  }
void resizeBuffer(size_t new_size)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXTEND_BUFFER() [2/2]

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

Definition at line 122 of file ParN04/include/MarshaledObj.h.

122  {
123  msh_size += size;
124  if(msh_size > msh_extent){
126  }
127  }
void resizeBuffer(size_t new_size)
Here is the call graph for this function:

◆ getBuffer() [1/2]

char* MarshaledObj::getBuffer ( )
inline

Definition at line 149 of file ParN04/include/MarshaledObj.h.

149  {
150  return msh_buffer;
151  }

◆ getBuffer() [2/2]

char* MarshaledObj::getBuffer ( )
inline

Definition at line 149 of file ParN02/include/MarshaledObj.h.

149  {
150  return msh_buffer;
151  }
Here is the caller graph for this function:

◆ getBufferSize() [1/2]

int MarshaledObj::getBufferSize ( )
inline

Definition at line 145 of file ParN02/include/MarshaledObj.h.

145  {
146  return msh_size;
147  }
Here is the caller graph for this function:

◆ getBufferSize() [2/2]

int MarshaledObj::getBufferSize ( )
inline

Definition at line 145 of file ParN04/include/MarshaledObj.h.

145  {
146  return msh_size;
147  }

◆ isUnmarshaling() [1/2]

bool MarshaledObj::isUnmarshaling ( )
inline

Definition at line 92 of file ParN02/include/MarshaledObj.h.

92  {
93  return (msh_extent <= 0);
94  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUnmarshaling() [2/2]

bool MarshaledObj::isUnmarshaling ( )
inline

Definition at line 92 of file ParN04/include/MarshaledObj.h.

92  {
93  return (msh_extent <= 0);
94  }
Here is the call graph for this function:

◆ marshalPrimitive() [1/2]

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

Definition at line 154 of file ParN04/include/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  }
void EXTEND_BUFFER(int size)
#define MSH_SET_TOTALSIZE(X)
Here is the call graph for this function:

◆ marshalPrimitive() [2/2]

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

Definition at line 154 of file ParN02/include/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  }
void EXTEND_BUFFER(int size)
#define MSH_SET_TOTALSIZE(X)
Here is the call graph for this function:

◆ operator=() [1/2]

const MarshaledObj& MarshaledObj::operator= ( const MarshaledObj right)
private

◆ operator=() [2/2]

const MarshaledObj& MarshaledObj::operator= ( const MarshaledObj right)
private
Here is the caller graph for this function:

◆ resizeBuffer() [1/2]

void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file ParN02/include/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)
Here is the caller graph for this function:

◆ resizeBuffer() [2/2]

void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file ParN04/include/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)

◆ ROUND_UP() [1/2]

static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file ParN04/include/MarshaledObj.h.

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
static const int WORD_SIZE

◆ ROUND_UP() [2/2]

static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file ParN02/include/MarshaledObj.h.

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
static const int WORD_SIZE
Here is the caller graph for this function:

◆ unmarshalPrimitive() [1/2]

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

Definition at line 171 of file ParN02/include/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  }

◆ unmarshalPrimitive() [2/2]

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

Definition at line 171 of file ParN04/include/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  }

Member Data Documentation

◆ msh_buffer

char * MarshaledObj::msh_buffer
protected

Definition at line 104 of file ParN02/include/MarshaledObj.h.

◆ msh_cursor

char * MarshaledObj::msh_cursor
protected

Definition at line 113 of file ParN02/include/MarshaledObj.h.

◆ msh_extent

size_t MarshaledObj::msh_extent
protected

Definition at line 117 of file ParN02/include/MarshaledObj.h.

◆ msh_field_begin

char * MarshaledObj::msh_field_begin
protected

Definition at line 107 of file ParN02/include/MarshaledObj.h.

◆ msh_isUnmarshalDone

bool MarshaledObj::msh_isUnmarshalDone
protected

Definition at line 119 of file ParN02/include/MarshaledObj.h.

◆ msh_size

size_t MarshaledObj::msh_size
protected

Definition at line 110 of file ParN02/include/MarshaledObj.h.

◆ msh_typechoice

int MarshaledObj::msh_typechoice
protected

Definition at line 101 of file ParN02/include/MarshaledObj.h.

◆ WORD_SIZE

static const int MarshaledObj::WORD_SIZE = sizeof(long)
staticprivate

Definition at line 30 of file ParN02/include/MarshaledObj.h.


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