Salome HOME
Updated copyright comment
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesCatalog_Parser.hxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
24 //  File   : SALOME_ResourcesCatalog_Parser.hxx
25 //  Author : Estelle Deville
26 //  Module : SALOME
27 //$Header$
28 //
29 #ifndef SALOME_RESOURCES_CATALOG_PARSER
30 #define SALOME_RESOURCES_CATALOG_PARSER
31
32 #include "ResourcesManager_Defs.hxx"
33
34 #include <string>
35 #include <vector>
36 #include <list>
37 #include <map>
38 #include <iostream>
39
40 #ifdef WIN32
41 #pragma warning(disable:4251) // Warning DLL Interface ...
42 #endif
43
44 enum AccessProtocolType {sh, rsh, ssh, srun, pbsdsh, blaunch, rsync};
45
46 enum ResourceType {cluster, single_machine};
47
48 enum BatchType {none, pbs, lsf, sge, ccc, ll, slurm, vishnu, oar, coorm};
49
50 enum MpiImplType {nompi, lam, mpich1, mpich2, openmpi, ompi, slurmmpi, prun};
51
52 class RESOURCESMANAGER_EXPORT ResourcesException
53 {
54 public:
55   const std::string msg;
56
57   ResourcesException(const std::string m) : msg(m) {}
58 };
59
60 class RESOURCESMANAGER_EXPORT ResourceDataToSort
61   {
62
63   public:
64     std::string _Name;
65     unsigned int _nbOfNodes;
66     unsigned int _nbOfProcPerNode;
67     unsigned int _CPUFreqMHz;
68     unsigned int _memInMB;
69     static unsigned int _nbOfProcWanted;
70     static unsigned int _nbOfNodesWanted;
71     static unsigned int _nbOfProcPerNodeWanted;
72     static unsigned int _CPUFreqMHzWanted;
73     static unsigned int _memInMBWanted;
74
75   public:
76     ResourceDataToSort();
77     ResourceDataToSort(const std::string& name,
78                        unsigned int nbOfNodes,
79                        unsigned int nbOfProcPerNode,
80                        unsigned int CPUFreqMHz,
81                        unsigned int memInMB);
82     bool operator< (const ResourceDataToSort& other) const;
83     void Print() const;
84
85   private:
86     unsigned int GetNumberOfPoints() const;
87   };
88
89 class RESOURCESMANAGER_EXPORT ParserResourcesType
90 {
91 public:
92   ParserResourcesType();
93   virtual ~ParserResourcesType();
94
95   std::string getAccessProtocolTypeStr() const;
96   std::string getResourceTypeStr() const;
97   std::string getBatchTypeStr() const;
98   std::string getMpiImplTypeStr() const;
99   std::string getClusterInternalProtocolStr() const;
100   std::string getCanLaunchBatchJobsStr() const;
101   std::string getCanRunContainersStr() const;
102
103   void setAccessProtocolTypeStr(const std::string & protocolTypeStr);
104   void setResourceTypeStr(const std::string & resourceTypeStr);
105   void setBatchTypeStr(const std::string & batchTypeStr);
106   void setMpiImplTypeStr(const std::string & mpiImplTypeStr);
107   void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr);
108   void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr);
109   void setCanRunContainersStr(const std::string & canRunContainersStr);
110   std::string dump(char sep) const;
111
112   ResourceDataToSort DataForSort;
113   std::string Name;
114   std::string HostName;
115   AccessProtocolType Protocol;
116   AccessProtocolType ClusterInternalProtocol;
117   ResourceType type;
118   BatchType Batch;
119   MpiImplType mpi;
120   std::string UserName;
121   std::string AppliPath;
122   std::vector<std::string> ComponentsList;
123   std::vector<std::string> ModulesList;
124   std::string OS;
125   std::string batchQueue;
126   std::string userCommands;
127   std::string use;
128   std::list<ParserResourcesType> ClusterMembersList;
129   unsigned int nbOfProc;
130   bool can_launch_batch_jobs;
131   bool can_run_containers;
132   std::string working_directory;
133
134 protected:
135
136   static std::string protocolToString(AccessProtocolType protocol);
137   static AccessProtocolType stringToProtocol(const std::string & protocolStr);
138
139   RESOURCESMANAGER_EXPORT friend std::ostream & operator<<(std::ostream &os,
140                                                            const ParserResourcesType &rt);
141
142 };
143
144 typedef std::map<std::string, ParserResourcesType> MapOfParserResourcesType;
145 typedef std::map<std::string, ParserResourcesType>::iterator MapOfParserResourcesType_it;
146
147 #endif //SALOME_RESOURCES_CATALOG_PARSER