1 // SALOME DataTypeCatalog : catalog of data types
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_DataTypeCatalog_Client.cxx
31 #include "SALOME_NamingService.hxx"
32 #include "SALOME_DataTypeCatalog.hh"
34 #include "utilities.h"
36 int main(int argc,char **argv)
39 CosNaming::NamingContext_var _rootContext;
40 CORBA::Object_var objVar, objVarN;
45 orb = CORBA::ORB_init (argc, argv);
48 // Get CORBA reference of the catalog
49 SALOME_NamingService NS(orb);
50 CORBA::Object_var objVarN = NS.Resolve("/Kernel/DataTypeCatalog");
52 SALOME_DataTypeCatalog::DataCatalog_var Catalogue = SALOME_DataTypeCatalog::DataCatalog::_narrow(objVarN);
53 MESSAGE("Distant catalog of data type found")
56 SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type = Catalogue->GetDataTypeList();
58 for (unsigned int ind = 0; ind < list_data_type->length();ind++)
60 MESSAGE("Data Type list : " << list_data_type[ind]);
65 // obtain interface_read of the first data type defined in the catalog
67 interf =Catalogue->GetDataInterfaceRead(list_data_type[0]);
68 MESSAGE("Interface read pour " << list_data_type[0] << " : " << interf);
72 // obtain interface_read of the last data type defined in the catalog
73 interf =Catalogue->GetDataInterfaceRead(list_data_type[list_data_type->length() -1]);
74 MESSAGE("Interface read pour " << list_data_type[list_data_type->length() -1] << " : " << interf);
76 // obtain interface_write of the first data type defined in the catalog
77 interf =Catalogue->GetDataInterfaceWrite(list_data_type[0]);
78 MESSAGE("Interface write pour " << list_data_type[0] << " : " << interf);
82 // obtain interface_read of the last data type defined in the catalog
83 interf =Catalogue->GetDataInterfaceWrite(list_data_type[list_data_type->length() -1]);
84 MESSAGE("Interface write pour " << list_data_type[list_data_type->length() -1] << " : " << interf);
86 //obtain parents name of the last data type defined in the catalog
87 SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type1 = Catalogue->GetDataTypeParents(list_data_type[list_data_type->length() -1]);
90 if (Catalogue->isDerivedFrom(list_data_type[0],list_data_type[list_data_type->length() -1]))
92 MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " derived from " << list_data_type[0] );
96 MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " is not derived from " << list_data_type[0]);
100 catch(SALOME_DataTypeCatalog::NotFound &){
101 INFOS("SALOME_DataTypeCatalog::NotFound");
103 catch(CORBA::SystemException&) {
104 INFOS("Caught CORBA::SystemException.")
106 catch (CosNaming::NamingContext::CannotProceed &) {
107 INFOS("CosNaming::NamingContext::CannotProceed")
109 catch (CosNaming::NamingContext::NotFound &) {
110 INFOS("CosNaming::NamingContext::NotFound")
112 catch (CosNaming::NamingContext::InvalidName &) {
113 INFOS("CosNaming::NamingContext::InvalidName")
115 catch (CosNaming::NamingContext::AlreadyBound &) {
116 INFOS("CosNaming::NamingContext::AlreadyBound")
118 catch (CosNaming::NamingContext::NotEmpty &) {
119 INFOS("CosNaming::NamingContext::NotEmpty")
122 catch(CORBA::Exception &sysEx) {
123 INFOS("Caught CORBA::Exception.")