1 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
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_ModuleCatalog_Client.cxx
31 #include "SALOME_NamingService.hxx"
32 #include "SALOME_ModuleCatalog.hh"
34 #include "utilities.h"
36 int main(int argc,char **argv)
38 char* name_to_find = "Geometry";
41 CosNaming::NamingContext_var _rootContext;
42 CORBA::Object_var objVar, objVarN;
47 orb = CORBA::ORB_init (argc, argv);
50 // Get CORBA reference of the catalog
51 SALOME_NamingService NS(orb);
52 CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog");
54 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
55 MESSAGE("Distant catalog of component found")
58 SALOME_ModuleCatalog::ListOfComponents_var list_composants = Catalogue->GetComponentList();
61 // Typed component list
62 MESSAGE("Get Typed Component list (GEOM Type)");
63 SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM);
64 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
65 MESSAGE("Component GEOM list : " << list_typed_composants[ind]);
67 MESSAGE("Get Typed Component list (SUPERV Type)");
68 SALOME_ModuleCatalog::ListOfComponents_var list_styped_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV);
69 for (unsigned int ind = 0; ind < list_styped_composants->length();ind++)
70 MESSAGE("Component SUPERV list : " << list_styped_composants[ind]);
72 // Get list of couple (component name, component icone)
73 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList();
74 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
76 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
77 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
80 // obtain a component (specified as parameter of the client)
81 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
82 if (CORBA::is_nil (Geom))
84 INFOS("Catalog Error : Component Geometry not found in the catalog")
88 MESSAGE("Component of name : " << Geom->componentname() << " created ");
89 MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <<Geom->multistudy());
90 MESSAGE("Component constraint : " << Geom->constraint());
91 MESSAGE("Component icone : " << Geom->component_icone());
93 // Obtain another component
94 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
95 if (CORBA::is_nil (Superv))
97 INFOS("Catalog Error : Component Supervision not found in the catalog")
101 MESSAGE("Component of name : " << Superv->componentname() << " created ");
102 MESSAGE("Component type : " << Superv->component_type() << " multistudy : " <<Superv->multistudy());
103 MESSAGE("Component constraint : " << Superv->constraint());
104 MESSAGE("Component icone : " << Superv->component_icone());
106 // obtain prefix path for a computer
108 path =Superv->GetPathPrefix("omote");
109 MESSAGE("Path prefix pour omote : " << path);
111 // obtain prefix path for a computer
112 path =Geom->GetPathPrefix("eri");
113 MESSAGE("Path prefix pour eri : " << path);
115 // obtain interfaces list of the component
116 SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces;
117 _list = Geom->GetInterfaceList();
118 for (unsigned int ind = 0; ind < _list->length();ind++)
119 MESSAGE("Interface name : " << _list[ind]);
121 // obtain interfaces list of the component
122 SALOME_ModuleCatalog::ListOfInterfaces_var _list1 = new SALOME_ModuleCatalog::ListOfInterfaces;
123 _list1 = Superv->GetInterfaceList();
124 for (unsigned int ind = 0; ind < _list1->length();ind++)
125 MESSAGE("Interface name : " << _list1[ind])
128 // Obtain one interface of a component
129 SALOME_ModuleCatalog::DefinitionInterface_var _interf = new SALOME_ModuleCatalog::DefinitionInterface;
130 _interf = Geom->GetInterface("Geometry");
131 MESSAGE ("Interface " << _interf->interfacename << " getted")
132 for (unsigned int ind = 0; ind < _interf->interfaceservicelist.length();ind++)
133 MESSAGE("Service name : " << _interf->interfaceservicelist[ind].ServiceName)
136 // obtain services list of the component
138 SALOME_ModuleCatalog::ListOfServices_var list_services_component = new SALOME_ModuleCatalog::ListOfServices;
139 list_services_component = Geom->GetServiceList("Geometry");
140 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
141 MESSAGE("Service name : " << list_services_component[ind])
144 // Get a service of the component
146 SALOME_ModuleCatalog::Service_var second_service = new SALOME_ModuleCatalog::Service;
147 second_service = Geom->GetDefaultService("Geometry");
149 MESSAGE("Default Service name: " << second_service->ServiceName)
150 for (unsigned int ind1 = 0; ind1 <second_service->ServiceinParameter.length();ind1++)
152 MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype)
153 MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername)
155 for (unsigned int ind1 = 0; ind1 <second_service->ServiceoutParameter.length();ind1++)
157 MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype)
158 MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername)
163 second_service = Geom->GetDefaultService("Geometry");
165 MESSAGE("Default Service name: " << second_service->ServiceName)
166 for (unsigned int ind1 = 0; ind1 <second_service->ServiceinParameter.length();ind1++)
168 MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype)
169 MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername)
171 for (unsigned int ind1 = 0; ind1 <second_service->ServiceoutParameter.length();ind1++)
173 MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype)
174 MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername)
179 // Get service of the component
181 SALOME_ModuleCatalog::Service_var service_1 = new SALOME_ModuleCatalog::Service;
183 service_1 = Geom->GetService("Geometry","MakeSphere") ;
185 MESSAGE("Service name: " << service_1->ServiceName)
186 for (unsigned int ind1 = 0; ind1 <service_1->ServiceinParameter.length();ind1++)
188 MESSAGE("Type of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametertype)
189 MESSAGE("Name of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametername)
192 for (unsigned int ind1 = 0; ind1 <service_1->ServiceoutParameter.length();ind1++)
194 MESSAGE("Type of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametertype)
195 MESSAGE("Name of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametername)
198 // Test levée exception
199 service_1 = Geom->GetService("BOX","makeBox") ;
203 catch(SALOME_ModuleCatalog::NotFound &ex){
204 INFOS("SALOME_ModuleCatalog::NotFound")
205 cerr << ex.what << endl;
207 catch(CORBA::SystemException&) {
208 INFOS("Caught CORBA::SystemException.")
210 catch (CosNaming::NamingContext::CannotProceed &) {
211 INFOS("CosNaming::NamingContext::CannotProceed")
213 catch (CosNaming::NamingContext::NotFound &) {
214 INFOS("CosNaming::NamingContext::NotFound")
216 catch (CosNaming::NamingContext::InvalidName &) {
217 INFOS("CosNaming::NamingContext::InvalidName")
219 catch (CosNaming::NamingContext::AlreadyBound &) {
220 INFOS("CosNaming::NamingContext::AlreadyBound")
222 catch (CosNaming::NamingContext::NotEmpty &) {
223 INFOS("CosNaming::NamingContext::NotEmpty")
226 catch(CORBA::Exception &sysEx) {
227 INFOS("Caught CORBA::Exception.")