Version: 9.16.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)
 
AnyPtr operator[] (int i) const
 
Anyclone () const
 
std::vector< unsigned int > getSetItems () const
 
SequenceAnyremoveUnsetItemsFromThis () const
 
- Public Member Functions inherited from YACS::ENGINE::ComposedAny
virtual void setEltAtRank (int i, const Any *elem)=0
 
AnyPtr operator[] (const char *key) const
 
- Public Member Functions inherited from YACS::ENGINE::Any
const TypeCodegetType () const
 
virtual Anyclone () const =0
 
virtual AnyPtr operator[] (int i) const =0
 
virtual AnyPtr operator[] (const char *key) const =0
 
virtual bool operator== (const Any &other) const =0
 
virtual int getIntValue () const =0
 
virtual bool getBoolValue () const =0
 
virtual double getDoubleValue () const =0
 
virtual std::string getStringValue () const =0
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef () const
 

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
 
- Protected Member Functions inherited from YACS::ENGINE::Any
virtual ~Any ()
 
 Any (TypeCode *type)
 
 Any (const Any &other)
 
virtual void putMyReprAtPlace (char *data) const =0
 
- 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)
 
- Static Protected Member Functions inherited from YACS::ENGINE::Any
static bool IsNull (char *data)
 

Protected Attributes

SeqAlloc _alloc
 
- Protected Attributes inherited from YACS::ENGINE::Any
TypeCode_type
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

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 203 of file Any.hxx.

Constructor & Destructor Documentation

◆ ~SequenceAny()

SequenceAny::~SequenceAny ( )
private

Definition at line 793 of file Any.cxx.

794{
795 for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
797}
TypeCode * _type
Definition: Any.hxx:106
void destroy(char *pt, const TypeCode *tc)
Definition: Any.cxx:633
const unsigned int _sizeOf1Elm
Definition: Any.hxx:166
virtual const TypeCode * contentType() const
Definition: TypeCode.cxx:174

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

◆ SequenceAny() [1/10]

SequenceAny::SequenceAny ( const SequenceAny other)
private

Definition at line 786 of file Any.cxx.

786 :ComposedAny(other),_alloc(other._alloc)
787{
788 const char *srcCur=other._alloc._start;
789 for(char *cur=_alloc._start;srcCur != other._alloc._finish; srcCur+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
790 _alloc.construct(cur, srcCur, _type->contentType(),true);
791}
ComposedAny(const ComposedAny &other)
Definition: Any.cxx:500
void construct(char *pt, const Any *val)
Definition: Any.cxx:593

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().

◆ SequenceAny() [2/10]

SequenceAny::SequenceAny ( const TypeCode typeOfContent)
private
Parameters
typeOfContent: typeCode of the type of elements stored in sequence.

Definition at line 802 of file Any.cxx.

802 :ComposedAny(new TypeCodeSeq("","",typeOfContent)),
803 _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
804{
805}
friend class TypeCodeSeq
Definition: Any.hxx:205
virtual unsigned getSizeInByteOfAnyReprInSeq() const
Definition: TypeCode.cxx:157

◆ SequenceAny() [3/10]

SequenceAny::SequenceAny ( const TypeCode typeOfContent,
unsigned  lgth 
)
private

Definition at line 807 of file Any.cxx.

807 :ComposedAny(new TypeCodeSeq("","",typeOfContent)),
808 _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
809{
810 _alloc.initCoarseMemory(0,lgth,0);
811}
void initCoarseMemory(char *mem, unsigned int size, Deallocator dealloc)
Definition: Any.cxx:571

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

◆ SequenceAny() [4/10]

SequenceAny::SequenceAny ( int *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 813 of file Any.cxx.

814 _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
815{
816 _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
817}
static YACS::ENGINE::TypeCode * _tc_int
Definition: Runtime.hxx:137

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

◆ SequenceAny() [5/10]

SequenceAny::SequenceAny ( bool *  val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 819 of file Any.cxx.

820 _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
821{
822 _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
823}
static YACS::ENGINE::TypeCode * _tc_bool
Definition: Runtime.hxx:138

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

◆ SequenceAny() [6/10]

SequenceAny::SequenceAny ( double val,
unsigned int  lgth,
Deallocator  deAlloc 
)
private

Definition at line 825 of file Any.cxx.

826 _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
827{
828 _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
829}
static YACS::ENGINE::TypeCode * _tc_double
Definition: Runtime.hxx:136

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

◆ SequenceAny() [7/10]

SequenceAny::SequenceAny ( const std::vector< int > &  val)
private

Definition at line 831 of file Any.cxx.

832 _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
833{
834 _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
835}

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

◆ SequenceAny() [8/10]

SequenceAny::SequenceAny ( const std::vector< bool > &  val)
private

Definition at line 837 of file Any.cxx.

838 _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
839{
840 for(vector<bool>::const_iterator iter=val.begin();iter!=val.end();iter++)
841 {
842 AtomAnyPtr tmp=AtomAny::New(*iter);
843 pushBack(tmp);
844 }
845}
: Allow to manage memory of instances of T. The only constraint on T is to have method incrRef and De...
Definition: SharedPtr.hxx:30
static AtomAny * New(T val)
Definition: Any.hxx:126
void pushBack(const Any *elem)
Definition: Any.cxx:670

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

◆ SequenceAny() [9/10]

SequenceAny::SequenceAny ( const std::vector< double > &  val)
private

Definition at line 847 of file Any.cxx.

848 _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
849{
850 _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
851}

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

◆ SequenceAny() [10/10]

SequenceAny::SequenceAny ( const std::vector< std::string > &  val)
private

Definition at line 853 of file Any.cxx.

854 _alloc(Runtime::_tc_string->getSizeInByteOfAnyReprInSeq())
855{
856 for(vector<string>::const_iterator iter=val.begin();iter!=val.end();iter++)
857 {
858 AtomAnyPtr tmp=AtomAny::New(*iter);
859 pushBack(tmp);
860 }
861}
static YACS::ENGINE::TypeCode * _tc_string
Definition: Runtime.hxx:139

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

Member Function Documentation

◆ clear()

◆ clone()

Any * SequenceAny::clone ( ) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 752 of file Any.cxx.

753{
754 return new SequenceAny(*this);
755}
friend class SequenceAny
Definition: Any.hxx:83

References YACS::ENGINE::Any::SequenceAny.

◆ destroyReprAtPlace()

void SequenceAny::destroyReprAtPlace ( char *  data,
const TypeCode type 
)
staticprotected

Definition at line 737 of file Any.cxx.

738{
739 void **tmp=(void **) data;
740 if(!Any::IsNull(data))
741 ((SequenceAny *)(*tmp))->decrRef();
742 //((SequenceAny *)data)->~SequenceAny();
743}
static bool IsNull(char *data)
Definition: Any.cxx:248

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

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

◆ getOrBuildFromData()

AnyPtr SequenceAny::getOrBuildFromData ( char *  data,
const TypeCode type 
)
staticprotected

Definition at line 745 of file Any.cxx.

746{
747 void **tmp=(void **) data;
748 ((SequenceAny *) (*tmp))->incrRef();
749 return AnyPtr((SequenceAny *)(*tmp));
750}
SharedPtr< Any > AnyPtr
Definition: Any.hxx:72

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

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

◆ getSetItems()

std::vector< unsigned int > YACS::ENGINE::SequenceAny::getSetItems ( ) const
inline

Definition at line 221 of file Any.hxx.

221{ return _alloc.getSetItems(); }
std::vector< unsigned int > getSetItems() const
Definition: Any.cxx:643

Referenced by removeUnsetItemsFromThis().

◆ New() [1/4]

template<class T >
SequenceAny * YACS::ENGINE::SequenceAny::New ( const std::vector< T > &  vec)
static

◆ New() [2/4]

SequenceAny * SequenceAny::New ( const TypeCode typeOfContent)
static

Definition at line 770 of file Any.cxx.

771{
772 return new SequenceAny(typeOfContent);
773}

References YACS::ENGINE::Any::SequenceAny.

◆ New() [3/4]

SequenceAny * SequenceAny::New ( const TypeCode typeOfContent,
unsigned  lgth 
)
static

Definition at line 775 of file Any.cxx.

776{
777 return new SequenceAny(typeOfContent,lgth);
778}

References YACS::ENGINE::Any::SequenceAny.

◆ New() [4/4]

template<class T >
SequenceAny * YACS::ENGINE::SequenceAny::New ( T val,
unsigned int  lgth,
Deallocator  deAlloc 
)
static

Definition at line 312 of file Any.hxx.

313 {
314 return new SequenceAny(val,lgth,deAlloc);
315 }

References YACS::ENGINE::Any::SequenceAny.

◆ operator==()

bool SequenceAny::operator== ( const Any other) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 683 of file Any.cxx.

684{
685 if(!_type->isA(other.getType()))
686 return false;
687 const SequenceAny& otherC=(const SequenceAny&) other;//cast granted due to previous lines
688 if(size()!=otherC.size())
689 return false;
690 for(unsigned i=0;i<size();i++)
691 if(!((*(*this)[i])==(*otherC[i])))
692 return false;
693 return true;
694}
const TypeCode * getType() const
Definition: Any.hxx:85
unsigned int size() const
Definition: Any.hxx:209
virtual int isA(const char *repositoryId) const
Definition: TypeCode.cxx:99

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

◆ operator[]()

◆ performCpy()

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

Definition at line 882 of file Any.cxx.

883{
884 char *cur=destStart;
885 for (;srcStart != srcFinish; srcStart+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
886 _alloc.construct(cur, srcStart, _type->contentType(),false);
887 return cur;
888}

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

Referenced by realloc().

◆ popBack()

◆ pushBack()

◆ putMyReprAtPlace()

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

713{
714 const void *tmp=(const void *)this;
715 memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
716 const void **tmp2=(const void **) data;
717 ((SequenceAny *)(*tmp2))->incrRef();
718 //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
719}

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

◆ putReprAtPlace()

void SequenceAny::putReprAtPlace ( char *  data,
const char *  src,
const TypeCode type,
bool  deepCpy 
)
staticprotected

Definition at line 721 of file Any.cxx.

722{
723 void **tmp2=(void **) src;
724 if(!deepCpy)
725 {
726 ((SequenceAny *)(*tmp2))->incrRef();
727 memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
728 }
729 else
730 {
731 SequenceAny *cpy=new SequenceAny(*((SequenceAny *)(*tmp2)));
732 memcpy(data,&cpy,type->getSizeInByteOfAnyReprInSeq());
733 }
734 //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
735}

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

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

◆ realloc()

void SequenceAny::realloc ( char *  endOfCurrentAllocated,
const Any elem 
)
private

Definition at line 863 of file Any.cxx.

864{
865 unsigned int oldSize=_alloc._finish-_alloc._start;
866 unsigned int newSize = oldSize != 0 ? 2 * oldSize : _alloc._sizeOf1Elm;
867 char *newStart=_alloc.allocate(newSize);
868 //
869 char *newFinish=performCpy(_alloc._start, endOfCurrentAllocated,newStart);
870 _alloc.construct(newFinish, elem);
871 newFinish+=_alloc._sizeOf1Elm;
872 newFinish=performCpy(endOfCurrentAllocated, _alloc._finish, newFinish);
873 //
874 for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
877 _alloc._start = newStart;
878 _alloc._finish = newFinish;
879 _alloc._endOfStorage=newStart+newSize;
880}
char * allocate(unsigned int nbOfByte)
Definition: Any.cxx:610
void deallocate(char *pt)
Definition: Any.cxx:619
char * performCpy(char *srcStart, char *srcFinish, char *destStart)
Definition: Any.cxx:882

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().

◆ removeUnsetItemsFromThis()

SequenceAny * SequenceAny::removeUnsetItemsFromThis ( ) const

Definition at line 757 of file Any.cxx.

758{
759 std::vector<unsigned int> its(getSetItems());
760 std::size_t sz(its.size());
761 SequenceAny *ret(SequenceAny::New(getType()->contentType(),sz));
762 for(std::size_t i=0;i<sz;i++)
763 {
764 AnyPtr obj((*this)[its[i]]);
765 ret->setEltAtRank(i,obj);
766 }
767 return ret;
768}
std::vector< unsigned int > getSetItems() const
Definition: Any.hxx:221
static SequenceAny * New(const std::vector< T > &vec)
Definition: Any.hxx:318

References getSetItems(), YACS::ENGINE::Any::getType(), yacsorb.CORBAEngineTest::i, New(), and setEltAtRank().

◆ setEltAtRank()

◆ size()

◆ takeInChargeStorageOf()

bool SequenceAny::takeInChargeStorageOf ( TypeCode type)
staticprotected

Definition at line 780 of file Any.cxx.

781{
782 DynType typ=type->kind();
783 return (typ==Sequence);
784}

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

Friends And Related Function Documentation

◆ TypeCodeSeq

friend class TypeCodeSeq
friend

Definition at line 205 of file Any.hxx.

Member Data Documentation

◆ _alloc

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

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