Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes
MarshaledObj Class Reference

#include <MarshaledObj.h>

Inheritance diagram for MarshaledObj:
MarshaledExN02TrackerHit MarshaledExN04CalorimeterHit MarshaledExN04MuonHit MarshaledExN04TrackerHit MarshaledG4HCofThisEvent MarshaledG4HCofThisEvent MarshaledG4HCofThisEvent MarshaledG4HCofThisEvent MarshaledG4HitsCollection MarshaledG4HitsCollection MarshaledG4HitsCollection MarshaledG4HitsCollection MarshaledG4String MarshaledG4String MarshaledG4String MarshaledG4String MarshaledG4THitsCollection< T > MarshaledG4THitsCollection< T > MarshaledG4THitsCollection< T > MarshaledG4THitsCollection< T > MarshaledG4VHitsCollection MarshaledG4VHitsCollection MarshaledG4VHitsCollection MarshaledG4VHitsCollection

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 ParN02/include/MarshaledObj.h.

Constructor & Destructor Documentation

MarshaledObj::MarshaledObj ( )
inline

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

References malloc(), MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, MSH_HEADER_SIZE, msh_isUnmarshalDone, MSH_SET_TOTALSIZE, MSH_SET_TYPECHOICE, msh_size, and msh_typechoice.

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)
void * malloc(size_t __size)
Definition: hjmalloc.cc:30
#define MSH_HEADER_SIZE
#define MSH_SET_TOTALSIZE(X)
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

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

References malloc(), MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, MSH_GET_TOTALSIZE, MSH_GET_TYPECHOICE, MSH_HEADER_SIZE, msh_isUnmarshalDone, msh_size, msh_typechoice, and ROUND_UP().

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)
#define MSH_ASSERT(X)
#define MSH_GET_TYPECHOICE(X, BUF)
void * malloc(size_t __size)
Definition: hjmalloc.cc:30
#define MSH_HEADER_SIZE
MarshaledObj::~MarshaledObj ( )
inline

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

References free(), isUnmarshaling(), and msh_buffer.

87  {
88  if ( ! isUnmarshaling() )
90  }
void free(void *__ptr)
Definition: hjmalloc.cc:140
MarshaledObj::MarshaledObj ( )
inline

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

References malloc(), MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, MSH_HEADER_SIZE, msh_isUnmarshalDone, MSH_SET_TOTALSIZE, MSH_SET_TYPECHOICE, msh_size, and msh_typechoice.

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)
void * malloc(size_t __size)
Definition: hjmalloc.cc:30
#define MSH_SET_TYPECHOICE(X)
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

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

References malloc(), MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, MSH_GET_TOTALSIZE, MSH_GET_TYPECHOICE, MSH_HEADER_SIZE, msh_isUnmarshalDone, msh_size, msh_typechoice, and ROUND_UP().

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)
#define MSH_GET_TYPECHOICE(X, BUF)
#define MSH_GET_TOTALSIZE(X, BUF)
void * malloc(size_t __size)
Definition: hjmalloc.cc:30
MarshaledObj::~MarshaledObj ( )
inline

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

References free(), isUnmarshaling(), and msh_buffer.

87  {
88  if ( ! isUnmarshaling() )
90  }
void free(void *__ptr)
Definition: hjmalloc.cc:140

Member Function Documentation

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline
void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

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

References msh_extent, msh_size, and resizeBuffer().

122  {
123  msh_size += size;
124  if(msh_size > msh_extent){
126  }
127  }
void resizeBuffer(size_t new_size)
char* MarshaledObj::getBuffer ( )
inline
char* MarshaledObj::getBuffer ( )
inline

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

References msh_buffer.

149  {
150  return msh_buffer;
151  }
int MarshaledObj::getBufferSize ( )
inline
int MarshaledObj::getBufferSize ( )
inline

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

References msh_size.

145  {
146  return msh_size;
147  }
bool MarshaledObj::isUnmarshaling ( )
inline

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

References msh_extent.

92  {
93  return (msh_extent <= 0);
94  }
bool MarshaledObj::isUnmarshaling ( )
inline
void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

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

References EXTEND_BUFFER(), int(), isUnmarshaling(), msh_buffer, msh_cursor, MSH_SET_TOTALSIZE, and msh_size.

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  }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const char * p
Definition: xmltok.h:285
void EXTEND_BUFFER(int size)
#define MSH_SET_TOTALSIZE(X)
void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

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

References EXTEND_BUFFER(), int(), isUnmarshaling(), msh_buffer, msh_cursor, MSH_SET_TOTALSIZE, and msh_size.

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  }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const char * p
Definition: xmltok.h:285
void EXTEND_BUFFER(int size)
#define MSH_SET_TOTALSIZE(X)
void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

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

References MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, and realloc().

Referenced by EXTEND_BUFFER().

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)
void * realloc(void *__ptr, size_t __size)
Definition: hjmalloc.cc:103
void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

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

References MSH_ASSERT, msh_buffer, msh_cursor, msh_extent, msh_field_begin, and realloc().

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)
void * realloc(void *__ptr, size_t __size)
Definition: hjmalloc.cc:103
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 int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

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

Referenced by MarshaledObj().

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
void MarshaledObj::unmarshalPrimitive ( void p,
int  size 
)
inline

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

References int(), and msh_cursor.

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  }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const char * p
Definition: xmltok.h:285
void MarshaledObj::unmarshalPrimitive ( void p,
int  size 
)
inline

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

References int(), and msh_cursor.

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  }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const char * p
Definition: xmltok.h:285

Field Documentation

char * MarshaledObj::msh_buffer
protected
char * MarshaledObj::msh_cursor
protected

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

Referenced by MarshaledG4String::marshal1(), MarshaledExN04TrackerHit::marshal1(), MarshaledExN04MuonHit::marshal1(), MarshaledG4VHitsCollection::marshal1(), MarshaledG4HCofThisEvent::marshal1(), MarshaledG4HitsCollection::marshal1(), MarshaledExN04CalorimeterHit::marshal1(), MarshaledExN02TrackerHit::marshal1(), MarshaledG4THitsCollection< T >::marshal1(), MarshaledExN04MuonHit::marshal2(), MarshaledExN04TrackerHit::marshal2(), MarshaledG4VHitsCollection::marshal2(), MarshaledExN04CalorimeterHit::marshal2(), MarshaledExN02TrackerHit::marshal2(), MarshaledExN02TrackerHit::marshal3(), MarshaledG4VHitsCollection::marshal3(), MarshaledExN04CalorimeterHit::marshal3(), MarshaledExN02TrackerHit::marshal4(), MarshaledExN04CalorimeterHit::marshal4(), MarshaledObj(), marshalPrimitive(), resizeBuffer(), MarshaledG4String::unmarshal1(), MarshaledExN04MuonHit::unmarshal1(), MarshaledExN04TrackerHit::unmarshal1(), MarshaledG4VHitsCollection::unmarshal1(), MarshaledExN04CalorimeterHit::unmarshal1(), MarshaledExN02TrackerHit::unmarshal1(), MarshaledG4HitsCollection::unmarshal1(), MarshaledG4HCofThisEvent::unmarshal1(), MarshaledG4THitsCollection< T >::unmarshal1(), MarshaledExN04MuonHit::unmarshal2(), MarshaledExN04TrackerHit::unmarshal2(), MarshaledG4VHitsCollection::unmarshal2(), MarshaledExN02TrackerHit::unmarshal2(), MarshaledExN04CalorimeterHit::unmarshal2(), MarshaledExN04CalorimeterHit::unmarshal3(), MarshaledExN02TrackerHit::unmarshal3(), MarshaledG4VHitsCollection::unmarshal3(), MarshaledExN04CalorimeterHit::unmarshal4(), MarshaledExN02TrackerHit::unmarshal4(), and unmarshalPrimitive().

size_t MarshaledObj::msh_extent
protected
char * MarshaledObj::msh_field_begin
protected
bool MarshaledObj::msh_isUnmarshalDone
protected
size_t MarshaledObj::msh_size
protected

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

Referenced by EXTEND_BUFFER(), getBufferSize(), MarshaledG4String::marshal1(), MarshaledExN04TrackerHit::marshal1(), MarshaledExN04MuonHit::marshal1(), MarshaledG4VHitsCollection::marshal1(), MarshaledG4HCofThisEvent::marshal1(), MarshaledG4HitsCollection::marshal1(), MarshaledExN04CalorimeterHit::marshal1(), MarshaledExN02TrackerHit::marshal1(), MarshaledG4THitsCollection< T >::marshal1(), MarshaledExN04MuonHit::marshal2(), MarshaledExN04TrackerHit::marshal2(), MarshaledG4VHitsCollection::marshal2(), MarshaledExN02TrackerHit::marshal2(), MarshaledExN04CalorimeterHit::marshal2(), MarshaledExN02TrackerHit::marshal3(), MarshaledG4VHitsCollection::marshal3(), MarshaledExN04CalorimeterHit::marshal3(), MarshaledExN04CalorimeterHit::marshal4(), MarshaledExN02TrackerHit::marshal4(), MarshaledObj(), marshalPrimitive(), MarshaledExN04MuonHit::unmarshal(), MarshaledG4String::unmarshal(), MarshaledExN04TrackerHit::unmarshal(), MarshaledG4VHitsCollection::unmarshal(), MarshaledExN02TrackerHit::unmarshal(), MarshaledExN04CalorimeterHit::unmarshal(), MarshaledG4HCofThisEvent::unmarshal(), MarshaledG4HitsCollection::unmarshal(), MarshaledG4THitsCollection< T >::unmarshal(), MarshaledG4String::unmarshalTo(), MarshaledExN04MuonHit::unmarshalTo(), MarshaledExN04TrackerHit::unmarshalTo(), MarshaledG4VHitsCollection::unmarshalTo(), MarshaledExN04CalorimeterHit::unmarshalTo(), MarshaledExN02TrackerHit::unmarshalTo(), MarshaledG4HitsCollection::unmarshalTo(), MarshaledG4HCofThisEvent::unmarshalTo(), and MarshaledG4THitsCollection< T >::unmarshalTo().

int MarshaledObj::msh_typechoice
protected

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