Version: 8.3.0
YACS::ENGINE::StructAny Class Reference

#include <Any.hxx>

Inheritance diagram for YACS::ENGINE::StructAny:
Collaboration diagram for YACS::ENGINE::StructAny:

Public Member Functions

Anyclone () const
 
bool operator== (const Any &other) const
 
AnyPtr operator[] (int i) const throw (Exception)
 
AnyPtr operator[] (const char *key) const throw (Exception)
 
void setEltAtRank (int i, const Any *elem) throw (Exception)
 
void setEltAtRank (const char *key, const Any *elem) throw (Exception)
 

Static Public Member Functions

static StructAnyNew (TypeCodeStruct *type)
 

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

Private Member Functions

 ~StructAny ()
 
 StructAny (TypeCodeStruct *type)
 
 StructAny (const StructAny &other)
 
 StructAny (char *data, TypeCodeStruct *type)
 

Private Attributes

char * _data
 

Friends

class TypeCodeStruct
 

Additional Inherited Members

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

Detailed Description

Definition at line 273 of file Any.hxx.

Constructor & Destructor Documentation

StructAny::~StructAny ( )
private

Definition at line 983 of file Any.cxx.

References _data, YACS::ENGINE::TypeCodeStruct::_members, and YACS::ENGINE::Any::_type.

984 {
985  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
986  vector< pair<string,TypeCode*> >::const_iterator iter;
987  char *whereToGet=_data;
988  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
989  {
990  (*iter).second->destroyZippedAny(whereToGet);
991  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
992  }
993  delete [] _data;
994 }
StructAny::StructAny ( TypeCodeStruct type)
private
StructAny::StructAny ( const StructAny other)
private

Definition at line 1003 of file Any.cxx.

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

1003  :ComposedAny(other)
1004 {
1006  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1007  vector< pair<string,TypeCode*> >::const_iterator iter;
1008  unsigned offset=0;
1009  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1010  {
1011  (*iter).second->putReprAtPlace(_data+offset,other._data+offset,true);
1012  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1013  }
1014 }
StructAny::StructAny ( char *  data,
TypeCodeStruct type 
)
private

Definition at line 1016 of file Any.cxx.

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

1016  :ComposedAny(type,false),_data(0)
1017 {
1019  vector< pair<string,TypeCode*> >::const_iterator iter;
1020  unsigned offset=0;
1021  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1022  {
1023  (*iter).second->putReprAtPlace(_data+offset,data+offset,false);
1024  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1025  }
1026 }

Member Function Documentation

Any * StructAny::clone ( ) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 882 of file Any.cxx.

References StructAny().

883 {
884  return new StructAny(*this);
885 }
void StructAny::destroyReprAtPlace ( char *  data,
const TypeCodeStruct type 
)
staticprotected

Definition at line 965 of file Any.cxx.

References YACS::ENGINE::TypeCodeStruct::_members.

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

966 {
967  char *whereToGet=data;
968  vector< pair<string,TypeCode*> >::const_iterator iter;
969  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
970  {
971  (*iter).second->destroyZippedAny(whereToGet);
972  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
973  }
974 }
AnyPtr StructAny::getOrBuildFromData ( char *  data,
const TypeCodeStruct type 
)
staticprotected

Definition at line 976 of file Any.cxx.

References PMMLBasicsTestLauncher::ret, and StructAny().

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

977 {
978  Any *ret;
979  ret=new StructAny(data,(TypeCodeStruct *)type);
980  return AnyPtr(ret);
981 }
StructAny * StructAny::New ( TypeCodeStruct type)
static

Definition at line 1028 of file Any.cxx.

References StructAny().

1029 {
1030  return new StructAny(type);
1031 }
bool StructAny::operator== ( const Any other) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 887 of file Any.cxx.

References YACS::ENGINE::TypeCodeStruct::_members, YACS::ENGINE::Any::_type, YACS::ENGINE::Any::getType(), and YACS::ENGINE::TypeCode::isA().

888 {
889  if(!_type->isA(other.getType()))
890  return false;
891  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
892  vector< pair<string,TypeCode*> >::const_iterator iter;
893  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
894  if(!((*(*this)[(*iter).first.c_str()]==(*other[(*iter).first.c_str()]))))
895  return false;
896  return true;
897 }
AnyPtr StructAny::operator[] ( int  i) const throw (Exception)
virtual

Implements YACS::ENGINE::Any.

Definition at line 899 of file Any.cxx.

900 {
901  const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
902  throw Exception(what);
903 }
AnyPtr StructAny::operator[] ( const char *  key) const throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedAny.

Definition at line 905 of file Any.cxx.

References YACS::ENGINE::TypeCodeStruct::_members, and YACS::ENGINE::TypeCodeStruct::getSizeInByteOfAnyReprInSeq().

906 {
907  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
908  char *whereToGet=_data;
909  vector< pair<string,TypeCode*> >::const_iterator iter;
910  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
911  if((*iter).first!=key)
912  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
913  else
914  break;
915  if(iter==typeC->_members.end())
916  {
917  string what("Unexisting key \""); what+=key; what+="\" for struct extraction.";
918  throw Exception(what);
919  }
920  return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
921 }
void StructAny::putMyReprAtPlace ( char *  data) const
protectedvirtual

Implements YACS::ENGINE::Any.

Definition at line 942 of file Any.cxx.

References _data, YACS::ENGINE::TypeCodeStruct::_members, YACS::ENGINE::Any::_type, and YACS::ENGINE::TypeCode::putReprAtPlace().

943 {
944  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
945  unsigned offset=0;
946  vector< pair<string,TypeCode*> >::const_iterator iter;
947  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
948  {
949  (*iter).second->putReprAtPlace(data+offset,_data+offset,false);
950  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
951  }
952 }
void StructAny::putReprAtPlace ( char *  data,
const char *  src,
const TypeCodeStruct type,
bool  deepCpy 
)
staticprotected

Definition at line 954 of file Any.cxx.

References YACS::ENGINE::TypeCodeStruct::_members.

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

955 {
956  unsigned offset=0;
957  vector< pair<string,TypeCode*> >::const_iterator iter;
958  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
959  {
960  (*iter).second->putReprAtPlace(data+offset,src+offset,deepCpy);
961  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
962  }
963 }
void StructAny::setEltAtRank ( int  i,
const Any elem 
) throw (Exception)
virtual

Implements YACS::ENGINE::ComposedAny.

Definition at line 923 of file Any.cxx.

Referenced by YACS::ENGINE::convertFromYacsStruct< NEUTRALImpl, YACS::ENGINE::Any * >::convert().

924 {
925  const char what[]="Struct key are strings not integers.";
926  throw Exception(what);
927 }
void StructAny::setEltAtRank ( const char *  key,
const Any elem 
) throw (Exception)

Definition at line 929 of file Any.cxx.

References YACS::ENGINE::TypeCode::destroyZippedAny(), and YACS::ENGINE::TypeCodeStruct::getMember().

930 {
931  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
932  unsigned offset;
933  const TypeCode *tcOnKey=typeC->getMember(key,offset);
934  if(!tcOnKey)
935  throw Exception("StructAny::setEltAtRank : invalid key given.");
936  if(!elem->getType()->isA(tcOnKey))
937  throw Exception("StructAny::setEltAtRank : invalid data type on the specified given key.");
938  tcOnKey->destroyZippedAny(_data+offset);
939  elem->putMyReprAtPlace(_data+offset);
940 }

Friends And Related Function Documentation

friend class TypeCodeStruct
friend

Definition at line 275 of file Any.hxx.

Member Data Documentation

char* YACS::ENGINE::StructAny::_data
private

Definition at line 295 of file Any.hxx.

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


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