00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "StructDef.h"
00024
00025 #include "Repository.h"
00026 #include "PersistNode.h"
00027
00028 namespace Omniifr {
00029
00030 StructMemberSeq* StructDef_impl::members()
00031 {
00032 return _members.copy();
00033 }
00034
00035 void StructDef_impl::members(const StructMemberSeq& v)
00036 {
00037 checkReadonly();
00038
00039
00040
00041
00042
00043
00044 StructMemberSeq temp(v);
00045 for(ULong i=0; i<temp.length(); i++)
00046 {
00047 if(CORBA::is_nil(temp[i].type_def))
00048 throw CORBA::BAD_PARAM(
00049 IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidObjectRef,43),
00050 CORBA::COMPLETED_NO
00051 );
00052 try {
00053 temp[i].type=temp[i].type_def->type();
00054 }
00055 catch(...) {
00056 DB(15,"Caught exception at "<<__FILE__<<":"<<__LINE__)
00057 throw;
00058 }
00059 }
00060
00061 _members.assign(temp);
00062 }
00063
00064 TypeCode_ptr StructDef_impl::type()
00065 {
00066 return Repository_impl::inst()._orb
00067 ->create_struct_tc(_id.in(),_name.in(),_members.in());
00068 }
00069
00070 void StructDef_impl::uncheckedDestroy()
00071 {
00072 _members.clear();
00073 Contained_impl::uncheckedDestroy();
00074 Container_impl::uncheckedDestroy();
00075 }
00076
00077 bool StructDef_impl::canContain(DefinitionKind kind)
00078 {
00079 switch(kind)
00080 {
00081 case dk_Struct:
00082 case dk_Union:
00083 case dk_Enum:
00084 return true;
00085 default:
00086 return false;
00087 }
00088 }
00089
00090 void StructDef_impl::reincarnate(const PersistNode& node)
00091 {
00092 cdrMemoryStream memstr =node.attrCdrStream("state");
00093 StructMemberSeq m;
00094 m<<=memstr;
00095 _members.uncheckedAssign(m);
00096 }
00097
00098 void StructDef_impl::output(ostream &os)
00099 {
00100 outputSelf(os,"StructDef");
00101 cdrMemoryStream memstr(CORBA::ULong(0),CORBA::Boolean(1));
00102 _members.in()>>=memstr;
00103 PersistNode::outputCdrMemoryStream(os,memstr,"\n state=");
00104 os<<" ;;\n";
00105 outputContents(os);
00106 }
00107
00108 }