Salome HOME
d9f6abe4379017c3098351c3e7c37568ae3fe50e
[modules/yacs.git] / src / genericgui / GuiExecutor.hxx
1 // Copyright (C) 2006-2022  CEA/DEN, EDF R&D
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 #ifndef _GUIEXECUTOR_HXX_
21 #define _GUIEXECUTOR_HXX_
22
23 #include "define.hxx"
24
25 #include <QObject>
26 #include <string>
27 #include <list>
28
29
30 #include <yacsgui.hh>
31
32 namespace YACS
33 {
34   namespace ENGINE
35   {
36     class Proc;
37     class Node;
38     class DataPort;
39   }
40
41   namespace HMI
42   {
43     class GuiObserver_i;
44     class QtGuiContext;
45
46     class GuiExecutor: public QObject
47     {
48     public:
49       GuiExecutor(YACS::ENGINE::Proc* proc);
50       virtual ~GuiExecutor();
51
52       void closeContext();
53
54       void startResumeDataflow(bool initialize = false);
55       bool checkEndOfDataflow(bool display = true);
56       void killDataflow();
57       void suspendDataflow();
58       void resumeDataflow();
59       void stopDataflow();
60       void resetDataflow();
61   
62       void setStepByStepMode();
63       void setContinueMode();
64       void setBreakpointMode();
65       void setStopOnError(bool aMode);
66       void unsetStopOnError();
67
68       void saveState(const std::string& xmlFile);
69       void setLoadStateFile(std::string xmlFile);
70   
71       YACS_ORB::executionMode getCurrentExecMode();
72       int getExecutorState();
73   
74       void setBreakpointList(std::list<std::string> breakpointList);
75       void addBreakpoint(std::string breakpoint);
76       void removeBreakpoint(std::string breakpoint);
77       void setNextStepList(std::list<std::string> nextStepList);
78
79       void setInPortValue(YACS::ENGINE::DataPort* port, std::string value);
80
81       void registerStatusObservers();
82       bool isRunning() const { return _isRunning; };
83       bool isStopOnError() const { return _isStopOnError; }
84
85       void setEngineRef(YACS_ORB::YACS_Gen_ptr ref);
86       YACS::ENGINE::Proc* getProc() { return _proc; };
87       std::string getErrorDetails(YACS::ENGINE::Node* node);
88       std::string getErrorReport(YACS::ENGINE::Node* node);
89       std::string getContainerLog();
90       std::string getContainerLog(YACS::ENGINE::Node* node);
91       void shutdownProc();
92       void setShutdownLevel(int level){_shutdownLevel=level;}
93       int getShutdownLevel(){return _shutdownLevel;}
94       
95       YACS::ExecutorState updateSchema(std::string jobState);
96
97       virtual bool event(QEvent *e);
98
99     protected:
100       void setBPList();
101
102       YACS::ENGINE::Proc* _proc;
103       QtGuiContext *_context;
104
105       YACS_ORB::YACS_Gen_var _engineRef;
106       YACS_ORB::ProcExec_var _procRef;
107       YACS_ORB::Observer_var _observerRef;
108
109       YACS::ExecutionMode _execMode;
110       GuiObserver_i* _serv;
111
112       bool _isRunning;
113       bool _isSuspended;
114       bool _isStopOnError;
115       int _shutdownLevel;
116
117       std::list<std::string> _breakpointList;
118       std::string _loadStateFile;
119     };
120   }
121 }
122
123 #endif