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