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

Container.h

Go to the documentation of this file.
00001 //                            Package   : omniIFR
00002 //  Container.h               Created   : 2004/02/22
00003 //                            Author    : Alex Tingle
00004 //
00005 //    Copyright (C) 2004 Alex Tingle.
00006 //
00007 //    This file is part of the omniIFR application.
00008 //
00009 //    omniIFR is free software; you can redistribute it and/or
00010 //    modify it under the terms of the GNU Lesser General Public
00011 //    License as published by the Free Software Foundation; either
00012 //    version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //    omniIFR is distributed in the hope that it will be useful,
00015 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //    Lesser General Public License for more details.
00018 //
00019 //    You should have received a copy of the GNU Lesser General Public
00020 //    License along with this library; if not, write to the Free Software
00021 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 #ifndef OMNIIFR__CONTAINER_H
00024 #define OMNIIFR__CONTAINER_H
00025 
00026 #include "IRObject.h"
00027 
00028 #include <list>
00029 #include <map>
00030 #include <string.h>
00031 
00032 using namespace CORBA;
00033 
00034 namespace Omniifr {
00035 
00036 class Contained_impl;
00037 class PersistNode;
00038 
00039 class Container_impl:
00040   public virtual POA_CORBA::Container,
00041   public virtual IRObject_impl
00042 {
00043 public: // CORBA interface methods
00044 
00045   // methods that read
00046 
00053   Contained_ptr lookup(
00054     const char*    search_name 
00055   );
00056 
00079   virtual ContainedSeq* contents(
00080     DefinitionKind limit_type,
00081     Boolean        exclude_inherited
00082   );
00083 
00101   ContainedSeq* lookup_name(
00102     const char*    search_name, 
00103     Long           levels_to_search,
00104     DefinitionKind limit_type,
00105     Boolean        exclude_inherited
00106   );
00107 
00118   CORBA::Container::DescriptionSeq* describe_contents(
00119     DefinitionKind limit_type,
00120     Boolean        exclude_inherited,
00121     Long           max_returned_objs
00122   );
00123 
00124   // methods that write
00125   ModuleDef_ptr create_module(
00126     const char* id,      
00127     const char* name,    
00128     const char* version  
00129   );
00130 
00131   ConstantDef_ptr create_constant(
00132     const char* id,      
00133     const char* name,    
00134     const char* version, 
00135     IDLType_ptr type,
00136     const Any&  value
00137   );
00138 
00139   StructDef_ptr create_struct(
00140     const char* id,      
00141     const char* name,    
00142     const char* version, 
00143     const StructMemberSeq& members
00144   );
00145 
00146   UnionDef_ptr create_union(
00147     const char* id,      
00148     const char* name,    
00149     const char* version, 
00150     IDLType_ptr discriminator_type,
00151     const UnionMemberSeq& members
00152   );
00153 
00154   EnumDef_ptr create_enum(
00155     const char* id,      
00156     const char* name,    
00157     const char* version, 
00158     const EnumMemberSeq& members
00159   );
00160 
00161   AliasDef_ptr create_alias(
00162     const char* id,      
00163     const char* name,    
00164     const char* version, 
00165     IDLType_ptr original_type
00166   );
00167 
00168   InterfaceDef_ptr create_interface(
00169     const char* id,      
00170     const char* name,    
00171     const char* version, 
00172     const InterfaceDefSeq& base_interfaces
00173   );
00174 
00175   ExceptionDef_ptr create_exception(
00176     const char* id,      
00177     const char* name,    
00178     const char* version, 
00179     const StructMemberSeq& members
00180   );
00181 
00183   ValueDef_ptr create_value(
00184     const char* id,      
00185     const char* name,    
00186     const char* version, 
00187     Boolean                is_custom,
00188     Boolean                is_abstract,
00189     ValueDef_ptr           base_value,
00190     Boolean                is_truncatable,
00191     const ValueDefSeq&     abstract_base_values,
00192     const InterfaceDefSeq& supported_interfaces,
00193     const InitializerSeq&  initializers
00194   );
00195 
00197   ValueBoxDef_ptr create_value_box(
00198     const char* id,      
00199     const char* name,    
00200     const char* version, 
00201     IDLType_ptr original_type_def
00202   );
00203 
00205   NativeDef_ptr create_native(
00206     const char* id,      
00207     const char* name,    
00208     const char* version  
00209   );
00210 
00212   AbstractInterfaceDef_ptr create_abstract_interface(
00213     const char* id,      
00214     const char* name,    
00215     const char* version, 
00216     const AbstractInterfaceDefSeq& base_interfaces
00217   );
00218 
00219   /* Not implemented in omniORB.
00220   LocalInterfaceDef_ptr create_local_interface(
00221     const char* id,      ///< typedef: RepositoryId
00222     const char* name,    ///< typedef: Identifier
00223     const char* version, ///< typedef: VersionSpec
00224     const InterfaceDefSeq& base_interfaces
00225   );
00226   */
00227 
00228 protected:
00229   void dependentObjectSet(set<const IRObject_impl*>& result) const;
00230   void containedObjectSet(set<const IRObject_impl*>& result) const;
00231   
00237   void recreate(PersistNode* node, map<IRObject_impl*,PersistNode*>& todo);
00238   
00240   void outputContents(ostream &os) const;
00241 
00242 public:
00243   Container_impl();
00244   virtual ~Container_impl() {}
00245   virtual void uncheckedDestroy() =0;
00246 
00251   Contained_impl* lookupServant(
00252     const char* searchName, 
00253     bool        matchCase
00254   );
00255 
00260   virtual bool canContain(DefinitionKind kind)=0;
00261 
00262   void addContained(Contained_impl* contained);
00263   void removeContained(Contained_impl* contained);
00264 
00265 private:
00266   list<Contained_impl*> _contents;
00267 
00272   struct EqualName{
00273     EqualName(const char* name,bool matchCase):_name(name),_case(matchCase){}
00274     bool operator()(Contained_ptr c){return test(c->name());}
00275     bool operator()(Contained_impl* c);
00277     bool test(char* name) {
00278       String_var cname(name); // consumes parameter
00279       if(_case)
00280         return(0==strcmp(cname.in(),_name.in()));
00281       else
00282         return(0==strcasecmp(cname.in(),_name.in()));
00283     }
00284     CORBA::String_var _name;
00285     bool              _case;
00286   };
00287 }; // Container_impl
00288 
00289 } // end namespace Omniifr
00290 
00291 #endif // OMNIIFR__CONTAINER_H

Generated on Fri Mar 4 13:03:22 2005 for OmniIFR by  doxygen 1.4.1