Version: 9.15.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
 
AnyPtr operator[] (const char *key) const
 
void setEltAtRank (int i, const Any *elem)
 
void setEltAtRank (const char *key, const Any *elem)
 
- 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 () const
 

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
 
- 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)
 
- Static Protected Member Functions inherited from YACS::ENGINE::Any
static bool IsNull (char *data)
 

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
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

Detailed Description

Definition at line 286 of file Any.hxx.

Constructor & Destructor Documentation

◆ ~StructAny()

StructAny::~StructAny ( )
private

Definition at line 1156 of file Any.cxx.

1157 {
1158  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1159  vector< pair<string,TypeCode*> >::const_iterator iter;
1160  char *whereToGet=_data;
1161  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1162  {
1163  (*iter).second->destroyZippedAny(whereToGet);
1164  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1165  }
1166  delete [] _data;
1167 }
TypeCode * _type
Definition: Any.hxx:106
Class for struct type.
Definition: TypeCode.hxx:228
std::vector< std::pair< std::string, TypeCode * > > _members
Definition: TypeCode.hxx:257

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

◆ StructAny() [1/3]

StructAny::StructAny ( TypeCodeStruct type)
private

Definition at line 1169 of file Any.cxx.

1169  :ComposedAny(type,false)
1170 {
1172  for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
1174 }
ComposedAny(const ComposedAny &other)
Definition: Any.cxx:500
static const char DFT_CHAR_VAR
Definition: Any.hxx:181
virtual unsigned getSizeInByteOfAnyReprInSeq() const
Definition: TypeCode.cxx:157

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

◆ StructAny() [2/3]

StructAny::StructAny ( const StructAny other)
private

Definition at line 1176 of file Any.cxx.

1176  :ComposedAny(other)
1177 {
1179  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1180  vector< pair<string,TypeCode*> >::const_iterator iter;
1181  unsigned offset=0;
1182  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1183  {
1184  (*iter).second->putReprAtPlace(_data+offset,other._data+offset,true);
1185  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1186  }
1187 }
virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const
Definition: TypeCode.cxx:57

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

◆ StructAny() [3/3]

StructAny::StructAny ( char *  data,
TypeCodeStruct type 
)
private

Definition at line 1189 of file Any.cxx.

1189  :ComposedAny(type,false),_data(0)
1190 {
1192  vector< pair<string,TypeCode*> >::const_iterator iter;
1193  unsigned offset=0;
1194  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1195  {
1196  (*iter).second->putReprAtPlace(_data+offset,data+offset,false);
1197  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1198  }
1199 }

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

Member Function Documentation

◆ clone()

Any * StructAny::clone ( ) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 1055 of file Any.cxx.

1056 {
1057  return new StructAny(*this);
1058 }
friend class StructAny
Definition: Any.hxx:82

References YACS::ENGINE::Any::StructAny.

◆ destroyReprAtPlace()

void StructAny::destroyReprAtPlace ( char *  data,
const TypeCodeStruct type 
)
staticprotected

Definition at line 1138 of file Any.cxx.

1139 {
1140  char *whereToGet=data;
1141  vector< pair<string,TypeCode*> >::const_iterator iter;
1142  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1143  {
1144  (*iter).second->destroyZippedAny(whereToGet);
1145  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1146  }
1147 }

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

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

◆ getOrBuildFromData()

AnyPtr StructAny::getOrBuildFromData ( char *  data,
const TypeCodeStruct type 
)
staticprotected

Definition at line 1149 of file Any.cxx.

1150 {
1151  Any *ret;
1152  ret=new StructAny(data,(TypeCodeStruct *)type);
1153  return AnyPtr(ret);
1154 }
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
SharedPtr< Any > AnyPtr
Definition: Any.hxx:72

References YACS::ENGINE::Any::StructAny.

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

◆ New()

StructAny * StructAny::New ( TypeCodeStruct type)
static

Definition at line 1201 of file Any.cxx.

1202 {
1203  return new StructAny(type);
1204 }

References YACS::ENGINE::Any::StructAny.

◆ operator==()

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

Implements YACS::ENGINE::Any.

Definition at line 1060 of file Any.cxx.

1061 {
1062  if(!_type->isA(other.getType()))
1063  return false;
1064  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1065  vector< pair<string,TypeCode*> >::const_iterator iter;
1066  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1067  if(!((*(*this)[(*iter).first.c_str()]==(*other[(*iter).first.c_str()]))))
1068  return false;
1069  return true;
1070 }
const TypeCode * getType() const
Definition: Any.hxx:85
virtual int isA(const char *repositoryId) const
Definition: TypeCode.cxx:99

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

◆ operator[]() [1/2]

AnyPtr StructAny::operator[] ( const char *  key) const
virtual

Reimplemented from YACS::ENGINE::ComposedAny.

Definition at line 1078 of file Any.cxx.

1079 {
1080  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1081  char *whereToGet=_data;
1082  vector< pair<string,TypeCode*> >::const_iterator iter;
1083  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1084  if((*iter).first!=key)
1085  whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1086  else
1087  break;
1088  if(iter==typeC->_members.end())
1089  {
1090  string what("Unexisting key \""); what+=key; what+="\" for struct extraction.";
1091  throw Exception(what);
1092  }
1093  return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
1094 }

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

◆ operator[]() [2/2]

AnyPtr StructAny::operator[] ( int  i) const
virtual

Implements YACS::ENGINE::Any.

Definition at line 1072 of file Any.cxx.

1073 {
1074  const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
1075  throw Exception(what);
1076 }

◆ putMyReprAtPlace()

void StructAny::putMyReprAtPlace ( char *  data) const
protectedvirtual

Implements YACS::ENGINE::Any.

Definition at line 1115 of file Any.cxx.

1116 {
1117  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1118  unsigned offset=0;
1119  vector< pair<string,TypeCode*> >::const_iterator iter;
1120  for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1121  {
1122  (*iter).second->putReprAtPlace(data+offset,_data+offset,false);
1123  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1124  }
1125 }

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

◆ putReprAtPlace()

void StructAny::putReprAtPlace ( char *  data,
const char *  src,
const TypeCodeStruct type,
bool  deepCpy 
)
staticprotected

Definition at line 1127 of file Any.cxx.

1128 {
1129  unsigned offset=0;
1130  vector< pair<string,TypeCode*> >::const_iterator iter;
1131  for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1132  {
1133  (*iter).second->putReprAtPlace(data+offset,src+offset,deepCpy);
1134  offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1135  }
1136 }

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

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

◆ setEltAtRank() [1/2]

void StructAny::setEltAtRank ( const char *  key,
const Any elem 
)

Definition at line 1102 of file Any.cxx.

1103 {
1104  const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1105  unsigned offset;
1106  const TypeCode *tcOnKey=typeC->getMember(key,offset);
1107  if(!tcOnKey)
1108  throw Exception("StructAny::setEltAtRank : invalid key given.");
1109  if(!elem->getType()->isA(tcOnKey))
1110  throw Exception("StructAny::setEltAtRank : invalid data type on the specified given key.");
1111  tcOnKey->destroyZippedAny(_data+offset);
1112  elem->putMyReprAtPlace(_data+offset);
1113 }
virtual void putMyReprAtPlace(char *data) const =0
const TypeCode * getMember(const std::string &name, unsigned &offset) const
Get typecode of struct member given its name.
Definition: TypeCode.cxx:801
Base class for all type objects.
Definition: TypeCode.hxx:68
virtual void destroyZippedAny(char *data) const
Definition: TypeCode.cxx:62

References _data, YACS::ENGINE::Any::_type, YACS::ENGINE::TypeCode::destroyZippedAny(), YACS::ENGINE::TypeCodeStruct::getMember(), YACS::ENGINE::Any::getType(), YACS::ENGINE::TypeCode::isA(), and YACS::ENGINE::Any::putMyReprAtPlace().

◆ setEltAtRank() [2/2]

void StructAny::setEltAtRank ( int  i,
const Any elem 
)
virtual

Implements YACS::ENGINE::ComposedAny.

Definition at line 1096 of file Any.cxx.

1097 {
1098  const char what[]="Struct key are strings not integers.";
1099  throw Exception(what);
1100 }

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

Friends And Related Function Documentation

◆ TypeCodeStruct

friend class TypeCodeStruct
friend

Definition at line 288 of file Any.hxx.

Member Data Documentation

◆ _data

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

Definition at line 308 of file Any.hxx.

Referenced by operator[](), putMyReprAtPlace(), setEltAtRank(), StructAny(), and ~StructAny().


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