Version: 9.16.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 158 of file Any.hxx.

Constructor & Destructor Documentation

◆ SeqAlloc() [1/2]

SeqAlloc::SeqAlloc ( const SeqAlloc other)
private

Definition at line 541 of file Any.cxx.

543{
544 _start=allocate(other._finish-other._start);
545 _finish=_start+(other._finish-other._start);
547}
char * _endOfStorage
Definition: Any.hxx:164
const unsigned int _sizeOf1Elm
Definition: Any.hxx:166
char * allocate(unsigned int nbOfByte)
Definition: Any.cxx:610
Deallocator _notStdDeAlloc
Definition: Any.hxx:165

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

◆ SeqAlloc() [2/2]

SeqAlloc::SeqAlloc ( unsigned int  sizeOf1Elm)
private

Definition at line 549 of file Any.cxx.

549 :_sizeOf1Elm(sizeOf1Elm),_notStdDeAlloc(0),
551{
552}

◆ ~SeqAlloc()

SeqAlloc::~SeqAlloc ( )
private

Definition at line 554 of file Any.cxx.

555{
557}
void deallocate(char *pt)
Definition: Any.cxx:619

References _start, and deallocate().

Member Function Documentation

◆ allocate()

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

Definition at line 610 of file Any.cxx.

611{
612 if(nbOfByte>0)
613 return (char *)::operator new(nbOfByte);
614 else
615 return 0;
616}

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

◆ clear()

void SeqAlloc::clear ( )
private

Definition at line 559 of file Any.cxx.

560{
562 _start=0;
563 _finish=0;
565}

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

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

◆ construct() [1/2]

void SeqAlloc::construct ( char *  pt,
const Any val 
)
private

◆ construct() [2/2]

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 605 of file Any.cxx.

606{
607 tc->putReprAtPlace(pt,val,deepCpy);
608}
virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const
Definition: TypeCode.cxx:57

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

◆ deallocate()

void SeqAlloc::deallocate ( char *  pt)
private

Definition at line 619 of file Any.cxx.

620{
621 if(pt)
622 {
623 if(!_notStdDeAlloc)
624 ::operator delete(pt);
625 else
626 {
627 _notStdDeAlloc(pt);
629 }
630 }
631}

References _notStdDeAlloc.

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

◆ destroy()

void SeqAlloc::destroy ( char *  pt,
const TypeCode tc 
)
private

◆ getSetItems()

std::vector< unsigned int > SeqAlloc::getSetItems ( ) const
private

Definition at line 643 of file Any.cxx.

644{
645 std::vector<unsigned int> ret;
646 unsigned int sz(size());
647 for(unsigned int i=0;i<sz;i++)
648 {
649 const char *pt(_start+i*_sizeOf1Elm);
650 for(unsigned j=0;j<_sizeOf1Elm && *pt==DFT_CHAR_VAR;j++,pt++); //see initCoarseMemory
651 if(pt!=_start+(i+1)*_sizeOf1Elm)
652 ret.push_back(i);
653 }
654 return ret;
655}
static const char DFT_CHAR_VAR
Definition: Any.hxx:181
unsigned int size() const
Definition: Any.cxx:638

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

◆ initCoarseMemory()

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 571 of file Any.cxx.

572{
573 unsigned sizeInByte=size*_sizeOf1Elm;
574 if(dealloc)
575 {
576 _notStdDeAlloc=dealloc;
577 _start=mem;
578 }
579 else
580 {
581 _start=allocate(sizeInByte);
582 if(mem)
583 memcpy(_start,mem,sizeInByte);
584 else
585 {
586 for(unsigned int i=0;i<sizeInByte;i++) _start[i]=DFT_CHAR_VAR;// see getSetItems
587 }
588 }
589 _finish=_start+sizeInByte;
591}

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

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

◆ size()

unsigned int SeqAlloc::size ( ) const
private

Definition at line 638 of file Any.cxx.

639{
640 return (_finish-_start)/_sizeOf1Elm;
641}

References _finish, _sizeOf1Elm, and _start.

Referenced by getSetItems(), and initCoarseMemory().

Friends And Related Function Documentation

◆ SequenceAny

friend class SequenceAny
friend

Definition at line 160 of file Any.hxx.

Member Data Documentation

◆ _endOfStorage

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

◆ _finish

◆ _notStdDeAlloc

Deallocator YACS::ENGINE::SeqAlloc::_notStdDeAlloc
private

Definition at line 165 of file Any.hxx.

Referenced by deallocate(), and initCoarseMemory().

◆ _sizeOf1Elm

◆ _start

◆ DFT_CHAR_VAR

const char SeqAlloc::DFT_CHAR_VAR =-17
static

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