Salome HOME
NRI : Check if a component-username is already associated with a component-name.
[modules/kernel.git] / src / DataTypeCatalog / SALOME_DataTypeCatalog_Client.cxx
1 using namespace std;
2 /* $Header$ */
3
4 #include <iostream.h>
5 #include "SALOME_NamingService.hxx"
6 #include "SALOME_DataTypeCatalog.hh"
7 #include <string>
8 #include "utilities.h"
9
10 int main(int argc,char **argv)
11 {
12   CORBA::ORB_var orb;
13   CosNaming::NamingContext_var _rootContext;
14   CORBA::Object_var objVar, objVarN;
15   try {
16
17         // initialize the ORB
18
19   orb = CORBA::ORB_init (argc, argv);
20
21  
22   // Get CORBA reference of the catalog
23   SALOME_NamingService NS(orb);
24   CORBA::Object_var objVarN = NS.Resolve("/Kernel/DataTypeCatalog");
25
26    SALOME_DataTypeCatalog::DataCatalog_var Catalogue  = SALOME_DataTypeCatalog::DataCatalog::_narrow(objVarN); 
27    MESSAGE("Distant catalog of data type found")
28
29      // Get component list
30    SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type = Catalogue->GetDataTypeList();
31    int indice =-1;
32    for (unsigned int ind = 0; ind < list_data_type->length();ind++)
33      {
34        MESSAGE("Data Type list : " << list_data_type[ind]);
35      }
36
37  
38
39    // obtain interface_read of the first data type defined in the catalog
40    char* interf;
41    interf =Catalogue->GetDataInterfaceRead(list_data_type[0]);
42    MESSAGE("Interface read pour " << list_data_type[0] << " : " << interf);
43
44
45
46    // obtain interface_read of the last data type defined in the catalog
47    interf =Catalogue->GetDataInterfaceRead(list_data_type[list_data_type->length() -1]);
48    MESSAGE("Interface read pour " << list_data_type[list_data_type->length() -1] << " : " << interf);
49
50    // obtain interface_write of the first data type defined in the catalog
51    interf =Catalogue->GetDataInterfaceWrite(list_data_type[0]);
52    MESSAGE("Interface write pour " << list_data_type[0] << " : " << interf);
53
54
55
56    // obtain interface_read of the last data type defined in the catalog
57    interf =Catalogue->GetDataInterfaceWrite(list_data_type[list_data_type->length() -1]);
58    MESSAGE("Interface write pour " << list_data_type[list_data_type->length() -1] << " : " << interf);
59
60    //obtain parents name of the last data type defined in the catalog
61    SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type1 = Catalogue->GetDataTypeParents(list_data_type[list_data_type->length() -1]);
62
63    // Test derivation
64    if (Catalogue->isDerivedFrom(list_data_type[0],list_data_type[list_data_type->length() -1]))
65      {
66      MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " derived from " << list_data_type[0] );
67      }
68    else
69      { 
70      MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " is not derived from " << list_data_type[0]);
71      }
72
73   }
74   catch(SALOME_DataTypeCatalog::NotFound &){
75     INFOS("SALOME_DataTypeCatalog::NotFound");
76   }
77     catch(CORBA::SystemException&) {
78       INFOS("Caught CORBA::SystemException.")
79   }
80     catch (CosNaming::NamingContext::CannotProceed &) {
81       INFOS("CosNaming::NamingContext::CannotProceed")
82   }
83     catch (CosNaming::NamingContext::NotFound &) {
84       INFOS("CosNaming::NamingContext::NotFound")
85   }
86     catch (CosNaming::NamingContext::InvalidName &) {
87       INFOS("CosNaming::NamingContext::InvalidName")
88   }
89     catch (CosNaming::NamingContext::AlreadyBound &) {
90       INFOS("CosNaming::NamingContext::AlreadyBound")
91   }
92     catch (CosNaming::NamingContext::NotEmpty &) {
93       INFOS("CosNaming::NamingContext::NotEmpty")
94   }
95
96   catch(CORBA::Exception &sysEx) {
97     INFOS("Caught CORBA::Exception.")
98   }
99
100
101   return 0;
102 }