Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
MarshaledObj Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/geant4/v4_10_4_p02ba/source/geant4.10.04.p02/examples/extended/parallel/TopC/ParN02/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
 

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 MarshaledObj.h.

Constructor & Destructor Documentation

MarshaledObj::MarshaledObj ( )
inline

Definition at line 38 of file MarshaledObj.h.

References 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  }
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_SET_TYPECHOICE(X)
Definition: MarshaledObj.h:21
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_buffer
Definition: MarshaledObj.h:104
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file MarshaledObj.h.

References 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, printf(), 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  }
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
#define MSH_GET_TYPECHOICE(X, BUF)
Definition: MarshaledObj.h:23
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
printf("%d Experimental points found\n", nlines)
char * msh_field_begin
Definition: MarshaledObj.h:107
static int ROUND_UP(int x)
Definition: MarshaledObj.h:32
char * msh_buffer
Definition: MarshaledObj.h:104
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
#define MSH_GET_TOTALSIZE(X, BUF)
Definition: MarshaledObj.h:24
MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file MarshaledObj.h.

References isUnmarshaling(), and msh_buffer.

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

Definition at line 38 of file MarshaledObj.h.

References 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)
Definition: MarshaledObj.h:21
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
size_t msh_size
Definition: MarshaledObj.h:110
char * msh_field_begin
Definition: MarshaledObj.h:107
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_buffer
Definition: MarshaledObj.h:104
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
MarshaledObj::MarshaledObj ( void buf,
char  chIsUnmarshaling 
)
inline

Definition at line 62 of file MarshaledObj.h.

References 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, printf(), 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)
Definition: MarshaledObj.h:24
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
size_t msh_size
Definition: MarshaledObj.h:110
printf("%d Experimental points found\n", nlines)
char * msh_field_begin
Definition: MarshaledObj.h:107
static int ROUND_UP(int x)
Definition: MarshaledObj.h:32
#define MSH_GET_TYPECHOICE(X, BUF)
Definition: MarshaledObj.h:23
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_buffer
Definition: MarshaledObj.h:104
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
MarshaledObj::~MarshaledObj ( )
inline

Definition at line 87 of file MarshaledObj.h.

References isUnmarshaling(), and msh_buffer.

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

Member Function Documentation

void MarshaledObj::EXTEND_BUFFER ( int  size)
inline

Definition at line 122 of file MarshaledObj.h.

References resizeBuffer(), and gen_flatrecord::size.

Referenced by marshalPrimitive().

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

Definition at line 122 of file MarshaledObj.h.

References resizeBuffer(), and gen_flatrecord::size.

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

Definition at line 149 of file MarshaledObj.h.

References msh_buffer.

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

Definition at line 145 of file MarshaledObj.h.

References msh_size.

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.

References msh_extent, operator=(), and art::right().

Referenced by marshalPrimitive(), and ~MarshaledObj().

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.

References msh_buffer, msh_cursor, msh_extent, msh_field_begin, msh_isUnmarshalDone, msh_size, msh_typechoice, operator=(), and art::right().

92  {
93  return (msh_extent <= 0);
94  }
size_t msh_extent
Definition: MarshaledObj.h:117
void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

Definition at line 154 of file MarshaledObj.h.

References EXTEND_BUFFER(), makeTrainCVSamples::int, isUnmarshaling(), msh_buffer, MSH_SET_TOTALSIZE, and gen_flatrecord::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  }
bool isUnmarshaling()
Definition: MarshaledObj.h:92
const char * p
Definition: xmltok.h:285
size_t msh_size
Definition: MarshaledObj.h:110
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_buffer
Definition: MarshaledObj.h:104
void EXTEND_BUFFER(int size)
Definition: MarshaledObj.h:122
char * msh_cursor
Definition: MarshaledObj.h:113
void MarshaledObj::marshalPrimitive ( void p,
int  size 
)
inline

Definition at line 154 of file MarshaledObj.h.

References EXTEND_BUFFER(), makeTrainCVSamples::int, isUnmarshaling(), msh_buffer, MSH_SET_TOTALSIZE, and gen_flatrecord::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  }
bool isUnmarshaling()
Definition: MarshaledObj.h:92
const char * p
Definition: xmltok.h:285
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
size_t msh_size
Definition: MarshaledObj.h:110
char * msh_buffer
Definition: MarshaledObj.h:104
void EXTEND_BUFFER(int size)
Definition: MarshaledObj.h:122
char * msh_cursor
Definition: MarshaledObj.h:113
const MarshaledObj& MarshaledObj::operator= ( const MarshaledObj right)
private
const MarshaledObj& MarshaledObj::operator= ( const MarshaledObj right)
private

Referenced by isUnmarshaling().

void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file MarshaledObj.h.

References MSH_ASSERT, and msh_buffer.

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)
Definition: MarshaledObj.h:13
char * msh_field_begin
Definition: MarshaledObj.h:107
char * msh_buffer
Definition: MarshaledObj.h:104
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
void MarshaledObj::resizeBuffer ( size_t  new_size)
inline

Definition at line 129 of file MarshaledObj.h.

References MSH_ASSERT, and msh_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  }
char * msh_field_begin
Definition: MarshaledObj.h:107
#define MSH_ASSERT(X)
Definition: MarshaledObj.h:13
char * msh_buffer
Definition: MarshaledObj.h:104
size_t msh_extent
Definition: MarshaledObj.h:117
char * msh_cursor
Definition: MarshaledObj.h:113
static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file MarshaledObj.h.

References WORD_SIZE.

32  {
33  return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
34  }
static const int WORD_SIZE
Definition: MarshaledObj.h:30
static int MarshaledObj::ROUND_UP ( int  x)
inlinestatic

Definition at line 32 of file MarshaledObj.h.

References WORD_SIZE.

Referenced by MarshaledObj().

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

Definition at line 171 of file MarshaledObj.h.

References makeTrainCVSamples::int, and gen_flatrecord::size.

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
char * msh_cursor
Definition: MarshaledObj.h:113
void MarshaledObj::unmarshalPrimitive ( void p,
int  size 
)
inline

Definition at line 171 of file MarshaledObj.h.

References makeTrainCVSamples::int, and gen_flatrecord::size.

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
char * msh_cursor
Definition: MarshaledObj.h:113

Member Data Documentation

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

Definition at line 113 of file MarshaledObj.h.

Referenced by isUnmarshaling(), and MarshaledObj().

size_t MarshaledObj::msh_extent
protected

Definition at line 117 of file MarshaledObj.h.

Referenced by isUnmarshaling(), and MarshaledObj().

char * MarshaledObj::msh_field_begin
protected

Definition at line 107 of file MarshaledObj.h.

Referenced by isUnmarshaling(), and MarshaledObj().

bool MarshaledObj::msh_isUnmarshalDone
protected

Definition at line 119 of file MarshaledObj.h.

Referenced by isUnmarshaling(), and MarshaledObj().

size_t MarshaledObj::msh_size
protected

Definition at line 110 of file MarshaledObj.h.

Referenced by getBufferSize(), isUnmarshaling(), and MarshaledObj().

int MarshaledObj::msh_typechoice
protected

Definition at line 101 of file MarshaledObj.h.

Referenced by isUnmarshaling(), and MarshaledObj().

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

Definition at line 30 of file MarshaledObj.h.

Referenced by ROUND_UP().


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