Salome HOME
import SalomePro v1.2c
[modules/kernel.git] / src / DataTypeCatalog / SALOME_DataTypeCatalog_Client.cxx
1 //  SALOME DataTypeCatalog : catalog of data types
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_DataTypeCatalog_Client.cxx
25 //  Module : SALOME
26
27 using namespace std;
28 /* $Header$ */
29
30 #include <iostream.h>
31 #include "SALOME_NamingService.hxx"
32 #include "SALOME_DataTypeCatalog.hh"
33 #include <string>
34 #include "utilities.h"
35
36 int main(int argc,char **argv)
37 {
38   CORBA::ORB_var orb;
39   CosNaming::NamingContext_var _rootContext;
40   CORBA::Object_var objVar, objVarN;
41   try {
42
43         // initialize the ORB
44
45   orb = CORBA::ORB_init (argc, argv);
46
47  
48   // Get CORBA reference of the catalog
49   SALOME_NamingService NS(orb);
50   CORBA::Object_var objVarN = NS.Resolve("/Kernel/DataTypeCatalog");
51
52    SALOME_DataTypeCatalog::DataCatalog_var Catalogue  = SALOME_DataTypeCatalog::DataCatalog::_narrow(objVarN); 
53    MESSAGE("Distant catalog of data type found")
54
55      // Get component list
56    SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type = Catalogue->GetDataTypeList();
57    int indice =-1;
58    for (unsigned int ind = 0; ind < list_data_type->length();ind++)
59      {
60        MESSAGE("Data Type list : " << list_data_type[ind]);
61      }
62
63  
64
65    // obtain interface_read of the first data type defined in the catalog
66    char* interf;
67    interf =Catalogue->GetDataInterfaceRead(list_data_type[0]);
68    MESSAGE("Interface read pour " << list_data_type[0] << " : " << interf);
69
70
71
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);
75
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);
79
80
81
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);
85
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]);
88
89    // Test derivation
90    if (Catalogue->isDerivedFrom(list_data_type[0],list_data_type[list_data_type->length() -1]))
91      {
92      MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " derived from " << list_data_type[0] );
93      }
94    else
95      { 
96      MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " is not derived from " << list_data_type[0]);
97      }
98
99   }
100   catch(SALOME_DataTypeCatalog::NotFound &){
101     INFOS("SALOME_DataTypeCatalog::NotFound");
102   }
103     catch(CORBA::SystemException&) {
104       INFOS("Caught CORBA::SystemException.")
105   }
106     catch (CosNaming::NamingContext::CannotProceed &) {
107       INFOS("CosNaming::NamingContext::CannotProceed")
108   }
109     catch (CosNaming::NamingContext::NotFound &) {
110       INFOS("CosNaming::NamingContext::NotFound")
111   }
112     catch (CosNaming::NamingContext::InvalidName &) {
113       INFOS("CosNaming::NamingContext::InvalidName")
114   }
115     catch (CosNaming::NamingContext::AlreadyBound &) {
116       INFOS("CosNaming::NamingContext::AlreadyBound")
117   }
118     catch (CosNaming::NamingContext::NotEmpty &) {
119       INFOS("CosNaming::NamingContext::NotEmpty")
120   }
121
122   catch(CORBA::Exception &sysEx) {
123     INFOS("Caught CORBA::Exception.")
124   }
125
126
127   return 0;
128 }