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);
82 for (unsigned int ind = 0; ind < list_typed_composants->length();ind++)
84 for (ind = 0; ind < list_typed_composants->length();ind++)
86 MESSAGE("Component SUPERV list : " << list_typed_composants[ind]);
88 // Get list of couple (component name, component icone)
89 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone
90 = Catalogue->GetComponentIconeList();
92 for (unsigned int ind = 0; ind < list_composants_icone->length();ind++)
94 for (ind = 0; ind < list_composants_icone->length();ind++)
97 MESSAGE("Component name: " << list_composants_icone[ind].modulename);
98 MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone);
101 // obtain a component (specified as parameter of the client)
102 SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry");
103 if (CORBA::is_nil (Geom))
105 INFOS("Catalog Error : Component Geometry not found in the catalog")
109 PrintComponent(Geom);
111 // Obtain another component
112 SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision");
113 if (CORBA::is_nil (Superv))
115 INFOS("Catalog Error : Component Supervision not found in the catalog")
118 PrintComponent(Superv);
120 // obtain prefix path for a computer
122 path =Superv->GetPathPrefix("omote");
123 MESSAGE("Path prefix pour omote : " << path);
125 // obtain prefix path for a computer
126 path =Geom->GetPathPrefix("eri");
127 MESSAGE("Path prefix pour eri : " << path);
130 catch(SALOME_ModuleCatalog::NotFound &ex){
131 INFOS("SALOME_ModuleCatalog::NotFound")
132 cerr << ex.what << endl;
134 catch(CORBA::SystemException&) {
135 INFOS("Caught CORBA::SystemException.")
137 catch (CosNaming::NamingContext::CannotProceed &) {
138 INFOS("CosNaming::NamingContext::CannotProceed")
140 catch (CosNaming::NamingContext::NotFound &) {
141 INFOS("CosNaming::NamingContext::NotFound")
143 catch (CosNaming::NamingContext::InvalidName &) {
144 INFOS("CosNaming::NamingContext::InvalidName")
146 catch (CosNaming::NamingContext::AlreadyBound &) {
147 INFOS("CosNaming::NamingContext::AlreadyBound")
149 catch (CosNaming::NamingContext::NotEmpty &) {
150 INFOS("CosNaming::NamingContext::NotEmpty")
153 catch(CORBA::Exception &sysEx) {
154 INFOS("Caught CORBA::Exception.")
161 void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C)
163 const char *_name = C->componentname();
165 MESSAGE("Name : " << C->componentname());
166 MESSAGE("Type : " << C->component_type() << " multistudy : " << C->multistudy());
167 MESSAGE("Constraint : " << C->constraint());
168 MESSAGE("Icon : " << C->component_icone());
170 // obtain interfaces list of the component
172 SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList();
173 for (unsigned int i = 0; i < _list->length();i++) {
174 const char * s = _list[i];
175 PrintInterface(C, s);
180 void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C,
181 const string & InterfaceName)
185 SALOME_ModuleCatalog::DefinitionInterface_var _interf
186 = C->GetInterface(InterfaceName.c_str());
187 MESSAGE ("Interface : " << _interf->interfacename);
189 SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist;
191 for (i = 0; i < n; i++) {
192 const char * _S = S[i].ServiceName;
193 PrintService(C, InterfaceName, _S);
197 void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C,
198 const string & InterfaceName,
199 const string & ServiceName)
203 SALOME_ModuleCatalog::Service_var Service
204 = (ServiceName.compare("") == 0)
205 ? C->GetDefaultService(InterfaceName.c_str())
206 : C->GetService(InterfaceName.c_str(), ServiceName.c_str());
208 MESSAGE("Service : " << Service->ServiceName);
210 MESSAGE("In Parameter(s):");
211 n = Service->ServiceinParameter.length();
212 for (i = 0; i<n; i++)
214 MESSAGE(" Parameter "
215 << Service->ServiceinParameter[i].Parametername);
217 << Service->ServiceinParameter[i].Parametertype);
220 MESSAGE("Out Parameter(s):");
221 n = Service->ServiceoutParameter.length();
222 for (i = 0; i<n; i++)
224 MESSAGE(" Parameter "
225 << Service->ServiceoutParameter[i].Parametername);
227 << Service->ServiceoutParameter[i].Parametertype);
230 MESSAGE("In DataStreamParameter(s):");
231 n = Service->ServiceinDataStreamParameter.length();
232 for (i = 0; i<n; i++)
234 MESSAGE(" Parameter "
235 << Service->ServiceinDataStreamParameter[i].Parametername);
237 << Service->ServiceinDataStreamParameter[i].Parametertype);
238 MESSAGE(" Dependency : "
239 << Service->ServiceinDataStreamParameter[i].Parametertype);
242 MESSAGE("Out DataStreamParameter(s):");
243 n = Service->ServiceoutDataStreamParameter.length();
244 for (i = 0; i<n; i++)
246 MESSAGE(" Parameter "
247 << Service->ServiceoutDataStreamParameter[i].Parametername);
249 << Service->ServiceoutDataStreamParameter[i].Parametertype);
250 MESSAGE(" Dependency : "
251 << Service->ServiceoutDataStreamParameter[i].Parametertype);