#include <Contained.h>
Inheritance diagram for Omniifr::Contained_impl:
Public Member Functions | |
char * | id () |
void | id (const char *) |
char * | name () |
void | name (const char *) |
char * | version () |
void | version (const char *) |
Container_ptr | defined_in () |
char * | absolute_name () |
Repository_ptr | containing_repository () |
virtual CORBA::Contained::Description * | describe ()=0 |
void | move (Container_ptr, const char *, const char *) |
Contained_impl () | |
void | init (const char *id, const char *name, const char *version, Container_impl *defined_in, int index=0) |
Initialize the container immediately after construction. | |
virtual | ~Contained_impl () |
virtual void | uncheckedDestroy ()=0 |
Destroys this object, without first checking for dependencies. | |
Public Attributes | |
int | _index |
Documents the ordering of Contained objects within their Container. | |
Protected Member Functions | |
char * | definedInId () |
Helper method. | |
void | outputSelf (ostream &os, const char *className) |
Helper method. | |
Protected Attributes | |
RepositoryId_var | _id |
Identifier_var | _name |
VersionSpec_var | _version |
Private Member Functions | |
void | updateAbsoluteName () |
Sets the value of _absolute_name from _name. | |
Private Attributes | |
Container_impl * | _defined_in |
ScopedName_var | _absolute_name |
|
Definition at line 57 of file Contained.h. 00057 {}
|
|
Definition at line 74 of file Contained.h. 00074 {}
|
|
Definition at line 194 of file Contained.cc. References _absolute_name. Referenced by updateAbsoluteName(). 00195 {
00196 return CORBA::string_dup(_absolute_name);
00197 }
|
|
Definition at line 217 of file Contained.cc. 00218 {
00219 return Repository_impl::inst()._this();
00220 }
|
|
Definition at line 188 of file Contained.cc. References _defined_in. Referenced by init(). 00189 { 00190 assert(_defined_in); 00191 return _defined_in->_this(); 00192 }
|
|
Helper method. Returns this->defined_in()->id(), or an empty string. Definition at line 310 of file Contained.cc. References _defined_in, and id(). Referenced by Omniifr::TypedefDef_impl::describe(), Omniifr::OperationDef_impl::describe(), Omniifr::ModuleDef_impl::describe(), Omniifr::InterfaceDef_impl::describe(), Omniifr::ExceptionDef_impl::describe(), Omniifr::ConstantDef_impl::describe(), Omniifr::AttributeDef_impl::describe(), and Omniifr::InterfaceDef_impl::describe_interface(). 00311 { 00312 Contained_impl* contained =dynamic_cast<Contained_impl*>(_defined_in); 00313 if(contained) 00314 return contained->id(); 00315 else 00316 return string_dup(""); 00317 }
|
|
|
Definition at line 106 of file Contained.cc. References _id, Omniifr::IRObject_impl::checkReadonly(), and IFELSE_OMNIORB4. 00107 { 00108 checkReadonly(); 00109 assert(v); 00110 00111 if(!v[0]) // empty string? invalid RID! 00112 throw CORBA::BAD_PARAM( 00113 IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidRepositoryId,16), 00114 CORBA::COMPLETED_NO 00115 ); 00116 if(_id.in() && 0==strcmp(_id,v)) // Unchanged? do nothing! 00117 return; 00118 if(Repository_impl::inst().findId(v)) // RID already in use. 00119 throw CORBA::BAD_PARAM( 00120 IFELSE_OMNIORB4(omni::BAD_PARAM_RIDAlreadyDefinedInIfR,2), 00121 CORBA::COMPLETED_NO 00122 ); 00123 00124 // Do it. 00125 if(_id.in()) 00126 Repository_impl::inst().removeId(_id.in()); 00127 _id=v; // Change the id 00128 Repository_impl::inst().addId(v,this); 00129 }
|
|
Definition at line 101 of file Contained.cc. References _id. Referenced by definedInId(), Omniifr::TypedefDef_impl::describe(), Omniifr::OperationDef_impl::describe(), Omniifr::ModuleDef_impl::describe(), Omniifr::InterfaceDef_impl::describe(), Omniifr::ExceptionDef_impl::describe(), Omniifr::ConstantDef_impl::describe(), Omniifr::AttributeDef_impl::describe(), Omniifr::InterfaceDef_impl::describe_interface(), and init(). 00102 {
00103 return CORBA::string_dup(_id);
00104 }
|
|
Initialize the container immediately after construction. This method must be called immediately after construction or member variables will not be set and fundamental assumptions about data validity will be violated. So, why not do this in the constructor? Well, some of the code relies upon virtual methods that cannot be relied upon during base class construction.
Definition at line 34 of file Contained.cc. References _defined_in, _id, _index, _version, Omniifr::Container_impl::addContained(), DB, defined_in(), id(), name(), and version(). 00041 { 00042 _index=index; 00043 _version=version; 00044 _defined_in=defined_in; 00045 00046 assert(id); 00047 assert(name); 00048 assert(version); 00049 assert(defined_in); 00050 // containing_repository //?? why isn't this a member of this class? 00051 00052 DB(5,"Contained_impl::init("<<id<<","<<name<<","<<version<<")") 00053 00054 // Note: The order of the following three actions is important. Each may 00055 // throw BAD_PARAM, in which case the changes made so far must be backed out. 00056 00057 int where =0; // Only for error reporting (see catch) 00058 try 00059 { 00060 00061 // name() requires _defined_in to be set. Has no side-effects. 00062 this->name(name); 00063 ++where; 00064 00065 // External-effect: adds id into the Repository. 00066 this->id(id); 00067 ++where; 00068 00069 // External-effects: 00070 // - adds 'this' to container's list; 00071 // - calls _defined_in->_add_ref() 00072 // BUT only if the call completes succcessfully. 00073 _defined_in->addContained(this); 00074 00075 } 00076 catch(CORBA::BAD_PARAM&) // Name already in use (or bad name) 00077 { 00078 switch(where) 00079 { 00080 case 0: 00081 DB(5,"Contained_impl::init() - failed to define name as "<<name) 00082 break; 00083 case 1: 00084 DB(5,"Contained_impl::init() - failed to define id as "<<id) 00085 break; 00086 case 2: 00087 DB(5,"Contained_impl::init() - failed to add to container.") 00088 // Remove the RID from the Repository. 00089 Repository_impl::inst().removeId(_id.in()); 00090 break; 00091 default: assert(0); 00092 } 00093 00094 // "_defined_in->addContained(this)" never succeeded, so we are 00095 // not defined anywhere --> uncheckedDestroy won't try to undefine us. 00096 _defined_in=NULL; 00097 throw; 00098 } 00099 }
|
|
Definition at line 222 of file Contained.cc. References Omniifr::IRObject_impl::_default_POA(), _defined_in, _index, _name, Omniifr::Container_impl::addContained(), Omniifr::Container_impl::canContain(), Omniifr::IRObject_impl::checkReadonly(), DB, IFELSE_OMNIORB4, name(), Omniifr::Container_impl::removeContained(), and version(). 00227 { 00228 assert(new_name); 00229 assert(new_version); 00230 DB(5,"Contained_impl::move("<<new_name<<":"<<new_version<<")") 00231 checkReadonly(); 00232 00233 if(CORBA::is_nil(new_container)) 00234 throw CORBA::BAD_PARAM( 00235 IFELSE_OMNIORB4(omni::BAD_PARAM_TargetIsInvalidContainer,4), 00236 CORBA::COMPLETED_NO 00237 ); 00238 00239 PortableServer::Servant servant =NULL; 00240 try 00241 { 00242 PortableServer::POA_var poa=_default_POA(); 00243 servant=poa->reference_to_servant(new_container); 00244 } 00245 catch(PortableServer::POA::ObjectNotActive&){servant=NULL;} 00246 catch(PortableServer::POA::WrongAdapter&){servant=NULL;} 00247 catch(PortableServer::POA::WrongPolicy&) 00248 { 00249 cerr<<"Can't move contained object.\n" 00250 "POA has wrong policy for reference_to_servant()."<<endl; 00251 exit(1); // Programming error - so quit. 00252 } 00253 Container_impl* newContainer =dynamic_cast<Container_impl*>(servant); 00254 00255 // the containers must be in the same repository 00256 // If newContainer is NULL, then we didn't find it in our repository's POA. 00257 if(!newContainer || !newContainer->canContain(this->def_kind())) 00258 throw CORBA::BAD_PARAM( 00259 IFELSE_OMNIORB4(omni::BAD_PARAM_TargetIsInvalidContainer,4), 00260 CORBA::COMPLETED_NO 00261 ); 00262 00263 // Have we been asked to move the object to the container it started in? 00264 if(newContainer==_defined_in) 00265 { 00266 // Just change the name and version. 00267 name(new_name); // May throw exception if new_name is already in use. 00268 version(new_version); 00269 } 00270 else 00271 { 00272 // Move to the new container. 00273 Container_impl* oldContainer = _defined_in; 00274 Identifier_var oldName = _name.in(); 00275 int oldIndex = _index; 00276 _defined_in=newContainer; 00277 _name=""; // Clear, as this object current has no name in newContainer. 00278 DB(5,"Contained_impl::move(): MOVE "<<oldName.in()<<"->"<<new_name<<")") 00279 try 00280 { 00281 name(new_name); // Throws BAD_PARAM if new_name is already in use. 00282 newContainer->addContained(this); // May throw BAD_PARAM 00283 } 00284 catch(CORBA::BAD_PARAM&) 00285 { 00286 // Restore _defined_in & _name. 00287 _defined_in=oldContainer; 00288 _name=oldName; 00289 _index=oldIndex; 00290 throw; 00291 } 00292 version(new_version); // never throws 00293 oldContainer->removeContained(this); 00294 } 00295 }
|
|
Definition at line 136 of file Contained.cc. References _defined_in, _name, Omniifr::IRObject_impl::checkReadonly(), IFELSE_OMNIORB4, Omniifr::Container_impl::lookupServant(), and updateAbsoluteName(). 00137 { 00138 checkReadonly(); 00139 assert(v); 00140 assert(_defined_in); 00141 00142 IdentifierUtil::checkInvalid(v); 00143 switch(IdentifierUtil::compare(_name.in(),v)) 00144 { 00145 case IdentifierUtil::equalMatch: 00146 break; // Unchanged -> do nothing! 00147 00148 case IdentifierUtil::equivalentMatch: 00149 { 00150 _name=v; // Equivalent name -> just change it! 00151 updateAbsoluteName(); 00152 } 00153 break; 00154 00155 case IdentifierUtil::noMatch: 00156 { 00157 // Check that the new name is not already in use (case INsensitive) 00158 Contained_impl* match =_defined_in->lookupServant(v,false); 00159 if(match) // Name already in use. 00160 throw CORBA::BAD_PARAM( 00161 IFELSE_OMNIORB4(omni::BAD_PARAM_ValueFactoryFailure,1), 00162 CORBA::COMPLETED_NO 00163 ); 00164 // Do it 00165 _name=v; 00166 updateAbsoluteName(); 00167 } 00168 break; 00169 00170 default: 00171 assert(false); // Never get here. 00172 }; // end switch. 00173 }
|
|
Definition at line 131 of file Contained.cc. References _name. Referenced by Omniifr::TypedefDef_impl::describe(), Omniifr::OperationDef_impl::describe(), Omniifr::ModuleDef_impl::describe(), Omniifr::InterfaceDef_impl::describe(), Omniifr::ExceptionDef_impl::describe(), Omniifr::ConstantDef_impl::describe(), Omniifr::AttributeDef_impl::describe(), Omniifr::InterfaceDef_impl::describe_interface(), Omniifr::Repository_impl::get_canonical_typecode(), init(), and move(). 00132 {
00133 return CORBA::string_dup(_name);
00134 }
|
|
Helper method. Sends a persistency file header, and common 'Contained' attributes to the output stream: Format: NAME<absolute_name> oid=<oid> id=<id> version=<version> class=<classname> Definition at line 97 of file Contained.h. References _absolute_name, _id, _index, _version, and Omniifr::IRObject_impl::outputOid(). Referenced by Omniifr::UnionDef_impl::output(), Omniifr::StructDef_impl::output(), Omniifr::OperationDef_impl::output(), Omniifr::ModuleDef_impl::output(), Omniifr::InterfaceDef_impl::output(), Omniifr::ExceptionDef_impl::output(), Omniifr::EnumDef_impl::output(), Omniifr::ConstantDef_impl::output(), Omniifr::AttributeDef_impl::output(), and Omniifr::AliasDef_impl::output(). 00098 { 00099 os<<"NAME"<<_absolute_name.in()<<" oid="; 00100 outputOid(os); 00101 os<<"\n id="<<_id.in()<< 00102 "\n version="<<_version.in()<< 00103 "\n class="<<className<< 00104 "\n index="<<_index; 00105 }
|
|
Destroys this object, without first checking for dependencies.
Implements Omniifr::IRObject_impl. Implemented in Omniifr::AliasDef_impl, Omniifr::AttributeDef_impl, Omniifr::ConstantDef_impl, Omniifr::EnumDef_impl, Omniifr::ExceptionDef_impl, Omniifr::InterfaceDef_impl, Omniifr::ModuleDef_impl, Omniifr::OperationDef_impl, Omniifr::StructDef_impl, and Omniifr::UnionDef_impl. Definition at line 297 of file Contained.cc. References _defined_in, _id, and Omniifr::Container_impl::removeContained(). 00298 { 00299 if(_defined_in) 00300 { 00301 _defined_in->removeContained(this); 00302 _defined_in=NULL; 00303 } 00304 if(_id.in()) 00305 { 00306 Repository_impl::inst().removeId(_id.in()); 00307 } 00308 }
|
|
Sets the value of _absolute_name from _name.
Definition at line 199 of file Contained.cc. References _absolute_name, _defined_in, _name, and absolute_name(). Referenced by name(). 00200 { 00201 assert(_name.in()); 00202 assert(_name.in()[0]); 00203 00204 string parent=""; 00205 00206 Contained_impl* contained=dynamic_cast<Contained_impl*>(_defined_in); 00207 if(contained) 00208 { 00209 CORBA::String_var containerName =contained->absolute_name(); 00210 parent=containerName.in(); 00211 } 00212 _absolute_name=(parent+"::"+_name.in()).c_str(); 00213 // ?? If this object is a Container, we should also call updateAbsoluteName() 00214 // ?? of any contained object. 00215 }
|
|
Definition at line 180 of file Contained.cc. References _version, and Omniifr::IRObject_impl::checkReadonly(). 00181 { 00182 checkReadonly(); 00183 // Empty strings ARE allowed. 00184 assert(v); 00185 _version=v; 00186 }
|
|
Definition at line 175 of file Contained.cc. References _version. Referenced by Omniifr::TypedefDef_impl::describe(), Omniifr::OperationDef_impl::describe(), Omniifr::ModuleDef_impl::describe(), Omniifr::InterfaceDef_impl::describe(), Omniifr::ExceptionDef_impl::describe(), Omniifr::ConstantDef_impl::describe(), Omniifr::AttributeDef_impl::describe(), Omniifr::InterfaceDef_impl::describe_interface(), init(), and move(). 00176 {
00177 return CORBA::string_dup(_version);
00178 }
|
|
Definition at line 109 of file Contained.h. Referenced by absolute_name(), outputSelf(), and updateAbsoluteName(). |
|
Definition at line 108 of file Contained.h. Referenced by defined_in(), definedInId(), init(), move(), name(), uncheckedDestroy(), and updateAbsoluteName(). |
|
Definition at line 81 of file Contained.h. Referenced by id(), init(), outputSelf(), and uncheckedDestroy(). |
|
Documents the ordering of Contained objects within their Container. Zero means not yet ordered. Definition at line 79 of file Contained.h. Referenced by Omniifr::Container_impl::addContained(), init(), move(), and outputSelf(). |
|
Definition at line 82 of file Contained.h. Referenced by move(), name(), and updateAbsoluteName(). |
|
Definition at line 83 of file Contained.h. Referenced by init(), outputSelf(), and version(). |