]> SALOME platform Git repositories - modules/kernel.git/blob - src/Launcher/SALOME_LogManager.hxx
Salome HOME
81c58766900bdf61978be9c933f7a47d9081a85c
[modules/kernel.git] / src / Launcher / SALOME_LogManager.hxx
1 // Copyright (C) 2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #pragma once
21
22 #include "SALOME_Launcher_defs.hxx"
23
24 #include "Python.h"
25
26 #include "PythonCppUtils.hxx"
27 #include "Utils_CorbaException.hxx"
28 #include "SALOMEconfig.h"
29
30 #include CORBA_SERVER_HEADER(SALOME_LogManager)
31
32 #include <vector>
33 #include <string>
34 #include <memory>
35
36 class SALOME_NamingService_Abstract;
37 class SALOME_LogManager;
38 class SALOME_ContainerPerfLog;
39 class SALOME_ContainerScriptPerfLog;
40
41 class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptExecPerfLog : public POA_Engines::ContainerScriptExecPerfLog
42 {
43 public:
44   SALOME_ContainerScriptExecPerfLog(SALOME_ContainerScriptPerfLog *father):_father(father) { }
45   SALOME_ContainerScriptPerfLog *father() const { return _father; }
46   void setPyObj(PyObject *obj) { _pyExecutionLog.set(obj); }
47   PyObject *pyObj() { return _pyExecutionLog.get(); }
48   PortableServer::POA_var getPOA();
49   void assign(const SALOME::vectorOfByte& value) override;
50   SALOME::vectorOfByte *getObj() override;
51 public:
52   void start();
53   AutoPyRef end();
54 private:
55   AutoPyRef _pyExecutionLog;
56   SALOME_ContainerScriptPerfLog *_father = nullptr;
57   std::vector<char> _data;
58 };
59
60 class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptPerfLog : public POA_Engines::ContainerScriptPerfLog
61 {
62 public:
63   SALOME_ContainerScriptPerfLog(SALOME_ContainerPerfLog *father, const std::string& name, const std::string& code):_father(father),_name(name),_code(code) { }
64   SALOME_ContainerPerfLog *father() const { return _father; }
65   void setPyObj(PyObject *obj) { _pyScriptLog.set(obj); }
66   PyObject *pyObj() { return _pyScriptLog.get(); }
67   PortableServer::POA_var getPOA();
68   Engines::ContainerScriptExecPerfLog_ptr addExecutionSession() override;
69   Engines::ListOfContainerScriptExecPerfLog *listOfExecs() override;
70   char *getCode() override;
71   char *getName() override;
72 private:
73   AutoPyRef _pyScriptLog;
74   SALOME_ContainerPerfLog *_father = nullptr;
75   std::string _name;
76   std::string _code;
77   std::vector< Engines::ContainerScriptExecPerfLog_var > _sessions;
78 };
79
80 class SALOMELAUNCHER_EXPORT SALOME_ContainerPerfLog : public POA_Engines::ContainerPerfLog
81 {
82 public:
83   SALOME_ContainerPerfLog(SALOME_LogManager *father, const std::string& nameInNS, const std::string& logFile):_father(father),_name_in_ns(nameInNS),_log_file(logFile) { }
84   SALOME_LogManager *father() const { return _father; }
85   void setPyObj(PyObject *obj) { _pyContLog.set(obj); }
86   PyObject *pyObj() { return _pyContLog.get(); }
87   PortableServer::POA_var getPOA(); 
88   char *getLogFile() override;
89   char *getContainerEntryInNS() override;
90   Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override;
91   Engines::ListOfContainerScriptPerfLog *listOfScripts() override;
92 private:
93   AutoPyRef _pyContLog;
94   SALOME_LogManager *_father = nullptr;
95   std::string _name_in_ns;
96   std::string _log_file;
97   std::vector< Engines::ContainerScriptPerfLog_var > _scripts;
98 };
99
100 class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager
101 {
102  public:
103   SALOME_LogManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns = nullptr);
104   PortableServer::POA_var getPOA() { return _poa; }
105   PyObject *pyHelper() const { return _pyLogManager; }
106   virtual ~SALOME_LogManager() = default;
107   Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override;
108   Engines::ListOfContainerPerfLog *listOfContainerLogs() override;
109  private:
110   PyObject *_pyLogManager = nullptr;
111   std::unique_ptr<SALOME_NamingService_Abstract> _NS;
112   PortableServer::POA_var _poa;
113   std::vector<Engines::ContainerPerfLog_var> _containers;
114  public:
115   static const char NAME_IN_NS[];
116 };