Version: 8.3.0
YACS::ENGINE::ArrayAny Class Reference

#include <Any.hxx>

Inheritance diagram for YACS::ENGINE::ArrayAny:
Collaboration diagram for YACS::ENGINE::ArrayAny:

Public Member Functions

void setEltAtRank (int i, const Any *elem) throw (Exception)
 
bool operator== (const Any &other) const
 
AnyPtr operator[] (int i) const throw (Exception)
 
unsigned int size () const
 
Anyclone () const
 
template<class T >
ArrayAnyNew (const std::vector< T > &vec)
 
template<class T >
ArrayAnyNew (const T *val, unsigned int lgth)
 
- 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 ArrayAnyNew (const std::vector< T > &vec)
 
template<class T >
static ArrayAnyNew (const T *val, unsigned int lgth)
 
static ArrayAnyNew (const TypeCode *typeOfContent, unsigned int lgth)
 

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 TypeCodeArray *type, bool deepCpy)
 
static void destroyReprAtPlace (char *data, const TypeCodeArray *type)
 
static AnyPtr getOrBuildFromData (char *data, const TypeCodeArray *type)
 
static bool takeInChargeStorageOf (TypeCode *type)
 

Protected Attributes

char * _data
 

Private Member Functions

 ~ArrayAny ()
 
 ArrayAny (const TypeCode *typeOfContent, unsigned int lgth)
 
 ArrayAny (char *data, TypeCodeArray *type)
 
 ArrayAny (const ArrayAny &other)
 
 ArrayAny (const int *val, unsigned int lgth)
 
 ArrayAny (const bool *val, unsigned int lgth)
 
 ArrayAny (const double *val, unsigned int lgth)
 
 ArrayAny (const std::vector< int > &val)
 
 ArrayAny (const std::vector< double > &val)
 
 ArrayAny (const std::vector< std::string > &val)
 

Friends

class TypeCodeArray
 

Additional Inherited Members

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

Detailed Description

Definition at line 236 of file Any.hxx.

Constructor & Destructor Documentation

ArrayAny::~ArrayAny ( )
private

Definition at line 717 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::destroyZippedAny(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), CORBAEngineTest::i, and size().

718 {
719  const TypeCode *subType=_type->contentType();
720  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
721  unsigned int size=((TypeCodeArray *)_type)->getStaticLgth();
722  char *tmp=_data;
723  for(unsigned i=0;i<size;i++,tmp+=sizePerContent)
724  subType->destroyZippedAny(tmp);
725  delete [] _data;
726 }
ArrayAny::ArrayAny ( const TypeCode typeOfContent,
unsigned int  lgth 
)
private

Definition at line 728 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::SeqAlloc::DFT_CHAR_VAR, YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), and CORBAEngineTest::i.

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

728  :ComposedAny(new TypeCodeArray("","",typeOfContent,lgth))
729 {
731  for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
733 }
ArrayAny::ArrayAny ( char *  data,
TypeCodeArray type 
)
private

Definition at line 735 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), YACS::ENGINE::TypeCodeArray::getStaticLgth(), CORBAEngineTest::i, and YACS::ENGINE::TypeCode::putReprAtPlace().

735  :ComposedAny(type,false),_data(0)
736 {
738  const TypeCode *subType=_type->contentType();
739  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
740  for(unsigned i=0;i<type->getStaticLgth();i++)
741  subType->putReprAtPlace(_data+i*sizePerContent,data+i*sizePerContent,false);
742 }
ArrayAny::ArrayAny ( const ArrayAny other)
private

Definition at line 744 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), CORBAEngineTest::i, and YACS::ENGINE::TypeCode::putReprAtPlace().

744  :ComposedAny(other)
745 {
747  const TypeCode *subType=_type->contentType();
748  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
749  for(unsigned i=0;i<((TypeCodeArray *)_type)->getStaticLgth();i++)
750  subType->putReprAtPlace(_data+i*sizePerContent,other._data+i*sizePerContent,true);
751 }
ArrayAny::ArrayAny ( const int *  val,
unsigned int  lgth 
)
private

Definition at line 753 of file Any.cxx.

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

753  :ComposedAny(new TypeCodeArray("","",Runtime::_tc_int,lgth)),
754  _data(0)
755 {
757  memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
758 }
ArrayAny::ArrayAny ( const bool *  val,
unsigned int  lgth 
)
private

Definition at line 760 of file Any.cxx.

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

760  :ComposedAny(new TypeCodeArray("","",Runtime::_tc_bool,lgth)),
761  _data(0)
762 {
764  memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
765 }
ArrayAny::ArrayAny ( const double *  val,
unsigned int  lgth 
)
private

Definition at line 767 of file Any.cxx.

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

768  _data(0)
769 {
771  memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
772 }
ArrayAny::ArrayAny ( const std::vector< int > &  val)
private

Definition at line 774 of file Any.cxx.

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

774  :ComposedAny(new TypeCodeArray("","",Runtime::_tc_int,val.size())),
775  _data(0)
776 {
778  memcpy(_data,&val[0],_type->getSizeInByteOfAnyReprInSeq());
779 }
ArrayAny::ArrayAny ( const std::vector< double > &  val)
private

Definition at line 781 of file Any.cxx.

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

781  :ComposedAny(new TypeCodeArray("","",Runtime::_tc_double,val.size())),
782  _data(0)
783 {
785  memcpy(_data,&val[0],_type->getSizeInByteOfAnyReprInSeq());
786 }
ArrayAny::ArrayAny ( const std::vector< std::string > &  val)
private

Definition at line 788 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), and CORBAEngineTest::i.

788  :ComposedAny(new TypeCodeArray("","",Runtime::_tc_string,val.size())),
789  _data(0)
790 {
792  unsigned i=0;
793  const TypeCode *subType=_type->contentType();
794  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
795  for(vector<std::string>::const_iterator iter=val.begin();iter!=val.end();iter++,i++)
796  {
797  StringOnHeap *st=new StringOnHeap(*iter);
798  memcpy(_data+i*sizePerContent,&st,sizePerContent);
799  }
800 }

Member Function Documentation

Any * ArrayAny::clone ( ) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 835 of file Any.cxx.

References ArrayAny().

836 {
837  return new ArrayAny(*this);
838 }
void ArrayAny::destroyReprAtPlace ( char *  data,
const TypeCodeArray type 
)
staticprotected

Definition at line 861 of file Any.cxx.

References YACS::ENGINE::TypeCodeArray::contentType(), YACS::ENGINE::TypeCode::destroyZippedAny(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), YACS::ENGINE::TypeCodeArray::getStaticLgth(), and CORBAEngineTest::i.

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

862 {
863  const TypeCode *subType=type->contentType();
864  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
865  for(unsigned i=0;i<type->getStaticLgth();i++)
866  subType->destroyZippedAny(data+i*sizePerContent);
867 }
AnyPtr ArrayAny::getOrBuildFromData ( char *  data,
const TypeCodeArray type 
)
staticprotected

Definition at line 869 of file Any.cxx.

References ArrayAny(), and PMMLBasicsTestLauncher::ret.

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

870 {
871  Any *ret;
872  ret=new ArrayAny(data,(TypeCodeArray *)type);
873  return AnyPtr(ret);
874 }
template<class T >
static ArrayAny* YACS::ENGINE::ArrayAny::New ( const std::vector< T > &  vec)
static
template<class T >
static ArrayAny* YACS::ENGINE::ArrayAny::New ( const T *  val,
unsigned int  lgth 
)
static
ArrayAny * ArrayAny::New ( const TypeCode typeOfContent,
unsigned int  lgth 
)
static

Definition at line 840 of file Any.cxx.

References ArrayAny().

841 {
842  return new ArrayAny(typeOfContent,lgth);
843 }
template<class T >
ArrayAny* YACS::ENGINE::ArrayAny::New ( const std::vector< T > &  vec)

Definition at line 311 of file Any.hxx.

312  {
313  return new ArrayAny(vec);
314  }
template<class T >
ArrayAny* YACS::ENGINE::ArrayAny::New ( const T *  val,
unsigned int  lgth 
)

Definition at line 317 of file Any.hxx.

318  {
319  return new ArrayAny(val,lgth);
320  }
bool ArrayAny::operator== ( const Any other) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 810 of file Any.cxx.

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

811 {
812  if(!_type->isA(other.getType()))
813  return false;
814  const ArrayAny& otherC=(const ArrayAny&) other;//cast granted due to previous lines
815  for(unsigned i=0;i<((const TypeCodeArray *)_type)->getStaticLgth();i++)
816  if(!((*(*this)[i])==(*otherC[i])))
817  return false;
818  return true;
819 }
AnyPtr ArrayAny::operator[] ( int  i) const throw (Exception)
virtual

Implements YACS::ENGINE::Any.

Definition at line 821 of file Any.cxx.

References YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), and CORBAEngineTest::i.

822 {
823  const TypeCode *subType=_type->contentType();
824  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
825  if(i<0 || i>=((TypeCodeArray *)_type)->getStaticLgth())
826  throw Exception("Trying to access to an invalid index in an Any Tuple");
827  return _type->contentType()->getOrBuildAnyFromZippedData(_data+i*sizePerContent);
828 }
void ArrayAny::putMyReprAtPlace ( char *  data) const
protectedvirtual

Implements YACS::ENGINE::Any.

Definition at line 845 of file Any.cxx.

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), CORBAEngineTest::i, and YACS::ENGINE::TypeCode::putReprAtPlace().

846 {
847  const TypeCode *subType=_type->contentType();
848  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
849  for(unsigned i=0;i<((const TypeCodeArray *)_type)->getStaticLgth();i++)
850  subType->putReprAtPlace(data+i*sizePerContent,_data+i*sizePerContent,false);
851 }
void ArrayAny::putReprAtPlace ( char *  data,
const char *  src,
const TypeCodeArray type,
bool  deepCpy 
)
staticprotected

Definition at line 853 of file Any.cxx.

References YACS::ENGINE::TypeCodeArray::contentType(), YACS::ENGINE::TypeCode::getSizeInByteOfAnyReprInSeq(), YACS::ENGINE::TypeCodeArray::getStaticLgth(), CORBAEngineTest::i, and YACS::ENGINE::TypeCode::putReprAtPlace().

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

854 {
855  const TypeCode *subType=type->contentType();
856  unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
857  for(unsigned i=0;i<type->getStaticLgth();i++)
858  subType->putReprAtPlace(data+i*sizePerContent,src+i*sizePerContent,deepCpy);
859 }
void ArrayAny::setEltAtRank ( int  i,
const Any elem 
) throw (Exception)
virtual
unsigned int ArrayAny::size ( ) const

Definition at line 830 of file Any.cxx.

References YACS::ENGINE::Any::_type.

Referenced by ~ArrayAny().

831 {
832  return ((TypeCodeArray *)_type)->getStaticLgth();
833 }
bool ArrayAny::takeInChargeStorageOf ( TypeCode type)
staticprotected

Definition at line 876 of file Any.cxx.

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

877 {
878  DynType typ=type->kind();
879  return (typ==Array);
880 }

Friends And Related Function Documentation

friend class TypeCodeArray
friend

Definition at line 238 of file Any.hxx.

Member Data Documentation

char* YACS::ENGINE::ArrayAny::_data
protected

Definition at line 268 of file Any.hxx.

Referenced by ArrayAny(), putMyReprAtPlace(), and ~ArrayAny().


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