Version: 8.3.0
YACS::ENGINE::SequenceAny Class Reference

#include <Any.hxx>

Inheritance diagram for YACS::ENGINE::SequenceAny:
Collaboration diagram for YACS::ENGINE::SequenceAny:

Public Member Functions

void clear ()
 
void popBack ()
 
unsigned int size () const
 
void pushBack (const Any *elem)
 
bool operator== (const Any &other) const
 
void setEltAtRank (int i, const Any *elem) throw (Exception)
 
AnyPtr operator[] (int i) const throw (Exception)
 
Anyclone () const
 
std::vector< unsigned int > getSetItems () const
 
SequenceAnyremoveUnsetItemsFromThis () const
 
template<class T >
SequenceAnyNew (T *val, unsigned int lgth, Deallocator deAlloc)
 
template<class T >
SequenceAnyNew (const std::vector< T > &vec)
 
- Public Member Functions inherited from YACS::ENGINE::ComposedAny
AnyPtr operator[] (const char *key) const throw (Exception)
 
- Public Member Functions inherited from YACS::ENGINE::Any
const TypeCodegetType () const
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef ()
 

Static Public Member Functions

template<class T >
static SequenceAnyNew (const std::vector< T > &vec)
 
static SequenceAnyNew (const TypeCode *typeOfContent)
 
static SequenceAnyNew (const TypeCode *typeOfContent, unsigned lgth)
 
template<class T >
static SequenceAnyNew (T *val, unsigned int lgth, Deallocator deAlloc)
 

Protected Member Functions

void putMyReprAtPlace (char *data) const
 
- Protected Member Functions inherited from YACS::ENGINE::ComposedAny
 ComposedAny (const ComposedAny &other)
 
 ComposedAny (TypeCode *type, bool isNew=true)
 
void checkTypeOf (const Any *elem) const throw (Exception)
 
- Protected Member Functions inherited from YACS::ENGINE::Any
virtual ~Any ()
 
 Any (TypeCode *type)
 
 Any (const Any &other)
 
- Protected Member Functions inherited from YACS::ENGINE::RefCounter
 RefCounter ()
 
 RefCounter (const RefCounter &other)
 
virtual ~RefCounter ()
 

Static Protected Member Functions

static void putReprAtPlace (char *data, const char *src, const TypeCode *type, bool deepCpy)
 
static void destroyReprAtPlace (char *data, const TypeCode *type)
 
static AnyPtr getOrBuildFromData (char *data, const TypeCode *type)
 
static bool takeInChargeStorageOf (TypeCode *type)
 

Protected Attributes

SeqAlloc _alloc
 

Private Member Functions

 ~SequenceAny ()
 
 SequenceAny (const SequenceAny &other)
 
 SequenceAny (const TypeCode *typeOfContent)
 
 SequenceAny (const TypeCode *typeOfContent, unsigned lgth)
 
 SequenceAny (int *val, unsigned int lgth, Deallocator deAlloc)
 
 SequenceAny (bool *val, unsigned int lgth, Deallocator deAlloc)
 
 SequenceAny (double *val, unsigned int lgth, Deallocator deAlloc)
 
 SequenceAny (const std::vector< int > &val)
 
 SequenceAny (const std::vector< bool > &val)
 
 SequenceAny (const std::vector< double > &val)
 
 SequenceAny (const std::vector< std::string > &val)
 
void realloc (char *endOfCurrentAllocated, const Any *elem)
 
char * performCpy (char *srcStart, char *srcFinish, char *destStart)
 

Friends

class TypeCodeSeq
 

Additional Inherited Members

- Static Public Attributes inherited from YACS::ENGINE::RefCounter
static unsigned int _totalCnt =0
 

Detailed Description

Definition at line 190 of file Any.hxx.

Constructor & Destructor Documentation

SequenceAny::SequenceAny ( const SequenceAny other)
private

Definition at line 613 of file Any.cxx.

References _alloc, YACS::ENGINE::SeqAlloc::_finish, YACS::ENGINE::SeqAlloc::_sizeOf1Elm, YACS::ENGINE::SeqAlloc::_start, YACS::ENGINE::Any::_type, YACS::ENGINE::SeqAlloc::construct(), and YACS::ENGINE::TypeCode::contentType().

Referenced by clone(), New(), and putReprAtPlace().

613  :ComposedAny(other),_alloc(other._alloc)
614 {
615  const char *srcCur=other._alloc._start;
616  for(char *cur=_alloc._start;srcCur != other._alloc._finish; srcCur+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
617  _alloc.construct(cur, srcCur, _type->contentType(),true);
618 }
SequenceAny::SequenceAny ( const TypeCode typeOfContent)
private
Parameters
typeOfContent: typeCode of the type of elements stored in sequence.

Definition at line 629 of file Any.cxx.

629  :ComposedAny(new TypeCodeSeq("","",typeOfContent)),
630  _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
631 {
632 }
SequenceAny::SequenceAny ( const TypeCode typeOfContent,
unsigned  lgth 
)
private

Definition at line 634 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

634  :ComposedAny(new TypeCodeSeq("","",typeOfContent)),
635  _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
636 {
637  _alloc.initCoarseMemory(0,lgth,0);
638 }
SequenceAny::SequenceAny ( int *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 640 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

641  _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
642 {
643  _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
644 }
SequenceAny::SequenceAny ( bool *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 646 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

647  _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
648 {
649  _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
650 }
SequenceAny::SequenceAny ( double *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 652 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

653  _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
654 {
655  _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
656 }
SequenceAny::SequenceAny ( const std::vector< int > &  val)
private

Definition at line 658 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

659  _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
660 {
661  _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
662 }
SequenceAny::SequenceAny ( const std::vector< bool > &  val)
private

Definition at line 664 of file Any.cxx.

References YACS::ENGINE::AtomAny::New(), and pushBack().

665  _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
666 {
667  for(vector<bool>::const_iterator iter=val.begin();iter!=val.end();iter++)
668  {
669  AtomAnyPtr tmp=AtomAny::New(*iter);
670  pushBack(tmp);
671  }
672 }
SequenceAny::SequenceAny ( const std::vector< double > &  val)
private

Definition at line 674 of file Any.cxx.

References _alloc, and YACS::ENGINE::SeqAlloc::initCoarseMemory().

675  _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
676 {
677  _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
678 }
SequenceAny::SequenceAny ( const std::vector< std::string > &  val)
private

Definition at line 680 of file Any.cxx.

References YACS::ENGINE::AtomAny::New(), and pushBack().

681  _alloc(Runtime::_tc_string->getSizeInByteOfAnyReprInSeq())
682 {
683  for(vector<string>::const_iterator iter=val.begin();iter!=val.end();iter++)
684  {
685  AtomAnyPtr tmp=AtomAny::New(*iter);
686  pushBack(tmp);
687  }
688 }

Member Function Documentation

Any * SequenceAny::clone ( ) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 567 of file Any.cxx.

References SequenceAny().

568 {
569  return new SequenceAny(*this);
570 }
void SequenceAny::destroyReprAtPlace ( char *  data,
const TypeCode type 
)
staticprotected

Definition at line 552 of file Any.cxx.

References YACS::ENGINE::RefCounter::decrRef(), and YACS::ENGINE::Any::IsNull().

Referenced by YACS::ENGINE::TypeCodeSeq::destroyZippedAny().

553 {
554  void **tmp=(void **) data;
555  if(!Any::IsNull(data))
556  ((SequenceAny *)(*tmp))->decrRef();
557  //((SequenceAny *)data)->~SequenceAny();
558 }
AnyPtr SequenceAny::getOrBuildFromData ( char *  data,
const TypeCode type 
)
staticprotected

Definition at line 560 of file Any.cxx.

References YACS::ENGINE::RefCounter::incrRef().

Referenced by YACS::ENGINE::TypeCodeSeq::getOrBuildAnyFromZippedData().

561 {
562  void **tmp=(void **) data;
563  ((SequenceAny *) (*tmp))->incrRef();
564  return AnyPtr((SequenceAny *)(*tmp));
565 }
std::vector<unsigned int> YACS::ENGINE::SequenceAny::getSetItems ( ) const
inline

Definition at line 208 of file Any.hxx.

Referenced by removeUnsetItemsFromThis().

208 { return _alloc.getSetItems(); }
template<class T >
static SequenceAny* YACS::ENGINE::SequenceAny::New ( const std::vector< T > &  vec)
static
SequenceAny * SequenceAny::New ( const TypeCode typeOfContent)
static

Definition at line 585 of file Any.cxx.

References YACS::ENGINE::Runtime::_tc_string, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, and SequenceAny().

586 {
587  if(typeOfContent->kind() == Objref)
588  {
589  //In case of Objref, use a sequence of string
590  return new SequenceAny(Runtime::_tc_string);
591  }
592  else
593  return new SequenceAny(typeOfContent);
594 }
SequenceAny * SequenceAny::New ( const TypeCode typeOfContent,
unsigned  lgth 
)
static

Definition at line 596 of file Any.cxx.

References YACS::ENGINE::Runtime::_tc_string, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, and SequenceAny().

597 {
598  if(typeOfContent->kind() == Objref)
599  {
600  //In case of Objref, use a sequence of string
601  return new SequenceAny(Runtime::_tc_string,lgth);
602  }
603  else
604  return new SequenceAny(typeOfContent,lgth);
605 }
template<class T >
static SequenceAny* YACS::ENGINE::SequenceAny::New ( T *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
static
template<class T >
SequenceAny* YACS::ENGINE::SequenceAny::New ( T *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)

Definition at line 299 of file Any.hxx.

300  {
301  return new SequenceAny(val,lgth,deAlloc);
302  }
template<class T >
SequenceAny* YACS::ENGINE::SequenceAny::New ( const std::vector< T > &  vec)

Definition at line 305 of file Any.hxx.

306  {
307  return new SequenceAny(vec);
308  }
bool SequenceAny::operator== ( const Any other) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 498 of file Any.cxx.

References YACS::ENGINE::Any::_type, YACS::ENGINE::Any::getType(), CORBAEngineTest::i, YACS::ENGINE::TypeCode::isA(), and size().

499 {
500  if(!_type->isA(other.getType()))
501  return false;
502  const SequenceAny& otherC=(const SequenceAny&) other;//cast granted due to previous lines
503  if(size()!=otherC.size())
504  return false;
505  for(unsigned i=0;i<size();i++)
506  if(!((*(*this)[i])==(*otherC[i])))
507  return false;
508  return true;
509 }
AnyPtr SequenceAny::operator[] ( int  i) const throw (Exception)
virtual

Implements YACS::ENGINE::Any.

Definition at line 518 of file Any.cxx.

References CORBAEngineTest::i.

char * SequenceAny::performCpy ( char *  srcStart,
char *  srcFinish,
char *  destStart 
)
private

Definition at line 709 of file Any.cxx.

References _alloc, YACS::ENGINE::SeqAlloc::_sizeOf1Elm, YACS::ENGINE::Any::_type, YACS::ENGINE::SeqAlloc::construct(), and YACS::ENGINE::TypeCode::contentType().

Referenced by realloc().

710 {
711  char *cur=destStart;
712  for (;srcStart != srcFinish; srcStart+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
713  _alloc.construct(cur, srcStart, _type->contentType(),false);
714  return cur;
715 }
void SequenceAny::putMyReprAtPlace ( char *  data) const
protectedvirtual
Note
: Contrary to AtomAny 'this' (ref) is put in data NOT a deep copy.
Parameters
data: already allocated memory zone where to put address of 'this'

Implements YACS::ENGINE::Any.

Definition at line 527 of file Any.cxx.

References YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), and YACS::ENGINE::RefCounter::incrRef().

528 {
529  const void *tmp=(const void *)this;
530  memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
531  const void **tmp2=(const void **) data;
532  ((SequenceAny *)(*tmp2))->incrRef();
533  //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
534 }
void SequenceAny::putReprAtPlace ( char *  data,
const char *  src,
const TypeCode type,
bool  deepCpy 
)
staticprotected

Definition at line 536 of file Any.cxx.

References YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), YACS::ENGINE::RefCounter::incrRef(), and SequenceAny().

Referenced by YACS::ENGINE::TypeCodeSeq::putReprAtPlace().

537 {
538  void **tmp2=(void **) src;
539  if(!deepCpy)
540  {
541  ((SequenceAny *)(*tmp2))->incrRef();
542  memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
543  }
544  else
545  {
546  SequenceAny *cpy=new SequenceAny(*((SequenceAny *)(*tmp2)));
547  memcpy(data,&cpy,type->getSizeInByteOfAnyReprInSeq());
548  }
549  //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
550 }
void SequenceAny::realloc ( char *  endOfCurrentAllocated,
const Any elem 
)
private

Definition at line 690 of file Any.cxx.

References _alloc, YACS::ENGINE::SeqAlloc::_endOfStorage, YACS::ENGINE::SeqAlloc::_finish, YACS::ENGINE::SeqAlloc::_sizeOf1Elm, YACS::ENGINE::SeqAlloc::_start, YACS::ENGINE::Any::_type, YACS::ENGINE::SeqAlloc::allocate(), YACS::ENGINE::SeqAlloc::construct(), YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::SeqAlloc::deallocate(), YACS::ENGINE::SeqAlloc::destroy(), and performCpy().

Referenced by pushBack().

691 {
692  unsigned int oldSize=_alloc._finish-_alloc._start;
693  unsigned int newSize = oldSize != 0 ? 2 * oldSize : _alloc._sizeOf1Elm;
694  char *newStart=_alloc.allocate(newSize);
695  //
696  char *newFinish=performCpy(_alloc._start, endOfCurrentAllocated,newStart);
697  _alloc.construct(newFinish, elem);
698  newFinish+=_alloc._sizeOf1Elm;
699  newFinish=performCpy(endOfCurrentAllocated, _alloc._finish, newFinish);
700  //
701  for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
704  _alloc._start = newStart;
705  _alloc._finish = newFinish;
706  _alloc._endOfStorage=newStart+newSize;
707 }
SequenceAny * SequenceAny::removeUnsetItemsFromThis ( ) const

Definition at line 572 of file Any.cxx.

References getSetItems(), YACS::ENGINE::Any::getType(), CORBAEngineTest::i, New(), and PMMLBasicsTestLauncher::ret.

573 {
574  std::vector<unsigned int> its(getSetItems());
575  std::size_t sz(its.size());
576  SequenceAny *ret(SequenceAny::New(getType()->contentType(),sz));
577  for(std::size_t i=0;i<sz;i++)
578  {
579  AnyPtr obj((*this)[its[i]]);
580  ret->setEltAtRank(i,obj);
581  }
582  return ret;
583 }
void SequenceAny::setEltAtRank ( int  i,
const Any elem 
) throw (Exception)
virtual
bool SequenceAny::takeInChargeStorageOf ( TypeCode type)
staticprotected

Definition at line 607 of file Any.cxx.

References YACS::ENGINE::TypeCode::kind(), and YACS::ENGINE::Sequence.

608 {
609  DynType typ=type->kind();
610  return (typ==Sequence);
611 }

Friends And Related Function Documentation

friend class TypeCodeSeq
friend

Definition at line 192 of file Any.hxx.

Member Data Documentation

SeqAlloc YACS::ENGINE::SequenceAny::_alloc
protected

Definition at line 231 of file Any.hxx.

Referenced by clear(), performCpy(), popBack(), pushBack(), realloc(), SequenceAny(), and ~SequenceAny().


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