#include <UnionDef.h>
Inheritance diagram for Omniifr::UnionDef_impl:


Public Member Functions | |
| TypeCode_ptr | discriminator_type () |
| IDLType_ptr | discriminator_type_def () |
| void | discriminator_type_def (IDLType_ptr v) |
| UnionMemberSeq * | members () |
| void | members (const UnionMemberSeq &v) |
| DefinitionKind | def_kind () |
| TypeCode_ptr | type () |
| UnionDef_impl () | |
| virtual | ~UnionDef_impl () |
| void | uncheckedDestroy () |
| Destroys this object, without first checking for dependencies. | |
| bool | canContain (DefinitionKind kind) |
| Returns TRUE if this Container_impl can contain type 'kind'. | |
| void | reincarnate (const PersistNode &node) |
| Re-create the repository from information saved in the log file. | |
| void | output (ostream &os) |
| Save this object's state to a stream. | |
Private Attributes | |
| Dependency1< CORBA::IDLType > | _discriminator_type_def |
| Dependency3< UnionMemberSeq > | _members |
|
|
Definition at line 52 of file UnionDef.h. References _discriminator_type_def, and _members. 00052 :_discriminator_type_def(this),_members(this){}
|
|
|
Definition at line 53 of file UnionDef.h. 00053 {}
|
|
|
Returns TRUE if this Container_impl can contain type 'kind'. Legal relationships are defined in CORBA spec. section 10.4.4 "Structure and Navigation of the Interface Repository". Implements Omniifr::Container_impl. Definition at line 205 of file UnionDef.cc. 00206 {
00207 switch(kind)
00208 {
00209 case dk_Struct:
00210 case dk_Union:
00211 case dk_Enum:
00212 return true;
00213 default:
00214 return false;
00215 }
00216 }
|
|
|
Implements Omniifr::IRObject_impl. Definition at line 44 of file UnionDef.h. 00044 {return dk_Union;}
|
|
|
Definition at line 33 of file UnionDef.cc. References _discriminator_type_def, and Omniifr::Dependency1< T_IRObject >::in(). Referenced by discriminator_type_def(), members(), and type(). 00034 {
00035 return _discriminator_type_def.in()->type();
00036 }
|
|
|
Definition at line 43 of file UnionDef.cc. References _discriminator_type_def, _members, Omniifr::Dependency1< T_IRObject >::assign(), Omniifr::Dependency3< T_xxxDescriptionSeq >::assign(), Omniifr::IRObject_impl::checkReadonly(), discriminator_type(), IFELSE_OMNIORB4, and Omniifr::Dependency1< T_IRObject >::in(). 00044 {
00045 checkReadonly();
00046 TypeCode_var tc =v->type();
00047 TCKind kind =tc->kind();
00048 // Strip out aliases.
00049 while(kind==tk_alias)
00050 {
00051 tc=tc->content_type();
00052 kind=tc->kind();
00053 }
00054
00055 switch(kind)
00056 {
00057 case tk_short: // <integer_type>
00058 case tk_ushort:
00059 case tk_long:
00060 case tk_ulong:
00061 #ifdef HAS_LongLong
00062 case tk_longlong:
00063 case tk_ulonglong:
00064 #endif
00065 case tk_char: // <char_type>
00066 case tk_wchar: // <wide_char_type>
00067 case tk_boolean: // <boolean_type>
00068 case tk_enum:
00069 {
00070 // If discriminator type has changed, then erase _members here,
00071 // to protect against type incompatability.
00072 if(!is_nil(_discriminator_type_def.in()))
00073 {
00074 TypeCode_var oldTc =discriminator_type();
00075 if(!tc->equivalent(oldTc.in()))
00076 _members.assign(UnionMemberSeq()); // clear _members.
00077 }
00078 _discriminator_type_def.assign(CORBA::IDLType::_duplicate(v));
00079 }
00080 break;
00081
00082 default:
00083 throw CORBA::BAD_PARAM(
00084 IFELSE_OMNIORB4(omni::BAD_PARAM_IllegitimateDiscriminatorType,20),
00085 CORBA::COMPLETED_NO
00086 );
00087 }
00088 }
|
|
|
Definition at line 38 of file UnionDef.cc. References _discriminator_type_def, and Omniifr::Dependency1< T_IRObject >::copy(). 00039 {
00040 return _discriminator_type_def.copy();
00041 }
|
|
|
Definition at line 95 of file UnionDef.cc. References _members, Omniifr::IRObject_impl::checkReadonly(), DB, discriminator_type(), IFELSE_OMNIORB4, type(), and Omniifr::Dependency3< T_xxxDescriptionSeq >::uncheckedAssign(). 00096 {
00097 checkReadonly();
00098 UnionMemberSeq temp(v); // take a copy (v is const).
00099 TypeCode_var discriminatorType =discriminator_type();
00100
00101 // Note: These checks are similar to Dependency3::check(), but more
00102 // extensive.
00103
00104 for(ULong i=0; i<temp.length(); ++i)
00105 {
00106 IdentifierUtil::checkInvalid(temp[i].name);
00107 if(CORBA::is_nil(temp[i].type_def))
00108 throw CORBA::BAD_PARAM(
00109 IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidObjectRef,43),
00110 CORBA::COMPLETED_NO
00111 );
00112
00113 // Set type to match type_def. (Ignore type's current value.)
00114 try
00115 {
00116 temp[i].type=temp[i].type_def->type();
00117 }
00118 catch(...)
00119 {
00120 DB(15,"Caught exception at "<<__FILE__<<":"<<__LINE__)
00121 throw; // If an exception occurs, just propagate it as-is.
00122 }
00123
00124 // The default label (Octet with the value zero) is always allowed.
00125 CORBA::Octet oct;
00126 bool isDefaultLabel=((temp[i].label>>=CORBA::Any::to_octet(oct)) && oct==0);
00127 if(!isDefaultLabel)
00128 {
00129 // Check that label's type matches discriminator_type.
00130 TypeCode_var labelType =temp[i].label.type();
00131 if(!labelType->equivalent(discriminatorType.in()))
00132 throw CORBA::BAD_PARAM(
00133 IFELSE_OMNIORB4(omni::BAD_PARAM_IncompatibleDiscriminatorType,19),
00134 CORBA::COMPLETED_NO
00135 );
00136
00137 // Check that the label is unique.
00138 DynamicAny::DynAny_var dai =
00139 Repository_impl::inst()._DynAnyFactory->create_dyn_any(temp[i].label);
00140 bool uniqueLabel =true;
00141 for(ULong j=0; uniqueLabel && j<i; ++j)
00142 {
00143 DynamicAny::DynAny_var daj =
00144 Repository_impl::inst()._DynAnyFactory->create_dyn_any(temp[j].label);
00145 if(dai->equal(daj))
00146 uniqueLabel=false;
00147 daj->destroy();
00148 }
00149 dai->destroy();
00150 if(!uniqueLabel)
00151 throw CORBA::BAD_PARAM(
00152 IFELSE_OMNIORB4(omni::BAD_PARAM_DuplicateLabelValue,18),
00153 CORBA::COMPLETED_NO
00154 );
00155 }
00156
00157 // Check that name/type is legal.
00158 // name must be unique, UNLESS it AND ITS TYPE are the same as the previous
00159 // member.
00160 bool match =true;
00161 for(Long k=i-1; k>=0; --k)
00162 {
00163 switch(IdentifierUtil::compare(temp[i].name,temp[k].name))
00164 {
00165 case IdentifierUtil::equalMatch:
00166 if(! (match && temp[i].type->equal(temp[k].type)) )
00167 throw CORBA::BAD_PARAM(); // ?? Minor code?
00168 break;
00169
00170 case IdentifierUtil::equivalentMatch:
00171 throw CORBA::BAD_PARAM(
00172 IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidMemberName,17),
00173 CORBA::COMPLETED_NO
00174 );
00175
00176 case IdentifierUtil::noMatch:
00177 match=false;
00178 break;
00179
00180 default:
00181 assert(false); // Never get here.
00182 }; // end switch.
00183 }
00184 }
00185
00186 // Do it.
00187 _members.uncheckedAssign(temp);
00188 }
|
|
|
Definition at line 90 of file UnionDef.cc. References _members, and Omniifr::Dependency3< T_xxxDescriptionSeq >::copy(). 00091 {
00092 return _members.copy();
00093 }
|
|
|
Save this object's state to a stream.
Implements Omniifr::IRObject_impl. Definition at line 230 of file UnionDef.cc. References _discriminator_type_def, _members, Omniifr::Dependency3< T_xxxDescriptionSeq >::in(), Omniifr::Dependency1< T_IRObject >::in(), Omniifr::Container_impl::outputContents(), and Omniifr::Contained_impl::outputSelf(). 00231 {
00232 outputSelf(os,"UnionDef");
00233 PersistNode::outputIOR(os,
00234 _discriminator_type_def.in(),
00235 "\n discriminator_type_def="
00236 );
00237 cdrMemoryStream memstr(CORBA::ULong(0),CORBA::Boolean(1)/*clearMemory*/);
00238 _members.in()>>=memstr;
00239 PersistNode::outputCdrMemoryStream(os,memstr,"\n state=");
00240 os<<" ;;\n";
00241 outputContents(os);
00242 }
|
|
|
Re-create the repository from information saved in the log file.
Reimplemented from Omniifr::IRObject_impl. Definition at line 218 of file UnionDef.cc. References _discriminator_type_def, _members, Omniifr::Dependency1< T_IRObject >::assign(), and Omniifr::Dependency3< T_xxxDescriptionSeq >::uncheckedAssign(). 00219 {
00220 _discriminator_type_def.assign(
00221 string_to_<CORBA::IDLType>(node.attrString("discriminator_type_def").c_str())
00222 );
00223
00224 cdrMemoryStream memstr =node.attrCdrStream("state");
00225 UnionMemberSeq m;
00226 m<<=memstr;
00227 _members.uncheckedAssign(m); // Skip the checks performed by members(m)
00228 }
|
|
|
Implements Omniifr::IDLType_impl. Definition at line 190 of file UnionDef.cc. References _members, discriminator_type(), and Omniifr::Dependency3< T_xxxDescriptionSeq >::in(). Referenced by members(). 00191 {
00192 TypeCode_var tc =discriminator_type();
00193 return Repository_impl::inst()._orb
00194 ->create_union_tc(_id.in(),_name.in(),tc.in(),_members.in());
00195 }
|
|
|
Destroys this object, without first checking for dependencies.
Implements Omniifr::Container_impl. Definition at line 197 of file UnionDef.cc. References _discriminator_type_def, _members, Omniifr::Dependency1< T_IRObject >::clear(), and Omniifr::Dependency3< T_xxxDescriptionSeq >::clear(). 00198 {
00199 _members.clear();
00200 _discriminator_type_def.clear();
00201 Contained_impl::uncheckedDestroy();
00202 Container_impl::uncheckedDestroy();
00203 }
|
|
|
Definition at line 49 of file UnionDef.h. Referenced by discriminator_type(), discriminator_type_def(), output(), reincarnate(), uncheckedDestroy(), and UnionDef_impl(). |
|
|
Definition at line 50 of file UnionDef.h. Referenced by discriminator_type_def(), members(), output(), reincarnate(), type(), uncheckedDestroy(), and UnionDef_impl(). |
1.4.1