#include <InterfaceDef.h>
Inheritance diagram for Omniifr::InterfaceDef_impl:


Public Member Functions | |
| InterfaceDefSeq * | base_interfaces () |
| void | base_interfaces (const InterfaceDefSeq &v) |
| Boolean | is_a (const char *interface_id) |
| CORBA::InterfaceDef::FullInterfaceDescription * | describe_interface () |
| AttributeDef_ptr | create_attribute (const char *id, const char *name, const char *version, IDLType_ptr type, AttributeMode mode) |
| OperationDef_ptr | create_operation (const char *id, const char *name, const char *version, IDLType_ptr result, OperationMode mode, const ParDescriptionSeq ¶ms, const ExceptionDefSeq &exceptions, const ContextIdSeq &contexts) |
| DefinitionKind | def_kind () |
| ContainedSeq * | contents (DefinitionKind limit_type, Boolean exclude_inherited) |
| CORBA::Contained::Description * | describe () |
| TypeCode_ptr | type () |
| InterfaceDef_impl () | |
| virtual | ~InterfaceDef_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 Types | |
| typedef set< string, NoCaseStringOrdering > | NoCaseStrSet |
Private Member Functions | |
| RepositoryIdSeq | baseInterfacesIds () |
| Obtain a RepositoryIdSeq from _base_interfaces. | |
| void | checkInheritedNameClash (const char *name) |
| Helper method called by create_operation/attribute(). | |
| void | interfaceSet (const InterfaceDefSeq &baseInterfaces, set< string > &repositoryIdSet, InterfaceDefSeq &allBaseInterfaces) |
| Calculate the set of all unique interfaces from which baseInterfaces are derived. | |
| NoCaseStrSet | inheritedNameSet (const InterfaceDefSeq &baseInterfaces) |
| Calculate the set of all attribute & operation names contained by 'baseInterfaces'. | |
Static Private Member Functions | |
| static bool | nameSetOk (const ContainedSeq &contents, NoCaseStrSet &result) |
| Sets 'result' to the set union of 'result's initial value and the set of all contents[x]->name(). | |
Private Attributes | |
| Dependency2< InterfaceDefSeq > | _base_interfaces |
Classes | |
| struct | NoCaseStringOrdering |
| Comparison operator used by NoCaseStrSet. More... | |
|
|
Definition at line 106 of file InterfaceDef.h. |
|
|
Definition at line 80 of file InterfaceDef.h. References _base_interfaces. 00080 :_base_interfaces(this){}
|
|
|
Definition at line 81 of file InterfaceDef.h. 00081 {}
|
|
|
Definition at line 48 of file InterfaceDef.cc. References _base_interfaces, Omniifr::Dependency2< T_IRObjectSeq >::assign(), Omniifr::IRObject_impl::checkReadonly(), contents(), DB, IFELSE_OMNIORB4, inheritedNameSet(), and nameSetOk(). 00049 {
00050 checkReadonly();
00051 // Raise BAD_PARAM if the name of any object contained by this object
00052 // conflicts with the name of any object contained by any of the classes
00053 // in v.
00054
00055 NoCaseStrSet vNameSet =inheritedNameSet(v);
00056
00057 NoCaseStrSet myNameSet;
00058 {
00059 // ASSERT: There should never be a name clash within a container.
00060 ContainedSeq_var myAttributes=contents(dk_Attribute,1);
00061 ContainedSeq_var myOperations=contents(dk_Operation,1);
00062 assert( nameSetOk(myAttributes.in(),myNameSet) );
00063 assert( nameSetOk(myOperations.in(),myNameSet) );
00064 }
00065
00066 NoCaseStrSet conflictSet;
00067 set_intersection(
00068 vNameSet.begin(), vNameSet.end(),
00069 myNameSet.begin(),myNameSet.end(), inserter(conflictSet,conflictSet.end())
00070 );
00071
00072 // conflictSet contains conflicts between this->contents and inherited names.
00073 if(!conflictSet.empty())
00074 {
00075 string badNames="";
00076 for(NoCaseStrSet::const_iterator i=conflictSet.begin();
00077 i!=conflictSet.end();
00078 ++i)
00079 {
00080 badNames+=" \""+(*i)+"\"";
00081 }
00082 DB(1,"BAD_PARAM_InheritedNameClash. InterfaceDef \""<<_name<< \
00083 "\" base_interfaces() rejected duplicate names:"<<badNames.c_str()<<".")
00084 throw CORBA::BAD_PARAM(
00085 IFELSE_OMNIORB4(omni::BAD_PARAM_InheritedNameClash,5),
00086 CORBA::COMPLETED_NO
00087 );
00088 }
00089
00090 // Procede:
00091 _base_interfaces.assign(v); // May raise BAD_PARAM.
00092 }
|
|
|
Definition at line 42 of file InterfaceDef.cc. References _base_interfaces, and Omniifr::Dependency2< T_IRObjectSeq >::copy(). 00043 {
00044 return _base_interfaces.copy();
00045 }
|
|
|
Obtain a RepositoryIdSeq from _base_interfaces.
Definition at line 351 of file InterfaceDef.cc. References _base_interfaces, and Omniifr::Dependency2< T_IRObjectSeq >::in(). Referenced by describe(), and describe_interface(). 00352 {
00353 RepositoryIdSeq result;
00354 try
00355 {
00356 const InterfaceDefSeq& bis =_base_interfaces.in();
00357 result.length(bis.length());
00358 for(ULong i=0; i<bis.length(); ++i)
00359 {
00360 assert(!CORBA::is_nil(bis[i]));
00361 result[i]=bis[i]->id();
00362 }
00363 }
00364 catch(...)
00365 {
00366 result.length(0);
00367 throw;
00368 }
00369 return result;
00370 }
|
|
|
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 275 of file InterfaceDef.cc. References CASE_TYPEDEF. 00276 {
00277 switch(kind)
00278 {
00279 CASE_TYPEDEF
00280 case dk_Constant:
00281 case dk_Exception:
00282 case dk_Operation:
00283 case dk_Attribute:
00284 return true;
00285 default:
00286 return false;
00287 }
00288 }
|
|
|
Helper method called by create_operation/attribute(). Checks that 'name' is a valid identifier, and does not clash with an inherited name. Throws BAD_PARAM if a problem is found. Definition at line 373 of file InterfaceDef.cc. References _base_interfaces, DB, IFELSE_OMNIORB4, Omniifr::Dependency2< T_IRObjectSeq >::in(), and inheritedNameSet(). Referenced by create_attribute(), and create_operation(). 00374 {
00375 IdentifierUtil::checkInvalid(name);
00376
00377 NoCaseStrSet nameSet =inheritedNameSet(_base_interfaces.in());
00378
00379 if(nameSet.find(string(name))!=nameSet.end())
00380 {
00381 DB(1,"BAD_PARAM_InheritedNameClash. InterfaceDef \""<<_name.in()<< \
00382 "\" rejected duplicate name: \""<<name<<"\"")
00383 throw CORBA::BAD_PARAM(
00384 IFELSE_OMNIORB4(omni::BAD_PARAM_InheritedNameClash,5),
00385 CORBA::COMPLETED_NO
00386 );
00387 }
00388 }
|
|
||||||||||||
|
Definition at line 201 of file InterfaceDef.cc. References _base_interfaces, and Omniifr::Dependency2< T_IRObjectSeq >::in(). Referenced by base_interfaces(), describe_interface(), and nameSetOk(). 00205 {
00206 ContainedSeq_var result =Container_impl::contents(limit_type,1);
00207
00208 // Add in inherited attributes & operations, if required.
00209 if( (!exclude_inherited) &&
00210 (limit_type==dk_all ||
00211 limit_type==dk_Operation ||
00212 limit_type==dk_Attribute))
00213 {
00214 const InterfaceDefSeq& bis=_base_interfaces.in();
00215 for(ULong i=0; i<bis.length(); ++i)
00216 {
00217 // result += inherited operations.
00218 if( limit_type==dk_all || limit_type==dk_Operation )
00219 {
00220 ContainedSeq_var opers =bis[i]->contents(dk_Operation,0);
00221 ULong offset=result->length();
00222 result->length( offset+opers->length() );
00223 for(ULong j=0; j<opers->length(); ++j)
00224 result[offset+j]=opers[j]._retn();
00225 }
00226 // result += inherited attributes.
00227 if( limit_type==dk_all || limit_type==dk_Operation )
00228 {
00229 ContainedSeq_var attrs =bis[i]->contents(dk_Attribute,0);
00230 ULong offset=result->length();
00231 result->length( offset+attrs->length() );
00232 for(ULong k=0; k<attrs->length(); ++k)
00233 result[offset+k]=attrs[k]._retn();
00234 }
00235 }
00236 }
00237
00238 return result._retn();
00239 }
|
|
||||||||||||||||||||||||
|
Definition at line 153 of file InterfaceDef.cc. References checkInheritedNameClash(), Omniifr::IRObject_impl::checkReadonly(), DB, and Omniifr::Creche< T >::release(). 00160 {
00161 DB(5,"InterfaceDef::create_attribute("<<id<<","<<name<<","<<version<<",...)")
00162 checkReadonly();
00163 checkInheritedNameClash(name);
00164
00165 // Create the attribute.
00166 Creche<AttributeDef_impl> newattribute(new AttributeDef_impl());
00167 newattribute->init(id,name,version,this);
00168 newattribute->mode(mode);
00169 newattribute->type_def(type);
00170 return newattribute.release()->_this();
00171 }
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 174 of file InterfaceDef.cc. References checkInheritedNameClash(), Omniifr::IRObject_impl::checkReadonly(), DB, and Omniifr::Creche< T >::release(). 00184 {
00185 DB(5,"InterfaceDef::create_operation("<<id<<","<<name<<","<<version<<",...)")
00186 checkReadonly();
00187 checkInheritedNameClash(name);
00188
00189 // Create the operation.
00190 Creche<OperationDef_impl> newoperation(new OperationDef_impl());
00191 newoperation->init(id,name,version,this);
00192 newoperation->mode(mode);
00193 newoperation->contexts(contexts);
00194 newoperation->result_def(result);
00195 newoperation->params(params);
00196 newoperation->exceptions(exceptions);
00197 return newoperation.release()->_this();
00198 }
|
|
|
Implements Omniifr::IRObject_impl. Definition at line 68 of file InterfaceDef.h. Referenced by describe(). 00068 {return CORBA::dk_Interface;}
|
|
|
Implements Omniifr::Contained_impl. Definition at line 242 of file InterfaceDef.cc. References baseInterfacesIds(), def_kind(), Omniifr::Contained_impl::definedInId(), Omniifr::Contained_impl::id(), Omniifr::Contained_impl::name(), and Omniifr::Contained_impl::version(). 00243 {
00244 InterfaceDescription_var interfacedesc = new InterfaceDescription();
00245 interfacedesc->name =name();
00246 interfacedesc->id =id();
00247 interfacedesc->version =version();
00248 interfacedesc->base_interfaces=baseInterfacesIds();
00249 interfacedesc->defined_in =definedInId();
00250
00251 CORBA::Contained::Description_var description =
00252 new CORBA::Contained::Description();
00253 description->kind = def_kind();
00254 description->value <<= interfacedesc._retn();
00255
00256 return description._retn();
00257 }
|
|
|
Definition at line 117 of file InterfaceDef.cc. References baseInterfacesIds(), contents(), Omniifr::Contained_impl::definedInId(), Omniifr::Contained_impl::id(), Omniifr::Contained_impl::name(), type(), and Omniifr::Contained_impl::version(). 00118 {
00119 CORBA::InterfaceDef::FullInterfaceDescription_var result =
00120 new CORBA::InterfaceDef::FullInterfaceDescription();
00121 result->name =name();
00122 result->id =id();
00123 result->defined_in =definedInId();
00124 result->version =version();
00125
00126 ContainedSeq_var containedseq =contents(dk_Operation,false);
00127 result->operations.length(containedseq->length());
00128 for(ULong i=0; i < containedseq->length(); i++ )
00129 {
00130 CORBA::Contained::Description_var description=containedseq[i]->describe();
00131 const OperationDescription* operation;
00132 description->value >>= operation; // Any still owns memory
00133 result->operations[i] = *operation; // deep copy
00134 }
00135
00136 containedseq=contents(dk_Attribute,false);
00137 result->attributes.length(containedseq->length());
00138 for(ULong j=0; j<containedseq->length(); j++)
00139 {
00140 CORBA::Contained::Description_var description=containedseq[j]->describe();
00141 const AttributeDescription* attribute;
00142 description->value >>= attribute; // Any still owns memory
00143 result->attributes[j] = *attribute; // deep copy
00144 }
00145
00146 result->base_interfaces =baseInterfacesIds();
00147 result->type =type();
00148
00149 return result._retn();
00150 }
|
|
|
Calculate the set of all attribute & operation names contained by 'baseInterfaces'. Throws BAD_PARAM(InheritedNameClash) if a duplicate is found. Definition at line 417 of file InterfaceDef.cc. References DB, IFELSE_OMNIORB4, interfaceSet(), and nameSetOk(). Referenced by base_interfaces(), and checkInheritedNameClash(). 00420 {
00421 // Find all base interfaces, including indirectly inherited ones.
00422 set<string> ridSet;
00423 InterfaceDefSeq allBaseInterfaces;
00424 interfaceSet(baseInterfaces,ridSet,allBaseInterfaces);
00425
00426 NoCaseStrSet result;
00427 for(ULong i=0; i<allBaseInterfaces.length(); ++i)
00428 {
00429 // ?? Catch COMMS / TRANSIENT errors here? Translate into BAD_PARAM?
00430 bool ok =true;
00431 ContainedSeq_var iAttrs =allBaseInterfaces[i]->contents(dk_Attribute,1);
00432 ContainedSeq_var iOpers =allBaseInterfaces[i]->contents(dk_Operation,1);
00433 ok=ok&&( nameSetOk(iAttrs.in(),result) );
00434 ok=ok&&( nameSetOk(iOpers.in(),result) );
00435 if(!ok) // Conflict amongst base interfaces
00436 {
00437 string baseIntNames ="";
00438 for(set<string>::const_iterator j=ridSet.begin(); j!=ridSet.end(); ++j)
00439 {
00440 baseIntNames+=" \""+(*j)+"\"";
00441 }
00442 DB(1,"BAD_PARAM_InheritedNameClash. InterfaceDef \""<<_name.in()<< \
00443 "\" detected conflict amongst base interfaces:"<<baseIntNames.c_str()<<".")
00444 throw CORBA::BAD_PARAM(
00445 IFELSE_OMNIORB4(omni::BAD_PARAM_InheritedNameClash,5),
00446 CORBA::COMPLETED_NO
00447 );
00448 }
00449 }
00450 return result;
00451 }
|
|
||||||||||||||||
|
Calculate the set of all unique interfaces from which baseInterfaces are derived.
Definition at line 391 of file InterfaceDef.cc. Referenced by inheritedNameSet(). 00396 {
00397 for(ULong i=0; i<baseInterfaces.length(); ++i)
00398 {
00399 String_var iName =baseInterfaces[i]->name();
00400 if(repositoryIdSet.find(string(iName.in()))==repositoryIdSet.end())
00401 {
00402 // This approach is inefficient when the sequence length might be large,
00403 // but for this case, it's OK.
00404 ULong len =repositoryIdSet.size();
00405 allBaseInterfaces.length(1+len);
00406 allBaseInterfaces[len]=CORBA::InterfaceDef::_duplicate(baseInterfaces[i]);
00407 repositoryIdSet.insert(string(iName.in()));
00408 // Now add in more distant ancestors.
00409 InterfaceDefSeq_var ancestors =baseInterfaces[i]->base_interfaces();
00410 interfaceSet(ancestors.in(),repositoryIdSet,allBaseInterfaces);
00411 }
00412 }
00413 }
|
|
|
Definition at line 95 of file InterfaceDef.cc. References _base_interfaces, and Omniifr::Dependency2< T_IRObjectSeq >::in(). 00096 {
00097 assert(interface_id);
00098
00099 if(strcmp(interface_id,"IDL:omg.org/CORBA/Object:1.0")==0)
00100 return true;
00101
00102 if(strcmp(interface_id,_id.in())==0) // itself
00103 return true;
00104
00105 const InterfaceDefSeq& bis =_base_interfaces.in();
00106 for(ULong i=0; i<bis.length(); i++)
00107 {
00108 assert(!CORBA::is_nil(bis[i]));
00109 if(bis[i]->is_a(interface_id))
00110 return true;
00111 }
00112 return false;
00113 }
|
|
||||||||||||
|
Sets 'result' to the set union of 'result's initial value and the set of all contents[x]->name(). Returns FALSE if a duplicate is found. Definition at line 454 of file InterfaceDef.cc. References contents(), and DB. Referenced by base_interfaces(), and inheritedNameSet(). 00458 {
00459 bool ok =true;
00460 for(ULong i=0; i<contents.length(); ++i)
00461 {
00462 CORBA::String_var iName =contents[i]->name();
00463 if(!result.insert(iName.in()).second)
00464 {
00465 DB(5,"Name clash: \""<<iName.in()<<"\"")
00466 ok=false; // Name clash detected.
00467 }
00468 }
00469 return ok;
00470 }
|
|
|
Save this object's state to a stream.
Implements Omniifr::IRObject_impl. Definition at line 340 of file InterfaceDef.cc. References _base_interfaces, Omniifr::Dependency2< T_IRObjectSeq >::in(), Omniifr::Container_impl::outputContents(), and Omniifr::Contained_impl::outputSelf(). 00341 {
00342 outputSelf(os,"InterfaceDef");
00343 cdrMemoryStream memstr(CORBA::ULong(0),CORBA::Boolean(1)/*clearMemory*/);
00344 _base_interfaces.in()>>=memstr;
00345 PersistNode::outputCdrMemoryStream(os,memstr,"\n state=");
00346 os<<" ;;\n";
00347 outputContents(os);
00348 }
|
|
|
Re-create the repository from information saved in the log file.
Reimplemented from Omniifr::IRObject_impl. Definition at line 291 of file InterfaceDef.cc. References _base_interfaces, Omniifr::Dependency2< T_IRObjectSeq >::assign(), DB, and Omniifr::Creche< T >::release(). 00292 {
00293 // Reincarnate ths object.
00294 cdrMemoryStream memstr =node.attrCdrStream("state");
00295 InterfaceDefSeq b;
00296 b<<=memstr;
00297 _base_interfaces.assign(b);
00298
00299 // Reincarnate contained objects.
00300 // Compare the implementation of Container_impl::recreate()
00301 // Note that there is no need to defer complete reincarnation of these
00302 // contained object, because they can never be the object of a link from
00303 // elsewhere in the hierarchy. (Operations and Attributes can never be
00304 // referred to by another part of the IDL.)
00305 for(map<string,PersistNode*>::const_iterator i =node._child.begin();
00306 i!=node._child.end();
00307 ++i)
00308 {
00309 const string iOid =i->second->attrString("oid");
00310 const string iId =i->second->attrString("id");
00311 const string iVersion =i->second->attrString("version");
00312 const string iClass =i->second->attrString("class");
00313 const int iIndex =i->second->attrLong("index");
00314 if(iOid.empty() || iId.empty() || iVersion.empty() || iClass.empty())
00315 {
00316 DB(1,"InterfaceDef_impl::reincarnate(): "
00317 "expected 'Contained' type child node.")
00318 i->second->output(cerr,i->first);
00319 continue;
00320 }
00321 // OK
00322 if("AttributeDef"==iClass)
00323 {
00324 Creche<AttributeDef_impl> servant(new AttributeDef_impl());
00325 servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00326 servant->reincarnate(*i->second);
00327 servant.release(iOid.c_str());
00328 }
00329 else if("OperationDef"==iClass)
00330 {
00331 Creche<OperationDef_impl> servant(new OperationDef_impl());
00332 servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00333 servant->reincarnate(*i->second);
00334 servant.release(iOid.c_str());
00335 }
00336 } // end for(i)
00337 } // end InterfaceDef_impl::reincarnate()
|
|
|
Implements Omniifr::IDLType_impl. Definition at line 260 of file InterfaceDef.cc. Referenced by describe_interface(). 00261 {
00262 return Repository_impl::inst()._orb
00263 ->create_interface_tc(_id.in(),_name.in());
00264 }
|
|
|
Destroys this object, without first checking for dependencies.
Implements Omniifr::Contained_impl. Definition at line 267 of file InterfaceDef.cc. References _base_interfaces, and Omniifr::Dependency2< T_IRObjectSeq >::clear(). 00268 {
00269 _base_interfaces.clear();
00270 Contained_impl::uncheckedDestroy(); // superclass
00271 Container_impl::uncheckedDestroy(); // superclass
00272 }
|
|
|
Definition at line 77 of file InterfaceDef.h. Referenced by base_interfaces(), baseInterfacesIds(), checkInheritedNameClash(), contents(), InterfaceDef_impl(), is_a(), output(), reincarnate(), and uncheckedDestroy(). |
1.4.1