Version: 8.3.0
YACS::ENGINE::SeqAlloc Class Reference

#include <Any.hxx>

Collaboration diagram for YACS::ENGINE::SeqAlloc:

Static Public Attributes

static const char DFT_CHAR_VAR =-17
 

Private Member Functions

 SeqAlloc (const SeqAlloc &other)
 
 SeqAlloc (unsigned int sizeOf1Elm)
 
 ~SeqAlloc ()
 
void clear ()
 
void initCoarseMemory (char *mem, unsigned int size, Deallocator dealloc)
 
void construct (char *pt, const Any *val)
 
void construct (char *pt, const char *val, const TypeCode *tc, bool deepCpy)
 
char * allocate (unsigned int nbOfByte)
 
void destroy (char *pt, const TypeCode *tc)
 
void deallocate (char *pt)
 
unsigned int size () const
 
std::vector< unsigned int > getSetItems () const
 

Private Attributes

char * _start
 
char * _finish
 
char * _endOfStorage
 
Deallocator _notStdDeAlloc
 
const unsigned int _sizeOf1Elm
 

Friends

class SequenceAny
 

Detailed Description

Definition at line 145 of file Any.hxx.

Constructor & Destructor Documentation

SeqAlloc::SeqAlloc ( const SeqAlloc other)
private

Definition at line 356 of file Any.cxx.

References _endOfStorage, _finish, _start, and allocate().

357  _start(0),_finish(0),_endOfStorage(0)
358 {
359  _start=allocate(other._finish-other._start);
360  _finish=_start+(other._finish-other._start);
362 }
SeqAlloc::SeqAlloc ( unsigned int  sizeOf1Elm)
private

Definition at line 364 of file Any.cxx.

364  :_sizeOf1Elm(sizeOf1Elm),_notStdDeAlloc(0),
365  _start(0),_finish(0),_endOfStorage(0)
366 {
367 }
SeqAlloc::~SeqAlloc ( )
private

Definition at line 369 of file Any.cxx.

References _start, and deallocate().

370 {
372 }

Member Function Documentation

char * SeqAlloc::allocate ( unsigned int  nbOfByte)
private

Definition at line 425 of file Any.cxx.

Referenced by initCoarseMemory(), YACS::ENGINE::SequenceAny::realloc(), and SeqAlloc().

426 {
427  if(nbOfByte>0)
428  return (char *)::operator new(nbOfByte);
429  else
430  return 0;
431 }
void SeqAlloc::clear ( )
private

Definition at line 374 of file Any.cxx.

References _endOfStorage, _finish, _start, and deallocate().

Referenced by YACS::ENGINE::SequenceAny::clear().

375 {
377  _start=0;
378  _finish=0;
379  _endOfStorage=0;
380 }
void SeqAlloc::construct ( char *  pt,
const Any val 
)
private
void SeqAlloc::construct ( char *  pt,
const char *  val,
const TypeCode tc,
bool  deepCpy 
)
private
Note
: This performs the placement new or zip info into pt.
Parameters
pt:
val: the source from which the construction will be performed.
tc:
deepCpy: If true in pt place a deep copy pointed by val will be put.

Definition at line 420 of file Any.cxx.

References YACS::ENGINE::TypeCode::putReprAtPlace().

421 {
422  tc->putReprAtPlace(pt,val,deepCpy);
423 }
void SeqAlloc::deallocate ( char *  pt)
private

Definition at line 434 of file Any.cxx.

References _notStdDeAlloc.

Referenced by clear(), YACS::ENGINE::SequenceAny::realloc(), and ~SeqAlloc().

435 {
436  if(pt)
437  {
438  if(!_notStdDeAlloc)
439  ::operator delete(pt);
440  else
441  {
442  _notStdDeAlloc(pt);
443  _notStdDeAlloc=0;
444  }
445  }
446 }
void SeqAlloc::destroy ( char *  pt,
const TypeCode tc 
)
private
std::vector< unsigned int > SeqAlloc::getSetItems ( ) const
private

Definition at line 458 of file Any.cxx.

References _sizeOf1Elm, _start, DFT_CHAR_VAR, CORBAEngineTest::i, PMMLBasicsTestLauncher::ret, and size().

459 {
460  std::vector<unsigned int> ret;
461  unsigned int sz(size());
462  for(unsigned int i=0;i<sz;i++)
463  {
464  const char *pt(_start+i*_sizeOf1Elm);
465  for(unsigned j=0;j<_sizeOf1Elm && *pt==DFT_CHAR_VAR;j++,pt++); //see initCoarseMemory
466  if(pt!=_start+(i+1)*_sizeOf1Elm)
467  ret.push_back(i);
468  }
469  return ret;
470 }
void SeqAlloc::initCoarseMemory ( char *  mem,
unsigned int  size,
Deallocator  dealloc 
)
private
Note
: This method is exclusively reserved for arrays of C++ built-in types because no constructor is applied atomically.

Definition at line 386 of file Any.cxx.

References _endOfStorage, _finish, _notStdDeAlloc, _sizeOf1Elm, _start, allocate(), DFT_CHAR_VAR, and CORBAEngineTest::i.

Referenced by YACS::ENGINE::SequenceAny::SequenceAny().

387 {
388  unsigned sizeInByte=size*_sizeOf1Elm;
389  if(dealloc)
390  {
391  _notStdDeAlloc=dealloc;
392  _start=mem;
393  }
394  else
395  {
396  _start=allocate(sizeInByte);
397  if(mem)
398  memcpy(_start,mem,sizeInByte);
399  else
400  {
401  for(unsigned int i=0;i<sizeInByte;i++) _start[i]=DFT_CHAR_VAR;// see getSetItems
402  }
403  }
404  _finish=_start+sizeInByte;
406 }
unsigned int SeqAlloc::size ( ) const
private

Definition at line 453 of file Any.cxx.

References _finish, _sizeOf1Elm, and _start.

Referenced by getSetItems().

454 {
455  return (_finish-_start)/_sizeOf1Elm;
456 }

Friends And Related Function Documentation

friend class SequenceAny
friend

Definition at line 147 of file Any.hxx.

Member Data Documentation

char* YACS::ENGINE::SeqAlloc::_endOfStorage
private
Deallocator YACS::ENGINE::SeqAlloc::_notStdDeAlloc
private

Definition at line 152 of file Any.hxx.

Referenced by deallocate(), and initCoarseMemory().

const char SeqAlloc::DFT_CHAR_VAR =-17
static

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