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