Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesManager.hxx
1 #ifndef __SALOME_RESOURCESMANAGER_HXX__
2 #define __SALOME_RESOURCESMANAGER_HXX__
3
4 #include "Utils_SALOME_Exception.hxx"
5 #include "utilities.h"
6 #include <SALOMEconfig.h>
7 #include "SALOME_ResourcesCatalog_Handler.hxx"
8 #include "SALOME_LoadRateManager.hxx"
9 #include "SALOME_NamingService.hxx"
10 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
11 #include <string>
12 #include <fstream>
13 #include <vector>
14
15
16
17 #if defined RESOURCESMANAGER_EXPORTS
18 #if defined WIN32
19 #define RESOURCESMANAGER_EXPORT __declspec( dllexport )
20 #else
21 #define RESOURCESMANAGER_EXPORT
22 #endif
23 #else
24 #if defined WNT
25 #define RESOURCESMANAGER_EXPORT __declspec( dllimport )
26 #else
27 #define RESOURCESMANAGER_EXPORT
28 #endif
29 #endif
30
31 // --- WARNING ---
32 // The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
33 // in a critical section to be sure to be clean.
34 // Only one thread should use the SALOME_ResourcesManager class in a SALOME
35 // session.
36
37 class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
38   {
39
40   public:
41
42     SALOME_ResourcesManager(CORBA::ORB_ptr orb, const char *xmlFilePath);
43     SALOME_ResourcesManager(CORBA::ORB_ptr orb);
44
45     ~SALOME_ResourcesManager();
46
47     std::vector<std::string>
48     GetFittingResources(const Engines::MachineParameters& params,
49                         const char *moduleName)
50     throw(SALOME_Exception);
51
52     std::string FindBest(const Engines::MachineList& listOfMachines);
53
54     std::string BuildCommandToLaunchRemoteContainer
55     (const std::string& machine,
56      const Engines::MachineParameters& params);
57
58     std::string BuildCommandToLaunchLocalContainer
59     (const Engines::MachineParameters& params);
60
61     void RmTmpFile();
62
63     std::string BuildCommand(const std::string& machine,
64                              const char *containerName);
65
66     int AddResourceInCatalog
67     (const Engines::MachineParameters& paramsOfNewResources,
68      const std::map<std::string, std::string>& modulesOnNewResources,
69      const char *environPathOfPrerequired,
70      const char *alias,
71      const char *userName,
72      AccessModeType mode,
73      AccessProtocolType prot)
74     throw(SALOME_Exception);
75
76     void DeleteResourceInCatalog(const char *hostname);
77
78     void WriteInXmlFile();
79
80     const MapOfParserResourcesType& ParseXmlFile();
81
82     const MapOfParserResourcesType& GetList() const;
83
84   private:
85     SALOME_NamingService *_NS;
86
87     std::string BuildTempFileToLaunchRemoteContainer
88     (const std::string& machine,
89      const Engines::MachineParameters& params);
90
91     void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
92                                    const char *OS) const
93       throw(SALOME_Exception);
94
95     void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,
96                                      const char *moduleName) const
97       throw(SALOME_Exception);
98
99     void AddOmninamesParams(std::string& command) const;
100
101     void AddOmninamesParams(std::ofstream& fileStream) const;
102
103     std::string BuildTemporaryFileName() const;
104
105
106     //! will contain the path to the ressources catalog
107     QString _path_resources;
108
109     //! attribute that contains current tmp files generated
110     std::string _TmpFileName;
111
112     //! contains the rsh or ssh command to access directly to machine.
113     //  Only used by this->RmTmpFile in case of a remote launch.
114     std::string _CommandForRemAccess;
115
116     //! will contain the informations on the data type catalog(after parsing)
117     MapOfParserResourcesType _resourcesList;
118
119     SALOME_LoadRateManager _dynamicResourcesSelecter;
120
121     //! different behaviour if $APPLI exists (SALOME Application) 
122     bool _isAppliSalomeDefined;
123   };
124
125 #endif // RESSOURCESCATALOG_IMPL_H