Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Omniifr::Container_impl Class Reference

#include <Container.h>

Inheritance diagram for Omniifr::Container_impl:

Inheritance graph
[legend]
Collaboration diagram for Omniifr::Container_impl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Contained_ptr lookup (const char *search_name)
 "The lookup operation locates a definition relative to this container given a scoped name using OMG IDL's name scoping rules.
virtual ContainedSeq * contents (DefinitionKind limit_type, Boolean exclude_inherited)
 This default implementation does not implement inheritance, see subclasses for that.
ContainedSeq * lookup_name (const char *search_name, Long levels_to_search, DefinitionKind limit_type, Boolean exclude_inherited)
 There is no special code to implement inheritance here.
CORBA::Container::DescriptionSeq * describe_contents (DefinitionKind limit_type, Boolean exclude_inherited, Long max_returned_objs)
 "The describe_contents operation combines the contents operation and the describe operation.
ModuleDef_ptr create_module (const char *id, const char *name, const char *version)
ConstantDef_ptr create_constant (const char *id, const char *name, const char *version, IDLType_ptr type, const Any &value)
StructDef_ptr create_struct (const char *id, const char *name, const char *version, const StructMemberSeq &members)
UnionDef_ptr create_union (const char *id, const char *name, const char *version, IDLType_ptr discriminator_type, const UnionMemberSeq &members)
EnumDef_ptr create_enum (const char *id, const char *name, const char *version, const EnumMemberSeq &members)
AliasDef_ptr create_alias (const char *id, const char *name, const char *version, IDLType_ptr original_type)
InterfaceDef_ptr create_interface (const char *id, const char *name, const char *version, const InterfaceDefSeq &base_interfaces)
ExceptionDef_ptr create_exception (const char *id, const char *name, const char *version, const StructMemberSeq &members)
ValueDef_ptr create_value (const char *id, const char *name, const char *version, Boolean is_custom, Boolean is_abstract, ValueDef_ptr base_value, Boolean is_truncatable, const ValueDefSeq &abstract_base_values, const InterfaceDefSeq &supported_interfaces, const InitializerSeq &initializers)
 Not supported.
ValueBoxDef_ptr create_value_box (const char *id, const char *name, const char *version, IDLType_ptr original_type_def)
 Not supported.
NativeDef_ptr create_native (const char *id, const char *name, const char *version)
 Not supported.
AbstractInterfaceDef_ptr create_abstract_interface (const char *id, const char *name, const char *version, const AbstractInterfaceDefSeq &base_interfaces)
 Not supported (deprecated).
 Container_impl ()
virtual ~Container_impl ()
virtual void uncheckedDestroy ()=0
 Destroys this object, without first checking for dependencies.
Contained_impllookupServant (const char *searchName, bool matchCase)
 Works exactly like lookup(), except the caller can choose whether they want case-sensitive or case insensitive searching.
virtual bool canContain (DefinitionKind kind)=0
 Returns TRUE if this Container_impl can contain type 'kind'.
void addContained (Contained_impl *contained)
void removeContained (Contained_impl *contained)

Protected Member Functions

void dependentObjectSet (set< const IRObject_impl * > &result) const
 'result' is set to the set union of 'result's initial value and the set of all objects that depend upon this object (or its children).
void containedObjectSet (set< const IRObject_impl * > &result) const
 'result' is set to the set union of 'result's initial value and the set of all objects contained by this object, plus this object itself.
void recreate (PersistNode *node, map< IRObject_impl *, PersistNode * > &todo)
 Recreate contained objects from a PersistNode.
void outputContents (ostream &os) const
 Helper method, calls output method for each Contained.

Private Attributes

list< Contained_impl * > _contents

Classes

struct  EqualName
 Predicate that tests a Contained->name() for equality with the 'name' parameter. More...

Constructor & Destructor Documentation

Omniifr::Container_impl::Container_impl  ) 
 

Definition at line 444 of file Container.cc.

References _contents.

00444                                : _contents()
00445 {
00446   _contents.clear();
00447 }

virtual Omniifr::Container_impl::~Container_impl  )  [inline, virtual]
 

Definition at line 244 of file Container.h.

00244 {}


Member Function Documentation

void Omniifr::Container_impl::addContained Contained_impl contained  ) 
 

Definition at line 505 of file Container.cc.

References _contents, Omniifr::Contained_impl::_index, canContain(), and IFELSE_OMNIORB4.

Referenced by Omniifr::Contained_impl::init(), and Omniifr::Contained_impl::move().

00506 {
00507   // Precondition: We know that the contained->name is not already in use by
00508   // this container, either because we've checked for that in
00509   // Contained_impl::name() or because we've set it to "" during a
00510   // Contained_impl::move().
00511 
00512   this->_add_ref(); // Do this now to ensure we aren't destroyed during the call
00513   try
00514   {
00515     // Verify that we don't already contain it.
00516     assert(find_if(_contents.begin(),_contents.end(),
00517                    bind2nd(equal_to<Contained_impl*>(),contained))
00518            ==_contents.end()
00519     );
00520     // Check that we are able to contain the specified type.
00521     if(!canContain(contained->def_kind()))
00522         throw CORBA::BAD_PARAM(
00523           IFELSE_OMNIORB4(omni::BAD_PARAM_TargetIsInvalidContainer,4),
00524           CORBA::COMPLETED_NO
00525         );
00526     // proceed...
00527     if(contained->_index > 0)
00528     {
00529       // we are being reincarnated: Put the it back in the right place.
00530       list<Contained_impl*>::iterator pos=_contents.begin();
00531       while(pos!=_contents.end() && (*pos)->_index < contained->_index)
00532           ++pos;
00533       _contents.insert(pos,contained);
00534     }
00535     else
00536     {
00537       // A newly added object - put it at the end.
00538       contained->_index=(_contents.empty()? 1: 1+_contents.back()->_index);
00539       _contents.push_back(contained);
00540     }
00541   }
00542   catch(...)
00543   {
00544     this->_remove_ref();
00545     throw;
00546   }
00547 }

virtual bool Omniifr::Container_impl::canContain DefinitionKind  kind  )  [pure virtual]
 

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".

Implemented in Omniifr::ExceptionDef_impl, Omniifr::InterfaceDef_impl, Omniifr::ModuleDef_impl, Omniifr::Repository_impl, Omniifr::StructDef_impl, and Omniifr::UnionDef_impl.

Referenced by addContained(), and Omniifr::Contained_impl::move().

void Omniifr::Container_impl::containedObjectSet set< const IRObject_impl * > &  result  )  const [protected, virtual]
 

'result' is set to the set union of 'result's initial value and the set of all objects contained by this object, plus this object itself.

Reimplemented from Omniifr::IRObject_impl.

Definition at line 328 of file Container.cc.

References _contents.

00329 {
00330   IRObject_impl::containedObjectSet(result); // parent's implementation.
00331   // now add in contained objects
00332   for(list<Contained_impl*>::const_iterator i=_contents.begin();
00333       i!=_contents.end();
00334       ++i)
00335   {
00336     (**i).containedObjectSet(result);
00337   }
00338 }

ContainedSeq * Omniifr::Container_impl::contents DefinitionKind  limit_type,
Boolean  exclude_inherited
[virtual]
 

This default implementation does not implement inheritance, see subclasses for that.

The operation is used to navigate through the hierarchy of objects. Starting with the Repository object, a client uses this operation to list all of the objects contained by the Repository, all of the objects contained by the modules within the Repository, and then all of the interfaces and value types within a specific module, and so on." -OMG

Parameters:
limit_type "If limit_type is set to dk_all "all," objects of all interface types are returned. For example, if this is an InterfaceDef, the attribute, operation, and exception objects are all returned. If limit_type is set to a specific interface, only objects of that interface type are returned. For example, only attribute objects are returned if limit_type is set to dk_Attribute "AttributeDef"." -OMG
exclude_inherited "If set to TRUE, inherited objects (if there are any) are not returned. If set to FALSE, all contained objects whether contained due to inheritance or because they were defined within the object are returned." -OMG

Definition at line 58 of file Container.cc.

References _contents.

Referenced by describe_contents(), and lookup_name().

00062 {
00063   ContainedSeq_var result = new ContainedSeq();
00064   ULong resultLength =0;
00065 
00066   for(list<Contained_impl*>::iterator it =_contents.begin();
00067       it!=_contents.end();
00068       ++it)
00069   {
00070     if(limit_type==dk_all || limit_type==(*it)->def_kind())
00071     {
00072       result->length(resultLength+1);
00073       result[resultLength]=(*it)->_this();
00074       ++resultLength;
00075     }
00076   }
00077   return result._retn();
00078 }

AbstractInterfaceDef_ptr Omniifr::Container_impl::create_abstract_interface const char *  id,
const char *  name,
const char *  version,
const AbstractInterfaceDefSeq &  base_interfaces
 

Not supported (deprecated).

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 301 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, and version().

00305 {
00306   DB(5,"Container::create_abstract_interface("<<id<<","<<name<<","<<version<<",...)")
00307   checkReadonly();
00308   // not supported
00309   return AbstractInterfaceDef::_nil();
00310 }

AliasDef_ptr Omniifr::Container_impl::create_alias const char *  id,
const char *  name,
const char *  version,
IDLType_ptr  original_type
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 224 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00228 {
00229   DB(5,"Container::create_alias("<<id<<","<<name<<","<<version<<",...)")
00230   checkReadonly();
00231   Creche<AliasDef_impl> newalias(new AliasDef_impl());
00232   newalias->init(id,name,version,this);
00233   newalias->original_type_def(original_type);
00234   return newalias.release()->_this();
00235 }

ConstantDef_ptr Omniifr::Container_impl::create_constant const char *  id,
const char *  name,
const char *  version,
IDLType_ptr  type,
const Any &  value
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 166 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00171 {
00172   DB(5,"Container::create_constant("<<id<<","<<name<<","<<version<<",...)")
00173   checkReadonly();
00174   Creche<ConstantDef_impl> newconstant(new ConstantDef_impl());
00175   newconstant->init(id,name,version,this);
00176   // Order is important.
00177   newconstant->type_def(type);
00178   newconstant->value(value);
00179   return newconstant.release()->_this();
00180 }

EnumDef_ptr Omniifr::Container_impl::create_enum const char *  id,
const char *  name,
const char *  version,
const EnumMemberSeq &  members
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 211 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00215 {
00216   DB(5,"Container::create_enum("<<id<<","<<name<<","<<version<<",...)")
00217   checkReadonly();
00218   Creche<EnumDef_impl> newenum(new EnumDef_impl());
00219   newenum->init(id,name,version,this);
00220   newenum->members(members);
00221   return newenum.release()->_this();
00222 }

ExceptionDef_ptr Omniifr::Container_impl::create_exception const char *  id,
const char *  name,
const char *  version,
const StructMemberSeq &  members
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 250 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00254 {
00255   DB(5,"Container::create_exception("<<id<<","<<name<<","<<version<<",...)")
00256   checkReadonly();
00257   Creche<ExceptionDef_impl> newexception(new ExceptionDef_impl());
00258   newexception->init(id,name,version,this);
00259   newexception->members(members);
00260   return newexception.release()->_this();
00261 }

InterfaceDef_ptr Omniifr::Container_impl::create_interface const char *  id,
const char *  name,
const char *  version,
const InterfaceDefSeq &  base_interfaces
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 237 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00241 {
00242   DB(5,"Container::create_interface("<<id<<","<<name<<","<<version<<",...)")
00243   checkReadonly();
00244   Creche<InterfaceDef_impl> newinterface(new InterfaceDef_impl());
00245   newinterface->init(id,name,version,this);
00246   newinterface->base_interfaces(base_interfaces);
00247   return newinterface.release()->_this();
00248 }

ModuleDef_ptr Omniifr::Container_impl::create_module const char *  id,
const char *  name,
const char *  version
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 155 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00158 {
00159   DB(5,"Container::create_module("<<id<<","<<name<<","<<version<<")")
00160   checkReadonly();
00161   Creche<ModuleDef_impl> newmodule(new ModuleDef_impl());
00162   newmodule->init(id,name,version,this);
00163   return newmodule.release()->_this();
00164 }

NativeDef_ptr Omniifr::Container_impl::create_native const char *  id,
const char *  name,
const char *  version
 

Not supported.

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 291 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, and version().

00294 {
00295   DB(5,"Container::create_native("<<id<<","<<name<<","<<version<<",...)")
00296   checkReadonly();
00297   // not supported
00298   return NativeDef::_nil();
00299 }

StructDef_ptr Omniifr::Container_impl::create_struct const char *  id,
const char *  name,
const char *  version,
const StructMemberSeq &  members
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 182 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00186 {
00187   DB(5,"Container::create_struct("<<id<<","<<name<<","<<version<<",...)")
00188   checkReadonly();
00189   Creche<StructDef_impl> newstruct(new StructDef_impl());
00190   newstruct->init(id,name,version,this);
00191   newstruct->members(members);
00192   return newstruct.release()->_this();
00193 }

UnionDef_ptr Omniifr::Container_impl::create_union const char *  id,
const char *  name,
const char *  version,
IDLType_ptr  discriminator_type,
const UnionMemberSeq &  members
 

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 195 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, Omniifr::Creche< T >::release(), and version().

00200 {
00201   DB(5,"Container::create_union("<<id<<","<<name<<","<<version<<",...)")
00202   checkReadonly();
00203   Creche<UnionDef_impl> newunion(new UnionDef_impl());
00204   newunion->init(id,name,version,this);
00205   // Note, order is important.
00206   newunion->discriminator_type_def(discriminator_type);
00207   newunion->members(members);
00208   return newunion.release()->_this();
00209 }

ValueDef_ptr Omniifr::Container_impl::create_value const char *  id,
const char *  name,
const char *  version,
Boolean  is_custom,
Boolean  is_abstract,
ValueDef_ptr  base_value,
Boolean  is_truncatable,
const ValueDefSeq &  abstract_base_values,
const InterfaceDefSeq &  supported_interfaces,
const InitializerSeq &  initializers
 

Not supported.

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 263 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, and version().

00273 {
00274   DB(5,"Container::create_value("<<id<<","<<name<<","<<version<<",...)")
00275   checkReadonly();
00276   // not supported
00277   return ValueDef::_nil();
00278 }

ValueBoxDef_ptr Omniifr::Container_impl::create_value_box const char *  id,
const char *  name,
const char *  version,
IDLType_ptr  original_type_def
 

Not supported.

Parameters:
id  typedef: RepositoryId
name  typedef: Identifier
version  typedef: VersionSpec

Definition at line 280 of file Container.cc.

References Omniifr::IRObject_impl::checkReadonly(), DB, and version().

00284 {
00285   DB(5,"Container::create_value_box("<<id<<","<<name<<","<<version<<",...)")
00286   checkReadonly();
00287   // not supported
00288   return ValueBoxDef::_nil();    
00289 }

void Omniifr::Container_impl::dependentObjectSet set< const IRObject_impl * > &  result  )  const [protected, virtual]
 

'result' is set to the set union of 'result's initial value and the set of all objects that depend upon this object (or its children).

Reimplemented from Omniifr::IRObject_impl.

Definition at line 316 of file Container.cc.

References _contents.

00317 {
00318   IRObject_impl::dependentObjectSet(result); // parent's implementation.
00319   // now add in contained objects
00320   for(list<Contained_impl*>::const_iterator i=_contents.begin();
00321       i!=_contents.end();
00322       ++i)
00323   {
00324     (**i).dependentObjectSet(result);
00325   }
00326 }

CORBA::Container::DescriptionSeq * Omniifr::Container_impl::describe_contents DefinitionKind  limit_type,
Boolean  exclude_inherited,
Long  max_returned_objs
 

"The describe_contents operation combines the contents operation and the describe operation.

For each object returned by the contents operation, the description of the object is returned (i.e., the object's describe operation is invoked and the results returned)." -OMG

Parameters:
max_returned_objs "Limits the number of objects that can be returned in an invocation of the call to the number provided. Setting the parameter to -1 means return all contained objects." -OMG

Definition at line 129 of file Container.cc.

References contents().

00134 {
00135   ContainedSeq_var containedseq =contents(limit_type,exclude_inherited);
00136 
00137   ULong numObjectsToReturn =containedseq->length();
00138   if(max_returned_objs>=Long(numObjectsToReturn))
00139       numObjectsToReturn=max_returned_objs;     
00140 
00141   CORBA::Container::DescriptionSeq_var result =
00142     new CORBA::Container::DescriptionSeq();
00143   result->length(numObjectsToReturn);
00144 
00145   for(ULong i=0; i<numObjectsToReturn; ++i)
00146   {
00147     CORBA::Contained::Description_var iDescription =containedseq[i]->describe();
00148     result[i].contained_object=containedseq[i];
00149     result[i].kind            =iDescription->kind;
00150     result[i].value           =iDescription->value;
00151   }
00152   return result._retn();
00153 }

Contained_ptr Omniifr::Container_impl::lookup const char *  search_name  ) 
 

"The lookup operation locates a definition relative to this container given a scoped name using OMG IDL's name scoping rules.

An absolute scoped name (beginning with "::") locates the definition relative to the enclosing Repository. If no object is found, a nil object reference is returned." -OMG

Parameters:
search_name  typedef: ScopedName

Definition at line 45 of file Container.cc.

References lookupServant().

00046 {
00047   Contained_impl* result =lookupServant(search_name,true); // Case sensitive
00048   if(result)
00049       return result->_this();
00050   else
00051       return Contained::_nil();
00052 }

ContainedSeq * Omniifr::Container_impl::lookup_name const char *  search_name,
Long  levels_to_search,
DefinitionKind  limit_type,
Boolean  exclude_inherited
 

There is no special code to implement inheritance here.

Use of values of levels_to_search of 0 or of negative numbers other than -1 is undefined." -OMG

Parameters:
search_name Specifies which name is to be searched for.
levels_to_search "Controls whether the lookup is constrained to the object the operation is invoked on or whether it should search through objects contained by the object as well." -OMG
"Setting levels_to_search to -1 searches the current object and all contained objects. Setting levels_to_search to 1 searches only the current object. Use of values of levels_to_search of 0 or of negative numbers other than -1 is undefined." -OMG
Parameters:
search_name  typedef: Identifier

Definition at line 83 of file Container.cc.

References _contents, and contents().

00089 {
00090   ContainedSeq_var result =new ContainedSeq();
00091   ULong resultLength =0;
00092   Long subLevels =levels_to_search<0? levels_to_search : levels_to_search-1;
00093   EqualName equalName(search_name,true); // true -> case sensitive
00094 
00095   // Obtain all contents (even inherited) that match the limit_type.
00096   ContainedSeq_var contents =this->contents(limit_type,exclude_inherited);
00097   for(ULong i=0; i<contents->length(); ++i)
00098   {
00099     if(equalName(contents[i]) && // name match
00100         limit_type==dk_all || limit_type==contents[i]->def_kind()) // type match
00101     {
00102       result->length(resultLength+1);
00103       result[resultLength]=contents[i];
00104       ++resultLength;
00105     }
00106   }
00107 
00108   // Search sub levels, if required.
00109   if(subLevels!=0)
00110   {
00111     for(list<Contained_impl*>::iterator it =_contents.begin();
00112         it!=_contents.end();
00113         ++it)
00114     {
00115       Container_impl* subContainer =dynamic_cast<Container_impl*>(*it);
00116       if(subContainer)
00117       {
00118         ContainedSeq_var subResult =subContainer->
00119           lookup_name(search_name,subLevels,limit_type,exclude_inherited);
00120         result->length( resultLength+subResult->length() );
00121         for(ULong j=0; j<subResult->length(); ++j)
00122             result[resultLength++]=subResult[j]._retn();
00123       }
00124     }
00125   }
00126   return result._retn();
00127 }

Contained_impl * Omniifr::Container_impl::lookupServant const char *  searchName,
bool  matchCase
 

Works exactly like lookup(), except the caller can choose whether they want case-sensitive or case insensitive searching.

The returned value is a servant pointer rather than a CORBA object reference.

Parameters:
searchName  typedef: ScopedName

Definition at line 460 of file Container.cc.

References _contents.

Referenced by lookup(), and Omniifr::Contained_impl::name().

00464 {
00465   assert(searchName);
00466   if(!searchName[0])// Empty string
00467       return NULL;
00468 
00469   // Split into: first::theRest
00470   const char* offset =strstr(searchName,"::");
00471   string first(searchName,offset?offset-searchName:strlen(searchName));
00472   string theRest(offset?offset+2:"");
00473 
00474   Contained_impl* result =NULL;
00475 
00476   if(first.empty())
00477   {
00478     result=Repository_impl::inst().lookupServant(theRest.c_str(),matchCase);
00479   }
00480   else
00481   {
00482     list<Contained_impl*>::iterator pos =
00483       find_if(
00484         _contents.begin(),
00485         _contents.end(),
00486         EqualName(first.c_str(),matchCase)
00487       );
00488     if(pos!=_contents.end()) // match found
00489     {
00490       if(theRest.empty())
00491       {
00492         result=*pos;
00493       }
00494       else
00495       {
00496         Container_impl* container =dynamic_cast<Container_impl*>(*pos);
00497         if(container)
00498             result=container->lookupServant(theRest.c_str(),matchCase);
00499       }
00500     }
00501   }
00502   return result;
00503 }

void Omniifr::Container_impl::outputContents ostream &  os  )  const [protected]
 

Helper method, calls output method for each Contained.

Definition at line 434 of file Container.cc.

References _contents, and Omniifr::ExceptionDef_impl::output().

Referenced by Omniifr::UnionDef_impl::output(), Omniifr::StructDef_impl::output(), Omniifr::Repository_impl::output(), Omniifr::ModuleDef_impl::output(), Omniifr::InterfaceDef_impl::output(), and Omniifr::ExceptionDef_impl::output().

00435 {
00436   for(list<Contained_impl*>::const_iterator i=_contents.begin();
00437       i!=_contents.end();
00438       ++i)
00439   {
00440     (**i).output(os);
00441   }
00442 }

void Omniifr::Container_impl::recreate PersistNode node,
map< IRObject_impl *, PersistNode * > &  todo
[protected]
 

Recreate contained objects from a PersistNode.

Does not recreate links & members - instead the object->node relationship is added to the 'todo' map. This is later used by Repository_impl::reincarnate() to complete the reincarnation process.

Definition at line 340 of file Container.cc.

References DB, Omniifr::Creche< T >::get(), Omniifr::ExceptionDef_impl::output(), and Omniifr::Creche< T >::release().

Referenced by Omniifr::Repository_impl::reincarnate().

00343 {
00344   if(!node)
00345   {
00346     DB(1,"Container_impl::recreate(): NULL child node encountered.")
00347     return;
00348   }
00349 
00350   for(map<string,PersistNode*>::const_iterator i =node->_child.begin();
00351                                                i!=node->_child.end();
00352                                              ++i)
00353   {
00354     const string iOid     =i->second->attrString("oid");
00355     const string iId      =i->second->attrString("id");
00356     const string iVersion =i->second->attrString("version");
00357     const string iClass   =i->second->attrString("class");
00358     const int    iIndex   =i->second->attrLong("index");
00359     if(iOid.empty() || iId.empty() || iVersion.empty() || iClass.empty())
00360     {
00361       DB(1,"Container_impl::recreate(): expected 'Contained' type child node.")
00362       i->second->output(cerr,i->first);
00363       continue;
00364     }
00365     // OK
00366     if("ModuleDef"==iClass)
00367     {
00368       Creche<ModuleDef_impl> servant(new ModuleDef_impl());
00369       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00370       servant->recreate(i->second,todo);
00371       servant.release(iOid.c_str());
00372     }
00373     else if("ConstantDef"==iClass)
00374     {
00375       Creche<ConstantDef_impl> servant(new ConstantDef_impl());
00376       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00377       todo[servant.get()]=i->second;
00378       servant.release(iOid.c_str());
00379     }
00380     else if("StructDef"==iClass)
00381     {
00382       Creche<StructDef_impl> servant(new StructDef_impl());
00383       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00384       servant->recreate(i->second,todo);
00385       todo[servant.get()]=i->second;
00386       servant.release(iOid.c_str());
00387     }
00388     else if("UnionDef"==iClass)
00389     {
00390       Creche<UnionDef_impl> servant(new UnionDef_impl());
00391       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00392       servant->recreate(i->second,todo);
00393       todo[servant.get()]=i->second;
00394       servant.release(iOid.c_str());
00395     }
00396     else if("EnumDef"==iClass)
00397     {
00398       Creche<EnumDef_impl> servant(new EnumDef_impl());
00399       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00400       todo[servant.get()]=i->second;
00401       servant.release(iOid.c_str());
00402     }
00403     else if("AliasDef"==iClass)
00404     {
00405       Creche<AliasDef_impl> servant(new AliasDef_impl());
00406       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00407       todo[servant.get()]=i->second;
00408       servant.release(iOid.c_str());
00409     }
00410     else if("InterfaceDef"==iClass)
00411     {
00412       Creche<InterfaceDef_impl> servant(new InterfaceDef_impl());
00413       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00414       servant->recreate(i->second,todo);
00415       todo[servant.get()]=i->second;
00416       servant.release(iOid.c_str());
00417     }
00418     else if("ExceptionDef"==iClass)
00419     {
00420       Creche<ExceptionDef_impl> servant(new ExceptionDef_impl());
00421       servant->init(iId.c_str(),i->first.c_str(),iVersion.c_str(),this,iIndex);
00422       servant->recreate(i->second,todo);
00423       todo[servant.get()]=i->second;
00424       servant.release(iOid.c_str());
00425     }
00426     else if("AttributeDef"!=iClass && "OperationDef"!=iClass)
00427     {
00428       DB(1,"Container_impl::recreate(): "
00429            "unexpected child class "<<iClass.c_str())
00430     }
00431   } // end for(i)
00432 } // end Container_impl::recreate()

void Omniifr::Container_impl::removeContained Contained_impl contained  ) 
 

Definition at line 549 of file Container.cc.

References _contents.

Referenced by Omniifr::Contained_impl::move(), and Omniifr::Contained_impl::uncheckedDestroy().

00550 {
00551   list<Contained_impl*>::iterator pos =
00552     find_if(_contents.begin(),_contents.end(),
00553             bind2nd(equal_to<Contained_impl*>(),contained));
00554   assert(pos!=_contents.end());
00555   _contents.erase(pos);
00556   this->_remove_ref();
00557 }

void Omniifr::Container_impl::uncheckedDestroy  )  [pure virtual]
 

Destroys this object, without first checking for dependencies.

Implements Omniifr::IRObject_impl.

Implemented in Omniifr::ExceptionDef_impl, Omniifr::InterfaceDef_impl, Omniifr::ModuleDef_impl, Omniifr::Repository_impl, Omniifr::StructDef_impl, and Omniifr::UnionDef_impl.

Definition at line 449 of file Container.cc.

References _contents, and Omniifr::ExceptionDef_impl::uncheckedDestroy().

00450 {
00451   for(list<Contained_impl*>::const_iterator i=_contents.begin();
00452       i!=_contents.end();
00453       ++i)
00454   {
00455     (**i).uncheckedDestroy();
00456   }
00457   _contents.clear();
00458 }


Member Data Documentation

list<Contained_impl*> Omniifr::Container_impl::_contents [private]
 

Definition at line 266 of file Container.h.

Referenced by addContained(), containedObjectSet(), Container_impl(), contents(), dependentObjectSet(), lookup_name(), lookupServant(), outputContents(), removeContained(), and uncheckedDestroy().


The documentation for this class was generated from the following files:
Generated on Fri Mar 4 13:03:58 2005 for OmniIFR by  doxygen 1.4.1