Salome HOME
Merge from V6_main 01/04/2013
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesManager.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 #ifndef __SALOME_RESOURCESMANAGER_HXX__
24 #define __SALOME_RESOURCESMANAGER_HXX__
25
26 #include "Utils_SALOME_Exception.hxx"
27 #include "utilities.h"
28 #include <SALOMEconfig.h>
29 #include "SALOME_ResourcesCatalog_Handler.hxx"
30 #include "SALOME_LoadRateManager.hxx"
31 #include "SALOME_NamingService.hxx"
32 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
33 #include <string>
34 #include <fstream>
35 #include <vector>
36 #include "ResourcesManager.hxx"
37
38
39 #ifdef WIN32
40 # if defined SALOMERESOURCESMANAGER_EXPORTS || defined SalomeResourcesManager_EXPORTS
41 #  define SALOMERESOURCESMANAGER_EXPORT __declspec( dllexport )
42 # else
43 #  define SALOMERESOURCESMANAGER_EXPORT __declspec( dllimport )
44 # endif
45 #else
46 # define SALOMERESOURCESMANAGER_EXPORT
47 #endif
48
49 #ifdef WNT
50 #pragma warning(disable:4275) // Disable warning interface non dll
51 #endif
52
53 // --- WARNING ---
54 // The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
55 // in a critical section to be sure to be clean.
56 // Only one thread should use the SALOME_ResourcesManager class in a SALOME
57 // session.
58
59 class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
60   public POA_Engines::ResourcesManager,
61   public PortableServer::RefCountServantBase
62   {
63
64   public:
65
66     SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath);
67     SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
68
69     ~SALOME_ResourcesManager();
70
71     // CORBA Methods
72     Engines::ResourceList * GetFittingResources(const Engines::ResourceParameters& params);
73     char* FindFirst(const Engines::ResourceList& listOfResources);
74     char* Find(const char *policy, const Engines::ResourceList& listOfResources);
75     Engines::ResourceDefinition * GetResourceDefinition(const char * name);
76     void AddResource(const Engines::ResourceDefinition& new_resource,
77                      CORBA::Boolean write,
78                      const char * xml_file);
79
80     void RemoveResource(const char * resource_name,
81                         CORBA::Boolean write,
82                         const char * xml_file);
83
84     // Cpp Methods
85     void Shutdown();
86     ResourcesManager_cpp *GetImpl() { return &_rm; }
87     std::string getMachineFile(std::string resource_name, 
88                                CORBA::Long nb_procs,
89                                std::string parallelLib);
90
91
92     static const char *_ResourcesManagerNameInNS;
93   protected:
94
95     SALOME_NamingService *_NS;
96     CORBA::ORB_var _orb;
97     PortableServer::POA_var _poa;
98
99     //
100     //! will contain the informations on the data type catalog(after parsing)
101     MapOfParserResourcesType _resourcesBatchList;
102
103     ResourcesManager_cpp _rm;
104   };
105
106 #endif // RESSOURCESCATALOG_IMPL_H