Salome HOME
75969394f701641a539fbbaf829ba669f390a59e
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesCatalog_Parser.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, 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.
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 WNT
41 #pragma warning(disable:4251) // Warning DLL Interface ...
42 #endif
43
44 enum AccessProtocolType {sh, rsh, ssh, srun, pbsdsh, blaunch};
45
46 enum ResourceType {cluster, single_machine};
47
48 enum BatchType {none, pbs, lsf, sge, ssh_batch, ccc, ll, slurm, vishnu, oar, coorm};
49
50 enum MpiImplType {nompi, lam, mpich1, mpich2, openmpi, ompi, slurmmpi, prun};
51
52 class RESOURCESMANAGER_EXPORT ResourceDataToSort
53   {
54
55   public:
56     std::string _Name;
57     unsigned int _nbOfNodes;
58     unsigned int _nbOfProcPerNode;
59     unsigned int _CPUFreqMHz;
60     unsigned int _memInMB;
61     static unsigned int _nbOfProcWanted;
62     static unsigned int _nbOfNodesWanted;
63     static unsigned int _nbOfProcPerNodeWanted;
64     static unsigned int _CPUFreqMHzWanted;
65     static unsigned int _memInMBWanted;
66
67   public:
68     ResourceDataToSort();
69     ResourceDataToSort(const std::string& name,
70                        unsigned int nbOfNodes,
71                        unsigned int nbOfProcPerNode,
72                        unsigned int CPUFreqMHz,
73                        unsigned int memInMB);
74     bool operator< (const ResourceDataToSort& other) const;
75     void Print() const;
76
77   private:
78     unsigned int GetNumberOfPoints() const;
79   };
80
81 class RESOURCESMANAGER_EXPORT ParserResourcesType
82 {
83 public:
84   ParserResourcesType();
85   virtual ~ParserResourcesType();
86
87   std::string getAccessProtocolTypeStr() const;
88   std::string getResourceTypeStr() const;
89   std::string getBatchTypeStr() const;
90   std::string getMpiImplTypeStr() const;
91   std::string getClusterInternalProtocolStr() const;
92   std::string getCanLaunchBatchJobsStr() const;
93   std::string getCanRunContainersStr() const;
94
95   void setAccessProtocolTypeStr(const std::string & protocolTypeStr);
96   void setResourceTypeStr(const std::string & resourceTypeStr);
97   void setBatchTypeStr(const std::string & batchTypeStr);
98   void setMpiImplTypeStr(const std::string & mpiImplTypeStr);
99   void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr);
100   void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr);
101   void setCanRunContainersStr(const std::string & canRunContainersStr);
102
103   ResourceDataToSort DataForSort;
104   std::string Name;
105   std::string HostName;
106   AccessProtocolType Protocol;
107   AccessProtocolType ClusterInternalProtocol;
108   ResourceType type;
109   BatchType Batch;
110   MpiImplType mpi;
111   std::string UserName;
112   std::string AppliPath;
113   std::vector<std::string> ComponentsList;
114   std::vector<std::string> ModulesList;
115   std::string OS;
116   std::string batchQueue;
117   std::string userCommands;
118   std::string use;
119   std::list<ParserResourcesType> ClusterMembersList;
120   unsigned int nbOfProc;
121   bool can_launch_batch_jobs;
122   bool can_run_containers;
123   std::string working_directory;
124
125 protected:
126
127   static std::string protocolToString(AccessProtocolType protocol);
128   static AccessProtocolType stringToProtocol(const std::string & protocolStr);
129
130   RESOURCESMANAGER_EXPORT friend std::ostream & operator<<(std::ostream &os,
131                                                            const ParserResourcesType &rt);
132
133 };
134
135 typedef std::map<std::string, ParserResourcesType> MapOfParserResourcesType;
136 typedef std::map<std::string, ParserResourcesType>::iterator MapOfParserResourcesType_it;
137
138 #endif //SALOME_RESOURCES_CATALOG_PARSER