1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include "SALOME_ResourcesCatalog_Parser.hxx"
21 #include "utilities.h"
28 unsigned int ResourceDataToSort::_nbOfNodesWanted = NULL_VALUE;
29 unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted = NULL_VALUE;
30 unsigned int ResourceDataToSort::_CPUFreqMHzWanted = NULL_VALUE;
31 unsigned int ResourceDataToSort::_memInMBWanted = NULL_VALUE;
33 ResourceDataToSort::ResourceDataToSort()
36 ResourceDataToSort::ResourceDataToSort(const string& hostname,
37 unsigned int nbOfNodes,
38 unsigned int nbOfProcPerNode,
39 unsigned int CPUFreqMHz,
40 unsigned int memInMB):
42 _nbOfNodes(nbOfNodes),
43 _nbOfProcPerNode(nbOfProcPerNode),
44 _CPUFreqMHz(CPUFreqMHz),
48 //! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
49 bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
51 unsigned int nbPts = GetNumberOfPoints();
52 return nbPts < other.GetNumberOfPoints();
55 unsigned int ResourceDataToSort::GetNumberOfPoints() const
58 //priority 1 : Nb of nodes
60 if (_nbOfNodesWanted != NULL_VALUE)
62 if (_nbOfNodes == _nbOfNodesWanted)
64 else if (_nbOfNodes > _nbOfNodesWanted)
70 //priority 2 : Nb of proc by node
71 if (_nbOfProcPerNodeWanted != NULL_VALUE)
73 if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
75 else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
81 //priority 3 : Cpu freq
82 if (_CPUFreqMHzWanted != NULL_VALUE)
84 if (_CPUFreqMHz == _CPUFreqMHzWanted)
86 else if (_CPUFreqMHz > _CPUFreqMHzWanted)
93 if (_memInMBWanted != NULL_VALUE)
95 if (_memInMB == _memInMBWanted)
97 else if (_memInMB > _memInMBWanted)
106 //! Method used for debug
107 void ResourceDataToSort::Print() const
110 SCRUTE(_nbOfProcPerNode);
115 void ParserResourcesType::Print()
117 MESSAGE("##############*****");
118 MESSAGE("HostName : " << DataForSort._hostName);
119 MESSAGE("Alias : " << Alias);
120 MESSAGE("Protocol : " << Protocol);
121 MESSAGE("Mode : " << Mode);
122 MESSAGE("UserName : " << UserName);
123 MESSAGE("Modules : ");
126 for (std::map<std::string, std::string>::iterator iter = ModulesPath.begin();
127 iter != ModulesPath.end();
130 MESSAGE("Module " << i++ << " called : " << (*iter).first
131 << " with path : " << (*iter).second);
134 MESSAGE("PreReqFilePath : " << PreReqFilePath);
135 MESSAGE("OS : " << OS);