1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
24 // File : SALOME_ModuleCatalog_Client.cxx
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_ModuleCatalog.hh"
33 #include "utilities.h"
35 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
36 const std::string & InterfaceName,
37 const std::string & ServiceName);
39 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
40 const std::string & InterfaceName);
42 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C);
44 int main(int argc,char **argv)
48 CosNaming::NamingContext_var _rootContext;
49 CORBA::Object_var objVar, objVarN;
54 orb = CORBA::ORB_init (argc, argv);
57 // Get CORBA reference of the catalog
58 SALOME_NamingService NS(orb);
59 CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog");
61 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue
62 = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
63 MESSAGE("Distant catalog of component found")
66 SALOME_ModuleCatalog::ListOfComponents_var list_composants
67 = Catalogue->GetComponentList();
70 // Typed component list
71 MESSAGE("Get Typed Component list (GEOM Type)");
72 SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants
73 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM);
74 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
75 MESSAGE("Component GEOM list : " << list_typed_composants[ind]);
77 MESSAGE("Get Typed Component list (SUPERV Type)");
79 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV);
80 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
81 MESSAGE("Component SUPERV list : " << list_typed_composants[ind]);
83 // Get list of couple (component name, component icone)
84 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone
85 = Catalogue->GetComponentIconeList();
86 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
88 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
89 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
92 // obtain a component (specified as parameter of the client)
93 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
94 if (CORBA::is_nil (Geom))
96 INFOS("Catalog Error : Component Geometry not found in the catalog")
100 PrintComponent(Geom);
102 // Obtain another component
103 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
104 if (CORBA::is_nil (Superv))
106 INFOS("Catalog Error : Component Supervision not found in the catalog")
109 PrintComponent(Superv);
111 // obtain prefix path for a computer
112 MESSAGE("Path prefix pour omote : " << Superv->GetPathPrefix("omote"));
114 // obtain prefix path for a computer
115 MESSAGE("Path prefix pour eri : " << Geom->GetPathPrefix("eri"));
118 catch(SALOME_ModuleCatalog::NotFound &ex){
119 INFOS("SALOME_ModuleCatalog::NotFound")
120 std::cerr << ex.what << std::endl;
122 catch(CORBA::SystemException&) {
123 INFOS("Caught CORBA::SystemException.")
125 catch (CosNaming::NamingContext::CannotProceed &) {
126 INFOS("CosNaming::NamingContext::CannotProceed")
128 catch (CosNaming::NamingContext::NotFound &) {
129 INFOS("CosNaming::NamingContext::NotFound")
131 catch (CosNaming::NamingContext::InvalidName &) {
132 INFOS("CosNaming::NamingContext::InvalidName")
134 catch (CosNaming::NamingContext::AlreadyBound &) {
135 INFOS("CosNaming::NamingContext::AlreadyBound")
137 catch (CosNaming::NamingContext::NotEmpty &) {
138 INFOS("CosNaming::NamingContext::NotEmpty")
141 catch(CORBA::Exception &) {
142 INFOS("Caught CORBA::Exception.")
149 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C)
151 MESSAGE("Name : " << C->componentname());
152 MESSAGE("Constraint : " << C->constraint());
153 MESSAGE("Icon : " << C->component_icone());
155 // obtain interfaces list of the component
157 SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList();
158 for (unsigned int i = 0; i < _list->length();i++) {
159 const char * s = _list[i];
160 PrintInterface(C, s);
165 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
166 const std::string & InterfaceName)
170 SALOME_ModuleCatalog::DefinitionInterface_var _interf
171 = C->GetInterface(InterfaceName.c_str());
172 MESSAGE ("Interface : " << _interf->interfacename);
174 SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist;
176 for (i = 0; i < n; i++) {
177 const char * _S = S[i].ServiceName;
178 PrintService(C, InterfaceName, _S);
182 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
183 const std::string & InterfaceName,
184 const std::string & ServiceName)
188 SALOME_ModuleCatalog::Service_var Service
189 = (ServiceName.compare("") == 0)
190 ? C->GetDefaultService(InterfaceName.c_str())
191 : C->GetService(InterfaceName.c_str(), ServiceName.c_str());
193 MESSAGE("Service : " << Service->ServiceName);
195 MESSAGE("In Parameter(s):");
196 n = Service->ServiceinParameter.length();
197 for (i = 0; i<n; i++)
199 MESSAGE(" Parameter "
200 << Service->ServiceinParameter[i].Parametername);
202 << Service->ServiceinParameter[i].Parametertype);
205 MESSAGE("Out Parameter(s):");
206 n = Service->ServiceoutParameter.length();
207 for (i = 0; i<n; i++)
209 MESSAGE(" Parameter "
210 << Service->ServiceoutParameter[i].Parametername);
212 << Service->ServiceoutParameter[i].Parametertype);
215 MESSAGE("In DataStreamParameter(s):");
216 n = Service->ServiceinDataStreamParameter.length();
217 for (i = 0; i<n; i++)
219 MESSAGE(" Parameter "
220 << Service->ServiceinDataStreamParameter[i].Parametername);
222 << Service->ServiceinDataStreamParameter[i].Parametertype);
223 MESSAGE(" Dependency : "
224 << Service->ServiceinDataStreamParameter[i].Parametertype);
227 MESSAGE("Out DataStreamParameter(s):");
228 n = Service->ServiceoutDataStreamParameter.length();
229 for (i = 0; i<n; i++)
231 MESSAGE(" Parameter "
232 << Service->ServiceoutDataStreamParameter[i].Parametername);
234 << Service->ServiceoutDataStreamParameter[i].Parametertype);
235 MESSAGE(" Dependency : "
236 << Service->ServiceoutDataStreamParameter[i].Parametertype);