Salome HOME
Merge tag 'V8_3_0a2' into ngr/python3_dev
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesManager.hxx
1 // Copyright (C) 2007-2016  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, 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 #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_NamingService.hxx"
30 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
31 #include <string>
32 #include <fstream>
33 #include <vector>
34 #include "ResourcesManager.hxx"
35
36 #include "SALOME_ResourcesManager_Common.hxx"
37
38 #ifdef WIN32
39 #pragma warning(disable:4275) // Disable warning interface non dll
40 #endif
41
42 // --- WARNING ---
43 // The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
44 // in a critical section to be sure to be clean.
45 // Only one thread should use the SALOME_ResourcesManager class in a SALOME
46 // session.
47
48 class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
49   public POA_Engines::ResourcesManager,
50   public PortableServer::RefCountServantBase
51   {
52
53   public:
54
55     SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath);
56     SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
57
58     ~SALOME_ResourcesManager();
59
60     // CORBA Methods
61     Engines::ResourceList * GetFittingResources(const Engines::ResourceParameters& params);
62     char* FindFirst(const Engines::ResourceList& listOfResources);
63     char* Find(const char *policy, const Engines::ResourceList& listOfResources);
64     Engines::ResourceDefinition * GetResourceDefinition(const char * name);
65     void AddResource(const Engines::ResourceDefinition& new_resource,
66                      CORBA::Boolean write,
67                      const char * xml_file);
68
69     void RemoveResource(const char * resource_name,
70                         CORBA::Boolean write,
71                         const char * xml_file);
72     char* getMachineFile(const char * resource_name,
73                          CORBA::Long nb_procs,
74                          const char * parallelLib);
75     void ListAllAvailableResources(Engines::ResourceList_out machines, Engines::IntegerList_out nbProcsOfMachines);
76     // Cpp Methods
77     void Shutdown();
78     ResourcesManager_cpp *GetImpl() { return &_rm; }
79
80
81     static const char *_ResourcesManagerNameInNS;
82   protected:
83
84     SALOME_NamingService *_NS;
85     CORBA::ORB_var _orb;
86     PortableServer::POA_var _poa;
87     ResourcesManager_cpp _rm;
88   };
89
90 #endif // RESSOURCESCATALOG_IMPL_H