5 #include "SALOME_NamingService.hxx"
6 #include "SALOME_ModuleCatalog.hh"
10 int main(int argc,char **argv)
12 char* name_to_find = "Geometry";
15 CosNaming::NamingContext_var _rootContext;
16 CORBA::Object_var objVar, objVarN;
21 orb = CORBA::ORB_init (argc, argv);
24 // Get CORBA reference of the catalog
25 SALOME_NamingService NS(orb);
26 CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog");
28 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
29 MESSAGE("Distant catalog of component found")
32 SALOME_ModuleCatalog::ListOfComponents_var list_composants = Catalogue->GetComponentList();
35 // Typed component list
36 MESSAGE("Get Typed Component list (GEOM Type)");
37 SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM);
38 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
39 MESSAGE("Component GEOM list : " << list_typed_composants[ind]);
41 MESSAGE("Get Typed Component list (SUPERV Type)");
42 SALOME_ModuleCatalog::ListOfComponents_var list_styped_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV);
43 for (unsigned int ind = 0; ind < list_styped_composants->length();ind++)
44 MESSAGE("Component SUPERV list : " << list_styped_composants[ind]);
46 // Get list of couple (component name, component icone)
47 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList();
48 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
50 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
51 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
54 // obtain a component (specified as parameter of the client)
55 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
56 if (CORBA::is_nil (Geom))
58 INFOS("Catalog Error : Component Geometry not found in the catalog")
62 MESSAGE("Component of name : " << Geom->componentname() << " created ");
63 MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <<Geom->multistudy());
64 MESSAGE("Component constraint : " << Geom->constraint());
65 MESSAGE("Component icone : " << Geom->component_icone());
67 // Obtain another component
68 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
69 if (CORBA::is_nil (Superv))
71 INFOS("Catalog Error : Component Supervision not found in the catalog")
75 MESSAGE("Component of name : " << Superv->componentname() << " created ");
76 MESSAGE("Component type : " << Superv->component_type() << " multistudy : " <<Superv->multistudy());
77 MESSAGE("Component constraint : " << Superv->constraint());
78 MESSAGE("Component icone : " << Superv->component_icone());
80 // obtain prefix path for a computer
82 path =Superv->GetPathPrefix("omote");
83 MESSAGE("Path prefix pour omote : " << path);
85 // obtain prefix path for a computer
86 path =Geom->GetPathPrefix("eri");
87 MESSAGE("Path prefix pour eri : " << path);
89 // obtain interfaces list of the component
90 SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces;
91 _list = Geom->GetInterfaceList();
92 for (unsigned int ind = 0; ind < _list->length();ind++)
93 MESSAGE("Interface name : " << _list[ind]);
95 // obtain interfaces list of the component
96 SALOME_ModuleCatalog::ListOfInterfaces_var _list1 = new SALOME_ModuleCatalog::ListOfInterfaces;
97 _list1 = Superv->GetInterfaceList();
98 for (unsigned int ind = 0; ind < _list1->length();ind++)
99 MESSAGE("Interface name : " << _list1[ind])
102 // Obtain one interface of a component
103 SALOME_ModuleCatalog::DefinitionInterface_var _interf = new SALOME_ModuleCatalog::DefinitionInterface;
104 _interf = Geom->GetInterface("Geometry");
105 MESSAGE ("Interface " << _interf->interfacename << " getted")
106 for (unsigned int ind = 0; ind < _interf->interfaceservicelist.length();ind++)
107 MESSAGE("Service name : " << _interf->interfaceservicelist[ind].ServiceName)
110 // obtain services list of the component
112 SALOME_ModuleCatalog::ListOfServices_var list_services_component = new SALOME_ModuleCatalog::ListOfServices;
113 list_services_component = Geom->GetServiceList("Geometry");
114 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
115 MESSAGE("Service name : " << list_services_component[ind])
118 // Get a service of the component
120 SALOME_ModuleCatalog::Service_var second_service = new SALOME_ModuleCatalog::Service;
121 second_service = Geom->GetDefaultService("Geometry");
123 MESSAGE("Default Service name: " << second_service->ServiceName)
124 for (unsigned int ind1 = 0; ind1 <second_service->ServiceinParameter.length();ind1++)
126 MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype)
127 MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername)
129 for (unsigned int ind1 = 0; ind1 <second_service->ServiceoutParameter.length();ind1++)
131 MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype)
132 MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername)
137 second_service = Geom->GetDefaultService("Geometry");
139 MESSAGE("Default Service name: " << second_service->ServiceName)
140 for (unsigned int ind1 = 0; ind1 <second_service->ServiceinParameter.length();ind1++)
142 MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype)
143 MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername)
145 for (unsigned int ind1 = 0; ind1 <second_service->ServiceoutParameter.length();ind1++)
147 MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype)
148 MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername)
153 // Get service of the component
155 SALOME_ModuleCatalog::Service_var service_1 = new SALOME_ModuleCatalog::Service;
157 service_1 = Geom->GetService("Geometry","MakeSphere") ;
159 MESSAGE("Service name: " << service_1->ServiceName)
160 for (unsigned int ind1 = 0; ind1 <service_1->ServiceinParameter.length();ind1++)
162 MESSAGE("Type of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametertype)
163 MESSAGE("Name of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametername)
166 for (unsigned int ind1 = 0; ind1 <service_1->ServiceoutParameter.length();ind1++)
168 MESSAGE("Type of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametertype)
169 MESSAGE("Name of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametername)
172 // Test levée exception
173 service_1 = Geom->GetService("BOX","makeBox") ;
177 catch(SALOME_ModuleCatalog::NotFound &ex){
178 INFOS("SALOME_ModuleCatalog::NotFound")
179 cerr << ex.what << endl;
181 catch(CORBA::SystemException&) {
182 INFOS("Caught CORBA::SystemException.")
184 catch (CosNaming::NamingContext::CannotProceed &) {
185 INFOS("CosNaming::NamingContext::CannotProceed")
187 catch (CosNaming::NamingContext::NotFound &) {
188 INFOS("CosNaming::NamingContext::NotFound")
190 catch (CosNaming::NamingContext::InvalidName &) {
191 INFOS("CosNaming::NamingContext::InvalidName")
193 catch (CosNaming::NamingContext::AlreadyBound &) {
194 INFOS("CosNaming::NamingContext::AlreadyBound")
196 catch (CosNaming::NamingContext::NotEmpty &) {
197 INFOS("CosNaming::NamingContext::NotEmpty")
200 catch(CORBA::Exception &sysEx) {
201 INFOS("Caught CORBA::Exception.")