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
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_ModuleCatalog.hh"
33 #include "utilities.h"
36 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
37 const string & InterfaceName,
38 const string & ServiceName);
40 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
41 const string & InterfaceName);
43 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C);
45 int main(int argc,char **argv)
49 CosNaming::NamingContext_var _rootContext;
50 CORBA::Object_var objVar, objVarN;
55 orb = CORBA::ORB_init (argc, argv);
58 // Get CORBA reference of the catalog
59 SALOME_NamingService NS(orb);
60 CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog");
62 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue
63 = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
64 MESSAGE("Distant catalog of component found")
67 SALOME_ModuleCatalog::ListOfComponents_var list_composants
68 = Catalogue->GetComponentList();
71 // Typed component list
72 MESSAGE("Get Typed Component list (GEOM Type)");
73 SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants
74 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM);
75 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
76 MESSAGE("Component GEOM list : " << list_typed_composants[ind]);
78 MESSAGE("Get Typed Component list (SUPERV Type)");
80 = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV);
81 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
82 MESSAGE("Component SUPERV list : " << list_typed_composants[ind]);
84 // Get list of couple (component name, component icone)
85 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone
86 = Catalogue->GetComponentIconeList();
87 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
89 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
90 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
93 // obtain a component (specified as parameter of the client)
94 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
95 if (CORBA::is_nil (Geom))
97 INFOS("Catalog Error : Component Geometry not found in the catalog")
101 PrintComponent(Geom);
103 // Obtain another component
104 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
105 if (CORBA::is_nil (Superv))
107 INFOS("Catalog Error : Component Supervision not found in the catalog")
110 PrintComponent(Superv);
112 // obtain prefix path for a computer
114 path =Superv->GetPathPrefix("omote");
115 MESSAGE("Path prefix pour omote : " << path);
117 // obtain prefix path for a computer
118 path =Geom->GetPathPrefix("eri");
119 MESSAGE("Path prefix pour eri : " << path);
122 catch(SALOME_ModuleCatalog::NotFound &ex){
123 INFOS("SALOME_ModuleCatalog::NotFound")
124 cerr << ex.what << endl;
126 catch(CORBA::SystemException&) {
127 INFOS("Caught CORBA::SystemException.")
129 catch (CosNaming::NamingContext::CannotProceed &) {
130 INFOS("CosNaming::NamingContext::CannotProceed")
132 catch (CosNaming::NamingContext::NotFound &) {
133 INFOS("CosNaming::NamingContext::NotFound")
135 catch (CosNaming::NamingContext::InvalidName &) {
136 INFOS("CosNaming::NamingContext::InvalidName")
138 catch (CosNaming::NamingContext::AlreadyBound &) {
139 INFOS("CosNaming::NamingContext::AlreadyBound")
141 catch (CosNaming::NamingContext::NotEmpty &) {
142 INFOS("CosNaming::NamingContext::NotEmpty")
145 catch(CORBA::Exception &sysEx) {
146 INFOS("Caught CORBA::Exception.")
153 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C)
155 const char *_name = C->componentname();
157 MESSAGE("Name : " << C->componentname());
158 MESSAGE("Type : " << C->component_type() << " multistudy : " << C->multistudy());
159 MESSAGE("Constraint : " << C->constraint());
160 MESSAGE("Icon : " << C->component_icone());
162 // obtain interfaces list of the component
164 SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList();
165 for (unsigned int i = 0; i < _list->length();i++) {
166 const char * s = _list[i];
167 PrintInterface(C, s);
172 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
173 const string & InterfaceName)
177 SALOME_ModuleCatalog::DefinitionInterface_var _interf
178 = C->GetInterface(InterfaceName.c_str());
179 MESSAGE ("Interface : " << _interf->interfacename);
181 SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist;
183 for (i = 0; i < n; i++) {
184 const char * _S = S[i].ServiceName;
185 PrintService(C, InterfaceName, _S);
189 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
190 const string & InterfaceName,
191 const string & ServiceName)
195 SALOME_ModuleCatalog::Service_var Service
196 = (ServiceName.compare("") == 0)
197 ? C->GetDefaultService(InterfaceName.c_str())
198 : C->GetService(InterfaceName.c_str(), ServiceName.c_str());
200 MESSAGE("Service : " << Service->ServiceName);
202 MESSAGE("In Parameter(s):");
203 n = Service->ServiceinParameter.length();
204 for (i = 0; i<n; i++)
206 MESSAGE(" Parameter "
207 << Service->ServiceinParameter[i].Parametername);
209 << Service->ServiceinParameter[i].Parametertype);
212 MESSAGE("Out Parameter(s):");
213 n = Service->ServiceoutParameter.length();
214 for (i = 0; i<n; i++)
216 MESSAGE(" Parameter "
217 << Service->ServiceoutParameter[i].Parametername);
219 << Service->ServiceoutParameter[i].Parametertype);
222 MESSAGE("In DataStreamParameter(s):");
223 n = Service->ServiceinDataStreamParameter.length();
224 for (i = 0; i<n; i++)
226 MESSAGE(" Parameter "
227 << Service->ServiceinDataStreamParameter[i].Parametername);
229 << Service->ServiceinDataStreamParameter[i].Parametertype);
230 MESSAGE(" Dependency : "
231 << Service->ServiceinDataStreamParameter[i].Parametertype);
234 MESSAGE("Out DataStreamParameter(s):");
235 n = Service->ServiceoutDataStreamParameter.length();
236 for (i = 0; i<n; i++)
238 MESSAGE(" Parameter "
239 << Service->ServiceoutDataStreamParameter[i].Parametername);
241 << Service->ServiceoutDataStreamParameter[i].Parametertype);
242 MESSAGE(" Dependency : "
243 << Service->ServiceoutDataStreamParameter[i].Parametertype);