00001 // Package : omniIFR 00002 // Repository.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__REPOSITORY_H 00024 #define OMNIIFR__REPOSITORY_H 00025 00026 #ifdef HAVE_CONFIG_H 00027 # include "config.h" 00028 #endif 00029 00030 #ifdef HAVE_IOSTREAM 00031 # include <iostream> 00032 #else 00033 # include <iostream.h> 00034 #endif 00035 00036 #include "Container.h" 00037 00038 #include <string> 00039 #include <map> 00040 00041 namespace Omniifr { 00042 00043 class PrimitiveDef_impl; 00044 class IDLType_impl; 00045 class Contained_impl; 00046 class Persist; 00047 class PersistNode; 00048 00049 class Repository_impl : 00050 public virtual POA_CORBA::Repository, 00051 public Container_impl 00052 { 00054 // Singleton stuff. 00055 private: 00056 static Repository_impl _inst; 00057 public: 00058 static Repository_impl& inst() {return _inst;} 00059 void init(ORB_ptr orb, bool readonly=false, Persist* persist=NULL); 00060 ORB_ptr _orb; 00061 PortableServer::POA_var _poa; 00062 PortableServer::POA_var _omniINSPOA; 00063 DynamicAny::DynAnyFactory_var _DynAnyFactory; 00065 00066 public: // CORBA interface methods 00067 00068 // methods that read 00069 Contained_ptr lookup_id(const char* search_id); 00070 TypeCode_ptr get_canonical_typecode(TypeCode_ptr tc); 00071 PrimitiveDef_ptr get_primitive(PrimitiveKind kind); 00072 00073 // methods that write 00074 StringDef_ptr create_string( ULong bound ); 00075 WstringDef_ptr create_wstring( ULong bound ); 00076 SequenceDef_ptr create_sequence( ULong bound, IDLType_ptr element_type ); 00077 ArrayDef_ptr create_array( ULong length, IDLType_ptr element_type ); 00078 FixedDef_ptr create_fixed( UShort digits, Short scale ); 00079 00080 public: // CORBA interface methods (from IRObject) 00081 DefinitionKind def_kind(){return dk_Repository;} 00082 00083 00084 private: 00085 map<PrimitiveKind,PrimitiveDef_impl*> _primitives; 00086 set<IDLType_impl*> _anonymous; 00087 map<string,Contained_impl*> _idmap; 00088 bool _readonly; 00089 00090 public: 00091 Repository_impl(); 00092 virtual ~Repository_impl(); 00093 void uncheckedDestroy(); 00094 void createPoa(PortableServer::POA_ptr rootPoa); 00095 bool canContain(DefinitionKind kind); 00096 void addId(string id, Contained_impl* container); 00097 void removeId(string id); 00098 Contained_impl* findId(string id); 00099 void addAnonymous(IDLType_impl* anon); 00100 void removeAnonymous(IDLType_impl* anon); 00101 bool readonly() const { return _readonly; } 00102 00106 void reincarnate(const PersistNode& node); 00107 void output(ostream &os); 00108 00109 protected: 00110 PortableServer::POA_ptr _default_POA(); 00111 }; // Repository_impl 00112 00113 } // end namespace Omniifr 00114 00115 #endif // OMNIIFR__REPOSITORY_H