Version: 9.16.0
commands.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 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#ifndef _COMMANDS_HXX_
21#define _COMMANDS_HXX_
22
23#include "HMIExport.hxx"
24#include <list>
25#include <string>
26#include <vector>
27
28namespace YACS
29{
30 namespace ENGINE
31 {
32 class Proc;
33 class Catalog;
34 }
35
36 namespace HMI
37 {
38 class Command
39 {
40 public:
41 Command();
42 virtual bool execute();
43 virtual bool reverse(bool isNormal=true);
44 virtual bool executeSubOnly();
45 virtual std::string dump();
46 std::string recursiveDump(int level =0);
47 void addSubCommand(Command* command);
48 bool isNormalReverse() { return _normalReverse; };
49 protected:
50 virtual bool localExecute() = 0;
51 virtual bool localReverse() = 0;
52 std::vector<Command*> _subCommands;
54 };
55
57 {
58 friend class Command;
59 public:
60 Invocator();
61 void add(Command* command);
62 bool undo();
63 bool redo();
64 std::list<std::string> getDone();
65 std::list<std::string> getUndone();
66 YACS::ENGINE::Proc *getUndoProc() { return _undoProc; };
67 YACS::ENGINE::Catalog *getUndoCata() { return _undoCata; };
68 bool isSpecialReverse() { return _specialReverse; };
69 static int _ctr;
70
71 protected:
72 std::vector<Command*> _commandsDone;
73 std::vector<Command*> _commandsUndone;
74 std::vector<Command*> _commandsInProgress;
77 bool _isRedo;
78 bool _isUndo;
80 };
81 }
82}
83#endif
#define HMI_EXPORT
Definition: HMIExport.hxx:30
class for YACS catalogs.
Definition: Catalog.hxx:42
Base class for all schema objects.
Definition: Proc.hxx:44
virtual bool reverse(bool isNormal=true)
Reverse action: undo.
Definition: commands.cxx:79
virtual bool executeSubOnly()
execute only sub commands in a reverse action
Definition: commands.cxx:105
virtual bool execute()
the command is executed a first time after its registration for undo redo, then on redo
Definition: commands.cxx:51
bool isNormalReverse()
Definition: commands.hxx:48
virtual bool localExecute()=0
std::vector< Command * > _subCommands
Definition: commands.hxx:52
std::string recursiveDump(int level=0)
Definition: commands.cxx:124
virtual bool localReverse()=0
void addSubCommand(Command *command)
Definition: commands.cxx:134
virtual std::string dump()
Definition: commands.cxx:119
YACS::ENGINE::Proc * getUndoProc()
Definition: commands.hxx:66
YACS::ENGINE::Proc * _undoProc
Definition: commands.hxx:75
YACS::ENGINE::Catalog * _undoCata
Definition: commands.hxx:76
std::vector< Command * > _commandsUndone
Definition: commands.hxx:73
std::vector< Command * > _commandsDone
Definition: commands.hxx:72
YACS::ENGINE::Catalog * getUndoCata()
Definition: commands.hxx:67
std::vector< Command * > _commandsInProgress
Definition: commands.hxx:74