1 // Copyright (C) 2007-2024 CEA, EDF, 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 "ArgvKeeper.hxx"
32 #include "SALOME_NamingService.hxx"
33 #include "SALOME_ModuleCatalog.hh"
35 #include "utilities.h"
37 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
38 const std::string & InterfaceName,
39 const std::string & ServiceName);
41 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
42 const std::string & InterfaceName);
44 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C);
46 int main(int argc,char **argv)
50 CosNaming::NamingContext_var _rootContext;
51 CORBA::Object_var objVar, objVarN;
55 SetArgcArgv(argc, argv);
56 orb = KERNEL::GetRefToORB();
59 // Get CORBA reference of the catalog
60 SALOME_NamingService NS(orb);
61 CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog");
63 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue
64 = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
65 MESSAGE("Distant catalog of component found");
68 SALOME_ModuleCatalog::ListOfComponents_var list_composants
69 = Catalogue->GetComponentList();
72 // Typed component list
73 MESSAGE("Get Typed Component list (GEOM Type)");
74 SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants
75 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM);
76 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
77 MESSAGE("Component GEOM list : " << list_typed_composants[ind]);
79 MESSAGE("Get Typed Component list (SUPERV Type)");
81 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV);
82 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
83 MESSAGE("Component SUPERV list : " << list_typed_composants[ind]);
85 // Get list of couple (component name, component icone)
86 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone
87 = Catalogue->GetComponentIconeList();
88 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
90 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
91 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
94 // obtain a component (specified as parameter of the client)
95 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
96 if (CORBA::is_nil (Geom))
98 INFOS("Catalog Error : Component Geometry not found in the catalog")
102 PrintComponent(Geom);
104 // Obtain another component
105 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
106 if (CORBA::is_nil (Superv))
108 INFOS("Catalog Error : Component Supervision not found in the catalog")
111 PrintComponent(Superv);
113 // obtain prefix path for a computer
114 MESSAGE("Path prefix pour omote : " << Superv->GetPathPrefix("omote"));
116 // obtain prefix path for a computer
117 MESSAGE("Path prefix pour eri : " << Geom->GetPathPrefix("eri"));
120 catch(SALOME_ModuleCatalog::NotFound &ex){
121 INFOS("SALOME_ModuleCatalog::NotFound")
122 std::cerr << ex.what << std::endl;
124 catch(CORBA::SystemException&) {
125 INFOS("Caught CORBA::SystemException.")
127 catch (CosNaming::NamingContext::CannotProceed &) {
128 INFOS("CosNaming::NamingContext::CannotProceed")
130 catch (CosNaming::NamingContext::NotFound &) {
131 INFOS("CosNaming::NamingContext::NotFound")
133 catch (CosNaming::NamingContext::InvalidName &) {
134 INFOS("CosNaming::NamingContext::InvalidName")
136 catch (CosNaming::NamingContext::AlreadyBound &) {
137 INFOS("CosNaming::NamingContext::AlreadyBound")
139 catch (CosNaming::NamingContext::NotEmpty &) {
140 INFOS("CosNaming::NamingContext::NotEmpty")
143 catch(CORBA::Exception &) {
144 INFOS("Caught CORBA::Exception.")
151 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C)
153 MESSAGE("Name : " << C->componentname());
154 MESSAGE("Constraint : " << C->constraint());
155 MESSAGE("Icon : " << C->component_icone());
157 // obtain interfaces list of the component
159 SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList();
160 for (unsigned int i = 0; i < _list->length();i++) {
161 const char * s = _list[i];
162 PrintInterface(C, s);
167 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
168 const std::string & InterfaceName)
172 SALOME_ModuleCatalog::DefinitionInterface_var _interf
173 = C->GetInterface(InterfaceName.c_str());
174 MESSAGE ("Interface : " << _interf->interfacename);
176 SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist;
178 for (i = 0; i < n; i++) {
179 const char * _S = S[i].ServiceName;
180 PrintService(C, InterfaceName, _S);
184 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
185 const std::string & InterfaceName,
186 const std::string & ServiceName)
190 SALOME_ModuleCatalog::Service_var Service
191 = (ServiceName.compare("") == 0)
192 ? C->GetDefaultService(InterfaceName.c_str())
193 : C->GetService(InterfaceName.c_str(), ServiceName.c_str());
195 MESSAGE("Service : " << Service->ServiceName);
197 MESSAGE("In Parameter(s):");
198 n = Service->ServiceinParameter.length();
199 for (i = 0; i<n; i++)
201 MESSAGE(" Parameter "
202 << Service->ServiceinParameter[i].Parametername);
204 << Service->ServiceinParameter[i].Parametertype);
207 MESSAGE("Out Parameter(s):");
208 n = Service->ServiceoutParameter.length();
209 for (i = 0; i<n; i++)
211 MESSAGE(" Parameter "
212 << Service->ServiceoutParameter[i].Parametername);
214 << Service->ServiceoutParameter[i].Parametertype);
217 MESSAGE("In DataStreamParameter(s):");
218 n = Service->ServiceinDataStreamParameter.length();
219 for (i = 0; i<n; i++)
221 MESSAGE(" Parameter "
222 << Service->ServiceinDataStreamParameter[i].Parametername);
224 << Service->ServiceinDataStreamParameter[i].Parametertype);
225 MESSAGE(" Dependency : "
226 << Service->ServiceinDataStreamParameter[i].Parametertype);
229 MESSAGE("Out DataStreamParameter(s):");
230 n = Service->ServiceoutDataStreamParameter.length();
231 for (i = 0; i<n; i++)
233 MESSAGE(" Parameter "
234 << Service->ServiceoutDataStreamParameter[i].Parametername);
236 << Service->ServiceoutDataStreamParameter[i].Parametertype);
237 MESSAGE(" Dependency : "
238 << Service->ServiceoutDataStreamParameter[i].Parametertype);