]> SALOME platform Git repositories - modules/yacs.git/blob - src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx
Salome HOME
9fef8478bfc9eaf64a8dde989373c1672fd4a902
[modules/yacs.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 /* $Header$ */
28
29 #include <iostream>
30 #include "SALOME_NamingService.hxx"
31 #include <SALOMEconfig.h>
32 #ifndef WNT
33 #include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog)
34 #else
35 #include <SALOME_RessourcesCatalog.hh>
36 #endif
37 #include <string>
38 #include "utilities.h"
39 using namespace std;
40
41 int main(int argc,char **argv)
42 {
43   CORBA::ORB_var orb;
44   CosNaming::NamingContext_var _rootContext;
45   CORBA::Object_var objVar, objVarN;
46   try {
47
48         // initialize the ORB
49
50   orb = CORBA::ORB_init (argc, argv);
51
52  
53   // Get CORBA reference of the catalog
54   SALOME_NamingService NS(orb);
55   CORBA::Object_var objVarN = NS.Resolve("/Kernel/RessourcesCatalog");
56
57   SALOME_RessourcesCatalog::RessourcesCatalog_var Catalogue  = SALOME_RessourcesCatalog::RessourcesCatalog::_narrow(objVarN); 
58   MESSAGE("Ressources distant catalog found");
59
60   //Get Computer list information
61   SALOME_RessourcesCatalog::ListOfComputer_var _list = Catalogue->GetComputerList();
62   for (unsigned int ind = 0; ind < _list->length();ind++)
63     {
64       MESSAGE("Ressources list : " << _list[ind]);
65     }
66
67   //Get container type list of computer eri
68   SALOME_RessourcesCatalog::ListOfContainerType_var list = Catalogue->GetContainerTypeList("eri");
69 #ifndef WNT
70   for (unsigned int ind = 0; ind < list->length();ind++)
71 #else
72   for (ind = 0; ind < list->length();ind++)
73 #endif
74     {
75       MESSAGE("Container type list of eri : " << list[ind]);
76     }
77
78   // Get processors information of eri
79   SALOME_RessourcesCatalog::computer_info_var computer = Catalogue->GetComputerInfo("eri");
80   MESSAGE("Ressource name : " << computer->name);
81   MESSAGE("Ressource OS : " << computer->OS);
82   MESSAGE("Ressource OS version : " << computer->OS_version);
83 #ifndef WNT
84   for (unsigned int ind = 0; ind < computer->procs.length();ind++)
85 #else
86   for (ind = 0; ind < computer->procs.length();ind++)
87 #endif
88     {
89       MESSAGE("Processor number : " << computer->procs[ind].number);
90       MESSAGE("Processor model name : " << computer->procs[ind].model_name);
91       MESSAGE("Processor cpu : " << computer->procs[ind].cpu_mhz);
92       MESSAGE("Processor cache : " << computer->procs[ind].cache_size);
93     }
94
95   }
96   catch(SALOME_RessourcesCatalog::NotFound &){
97     INFOS("SALOME_RessourcesCatalog::NotFound");
98   }
99     catch(CORBA::SystemException&) {
100       INFOS("Caught CORBA::SystemException.")
101   }
102     catch (CosNaming::NamingContext::CannotProceed &) {
103       INFOS("CosNaming::NamingContext::CannotProceed")
104   }
105     catch (CosNaming::NamingContext::NotFound &) {
106       INFOS("CosNaming::NamingContext::NotFound")
107   }
108     catch (CosNaming::NamingContext::InvalidName &) {
109       INFOS("CosNaming::NamingContext::InvalidName")
110   }
111     catch (CosNaming::NamingContext::AlreadyBound &) {
112       INFOS("CosNaming::NamingContext::AlreadyBound")
113   }
114     catch (CosNaming::NamingContext::NotEmpty &) {
115       INFOS("CosNaming::NamingContext::NotEmpty")
116   }
117
118   catch(CORBA::Exception &sysEx) {
119     INFOS("Caught CORBA::Exception.")
120   }
121
122
123   return 0;
124 }