1 // Copyright (C) 2007-2008 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.
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
22 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
23 // File : SALOME_ModuleCatalog_Client.cxx
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_ModuleCatalog.hh"
32 #include "utilities.h"
35 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
36 const string & InterfaceName,
37 const string & ServiceName);
39 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
40 const 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
113 path =Superv->GetPathPrefix("omote");
114 MESSAGE("Path prefix pour omote : " << path);
116 // obtain prefix path for a computer
117 path =Geom->GetPathPrefix("eri");
118 MESSAGE("Path prefix pour eri : " << path);
121 catch(SALOME_ModuleCatalog::NotFound &ex){
122 INFOS("SALOME_ModuleCatalog::NotFound")
123 cerr << ex.what << endl;
125 catch(CORBA::SystemException&) {
126 INFOS("Caught CORBA::SystemException.")
128 catch (CosNaming::NamingContext::CannotProceed &) {
129 INFOS("CosNaming::NamingContext::CannotProceed")
131 catch (CosNaming::NamingContext::NotFound &) {
132 INFOS("CosNaming::NamingContext::NotFound")
134 catch (CosNaming::NamingContext::InvalidName &) {
135 INFOS("CosNaming::NamingContext::InvalidName")
137 catch (CosNaming::NamingContext::AlreadyBound &) {
138 INFOS("CosNaming::NamingContext::AlreadyBound")
140 catch (CosNaming::NamingContext::NotEmpty &) {
141 INFOS("CosNaming::NamingContext::NotEmpty")
144 catch(CORBA::Exception &sysEx) {
145 INFOS("Caught CORBA::Exception.")
152 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C)
154 MESSAGE("Name : " << C->componentname());
155 MESSAGE("Type : " << C->component_type() << " multistudy : " << C->multistudy());
156 MESSAGE("Constraint : " << C->constraint());
157 MESSAGE("Icon : " << C->component_icone());
159 // obtain interfaces list of the component
161 SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList();
162 for (unsigned int i = 0; i < _list->length();i++) {
163 const char * s = _list[i];
164 PrintInterface(C, s);
169 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
170 const string & InterfaceName)
174 SALOME_ModuleCatalog::DefinitionInterface_var _interf
175 = C->GetInterface(InterfaceName.c_str());
176 MESSAGE ("Interface : " << _interf->interfacename);
178 SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist;
180 for (i = 0; i < n; i++) {
181 const char * _S = S[i].ServiceName;
182 PrintService(C, InterfaceName, _S);
186 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
187 const string & InterfaceName,
188 const string & ServiceName)
192 SALOME_ModuleCatalog::Service_var Service
193 = (ServiceName.compare("") == 0)
194 ? C->GetDefaultService(InterfaceName.c_str())
195 : C->GetService(InterfaceName.c_str(), ServiceName.c_str());
197 MESSAGE("Service : " << Service->ServiceName);
199 MESSAGE("In Parameter(s):");
200 n = Service->ServiceinParameter.length();
201 for (i = 0; i<n; i++)
203 MESSAGE(" Parameter "
204 << Service->ServiceinParameter[i].Parametername);
206 << Service->ServiceinParameter[i].Parametertype);
209 MESSAGE("Out Parameter(s):");
210 n = Service->ServiceoutParameter.length();
211 for (i = 0; i<n; i++)
213 MESSAGE(" Parameter "
214 << Service->ServiceoutParameter[i].Parametername);
216 << Service->ServiceoutParameter[i].Parametertype);
219 MESSAGE("In DataStreamParameter(s):");
220 n = Service->ServiceinDataStreamParameter.length();
221 for (i = 0; i<n; i++)
223 MESSAGE(" Parameter "
224 << Service->ServiceinDataStreamParameter[i].Parametername);
226 << Service->ServiceinDataStreamParameter[i].Parametertype);
227 MESSAGE(" Dependency : "
228 << Service->ServiceinDataStreamParameter[i].Parametertype);
231 MESSAGE("Out DataStreamParameter(s):");
232 n = Service->ServiceoutDataStreamParameter.length();
233 for (i = 0; i<n; i++)
235 MESSAGE(" Parameter "
236 << Service->ServiceoutDataStreamParameter[i].Parametername);
238 << Service->ServiceoutDataStreamParameter[i].Parametertype);
239 MESSAGE(" Dependency : "
240 << Service->ServiceoutDataStreamParameter[i].Parametertype);