1 // Copyright (C) 2024 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SALOME_Launcher_defs.hxx"
26 #include "PythonCppUtils.hxx"
27 #include "Utils_CorbaException.hxx"
28 #include "SALOMEconfig.h"
30 #include CORBA_SERVER_HEADER(SALOME_LogManager)
36 class SALOME_NamingService_Abstract;
37 class SALOME_LogManager;
38 class SALOME_ContainerPerfLog;
39 class SALOME_ContainerScriptPerfLog;
40 class SALOME_ContainerScriptExecPerfLog;
42 class SALOMELAUNCHER_EXPORT SALOME_VisitorContainerLog
45 virtual void enterLogManager(SALOME_LogManager& inst) = 0;
46 virtual void leaveLogManager(SALOME_LogManager& inst) = 0;
47 virtual void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) = 0;
48 virtual void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) = 0;
49 virtual void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) = 0;
50 virtual void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) = 0;
51 virtual void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) = 0;
54 class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptExecPerfLog : public POA_Engines::ContainerScriptExecPerfLog
57 SALOME_ContainerScriptExecPerfLog(SALOME_ContainerScriptPerfLog *father):_father(father) { }
58 SALOME_ContainerScriptPerfLog *father() const { return _father; }
59 void setPyObj(PyObject *obj) { _pyExecutionLog.set(obj); }
60 PyObject *pyObj() { return _pyExecutionLog.get(); }
61 PortableServer::POA_var getPOA();
62 void assign(const SALOME::vectorOfByte& value) override;
63 SALOME::vectorOfByte *getObj() override;
64 const std::vector<char>& data() const { return _data; }
65 void setData(std::vector<char>&& data) { _data = std::move(data); }
67 void accept(SALOME_VisitorContainerLog &visitor);
72 AutoPyRef _pyExecutionLog;
73 SALOME_ContainerScriptPerfLog *_father = nullptr;
74 std::vector<char> _data;
77 class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptPerfLog : public POA_Engines::ContainerScriptPerfLog
80 SALOME_ContainerScriptPerfLog(SALOME_ContainerPerfLog *father, const std::string& name, const std::string& code):_father(father),_name(name),_code(code) { }
81 SALOME_ContainerPerfLog *father() const { return _father; }
82 void setPyObj(PyObject *obj) { _pyScriptLog.set(obj); }
83 PyObject *pyObj() { return _pyScriptLog.get(); }
84 PortableServer::POA_var getPOA();
85 Engines::ContainerScriptExecPerfLog_ptr addExecutionSession() override;
86 Engines::ListOfContainerScriptExecPerfLog *listOfExecs() override;
87 char *getCode() override;
88 char *getName() override;
89 const std::string& name() const { return _name; }
90 const std::string& code() const { return _code; }
91 void setName(const std::string& name) { _name = name; }
92 void setCode(const std::string& code) { _code = code; }
93 std::size_t getNumberOfSessions() const { return _sessions.size(); }
95 void accept(SALOME_VisitorContainerLog &visitor);
97 AutoPyRef _pyScriptLog;
98 SALOME_ContainerPerfLog *_father = nullptr;
101 std::vector< Engines::ContainerScriptExecPerfLog_var > _sessions;
104 class SALOMELAUNCHER_EXPORT SALOME_ContainerPerfLog : public POA_Engines::ContainerPerfLog
107 SALOME_ContainerPerfLog(SALOME_LogManager *father, const std::string& nameInNS, const std::string& logFile):_father(father),_name_in_ns(nameInNS),_log_file(logFile) { }
108 SALOME_LogManager *father() const { return _father; }
109 void setPyObj(PyObject *obj) { _pyContLog.set(obj); }
110 PyObject *pyObj() { return _pyContLog.get(); }
111 PortableServer::POA_var getPOA();
112 char *getLogFile() override;
113 char *getContainerEntryInNS() override;
114 Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override;
115 Engines::ListOfContainerScriptPerfLog *listOfScripts() override;
116 const std::string& nameInNS() const { return _name_in_ns; }
117 const std::string& logFile() const { return _log_file; }
118 void setNameInNS(const std::string& name) { _name_in_ns = name; }
119 void setLogFile(const std::string& logFile) { _log_file = logFile; }
120 std::size_t getNumberOfScripts() const { return _scripts.size(); }
122 void accept(SALOME_VisitorContainerLog &visitor);
124 AutoPyRef _pyContLog;
125 SALOME_LogManager *_father = nullptr;
126 std::string _name_in_ns;
127 std::string _log_file;
128 std::vector< Engines::ContainerScriptPerfLog_var > _scripts;
131 class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager
134 SALOME_LogManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns = nullptr);
135 PortableServer::POA_var getPOA() { return _poa; }
136 PyObject *pyHelper() const { return _pyLogManager; }
137 virtual ~SALOME_LogManager() = default;
138 Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override;
139 Engines::ListOfContainerPerfLog *listOfContainerLogs() override;
140 SALOME::vectorOfByte *getAllStruct() override;
141 std::size_t getNumberOfContainers() const { return _containers.size(); }
143 void accept(SALOME_VisitorContainerLog &visitor);
145 std::vector<char> dumpCppInternalFrmt();
147 PyObject *_pyLogManager = nullptr;
148 std::unique_ptr<SALOME_NamingService_Abstract> _NS;
149 PortableServer::POA_var _poa;
150 std::vector<Engines::ContainerPerfLog_var> _containers;
152 static const char NAME_IN_NS[];