Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/kernel.git] / src / RessourcesCatalog / SALOME_RessourcesCatalog_Client.cxx
1 //  SALOME RessourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_RessourcesCatalog_Client.cxx
25 //  Module : SALOME
26
27 using namespace std;
28 /* $Header$ */
29
30 #include <iostream.h>
31 #include "SALOME_NamingService.hxx"
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog)
34 #include <string>
35 #include "utilities.h"
36
37 int main(int argc,char **argv)
38 {
39   CORBA::ORB_var orb;
40   CosNaming::NamingContext_var _rootContext;
41   CORBA::Object_var objVar, objVarN;
42   try {
43
44         // initialize the ORB
45
46   orb = CORBA::ORB_init (argc, argv);
47
48  
49   // Get CORBA reference of the catalog
50   SALOME_NamingService NS(orb);
51   CORBA::Object_var objVarN = NS.Resolve("/Kernel/RessourcesCatalog");
52
53   SALOME_RessourcesCatalog::RessourcesCatalog_var Catalogue  = SALOME_RessourcesCatalog::RessourcesCatalog::_narrow(objVarN); 
54   MESSAGE("Ressources distant catalog found");
55
56   //Get Computer list information
57   SALOME_RessourcesCatalog::ListOfComputer_var _list = Catalogue->GetComputerList();
58   for (unsigned int ind = 0; ind < _list->length();ind++)
59     {
60       MESSAGE("Ressources list : " << _list[ind]);
61     }
62
63   //Get container type list of computer eri
64   SALOME_RessourcesCatalog::ListOfContainerType_var list = Catalogue->GetContainerTypeList("eri");
65   for (unsigned int ind = 0; ind < list->length();ind++)
66     {
67       MESSAGE("Container type list of eri : " << list[ind]);
68     }
69
70   // Get processors information of eri
71   SALOME_RessourcesCatalog::computer_info_var computer = Catalogue->GetComputerInfo("eri");
72   MESSAGE("Ressource name : " << computer->name);
73   MESSAGE("Ressource OS : " << computer->OS);
74   MESSAGE("Ressource OS version : " << computer->OS_version);
75   for (unsigned int ind = 0; ind < computer->procs.length();ind++)
76     {
77       MESSAGE("Processor number : " << computer->procs[ind].number);
78       MESSAGE("Processor model name : " << computer->procs[ind].model_name);
79       MESSAGE("Processor cpu : " << computer->procs[ind].cpu_mhz);
80       MESSAGE("Processor cache : " << computer->procs[ind].cache_size);
81     }
82
83   }
84   catch(SALOME_RessourcesCatalog::NotFound &){
85     INFOS("SALOME_RessourcesCatalog::NotFound");
86   }
87     catch(CORBA::SystemException&) {
88       INFOS("Caught CORBA::SystemException.")
89   }
90     catch (CosNaming::NamingContext::CannotProceed &) {
91       INFOS("CosNaming::NamingContext::CannotProceed")
92   }
93     catch (CosNaming::NamingContext::NotFound &) {
94       INFOS("CosNaming::NamingContext::NotFound")
95   }
96     catch (CosNaming::NamingContext::InvalidName &) {
97       INFOS("CosNaming::NamingContext::InvalidName")
98   }
99     catch (CosNaming::NamingContext::AlreadyBound &) {
100       INFOS("CosNaming::NamingContext::AlreadyBound")
101   }
102     catch (CosNaming::NamingContext::NotEmpty &) {
103       INFOS("CosNaming::NamingContext::NotEmpty")
104   }
105
106   catch(CORBA::Exception &sysEx) {
107     INFOS("Caught CORBA::Exception.")
108   }
109
110
111   return 0;
112 }