Salome HOME
157fbe433d010770b2acd0ad01929c037c52fed6
[modules/yacs.git] / src / hmi / commands.hxx
1 //  Copyright (C) 2006-2008  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.
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 #ifndef _COMMANDS_HXX_
20 #define _COMMANDS_HXX_
21
22 #include <list>
23 #include <stack>
24 #include <string>
25
26 namespace YACS
27 {
28   namespace HMI
29   {
30     class Command
31     {
32     public:
33       Command();
34       virtual bool execute();
35       virtual bool reverse();
36       //virtual std::string getCommandType() = 0; // utiliser un dynamic_cast plutot
37       void addSubCommand(Command* command);
38     protected:
39       virtual bool localExecute() = 0;
40       virtual bool localReverse() = 0;
41       std::list<Command*> _subCommands;
42     };
43     
44     class Invocator
45     {
46     public:
47       Invocator();
48       void add(Command* command);
49       bool undo();
50       bool redo();
51     protected:
52       std::stack<Command*> _commandsDone;
53       std::stack<Command*> _commandsUndone;
54     };
55   }
56 }
57 #endif