anatomist 6.0.4
3D neuroimaging data viewer
Command.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef ANA_PROCESSOR_COMMAND_H
36#define ANA_PROCESSOR_COMMAND_H
37
38
39//--- header files ------------------------------------------------------------
40
41#include <map>
42#include <string>
43
44class Tree;
45
46
47//--- class declarations ------------------------------------------------------
48
49
50namespace anatomist
51{
52 class Serializer;
53 class Unserializer;
54 class CommandReader;
55 struct CommandContext;
56
59 class Command
60 {
61 public:
63 virtual ~Command();
64
66 virtual void execute();
68 virtual void undo();
70 virtual void redo();
71
72 typedef Command* (*Reader)( const Tree &, CommandContext * );
73
75 virtual std::string name() const = 0;
76
78 virtual void write( Tree & com, Serializer *ser ) const;
79
80 protected:
85
87 virtual void doit() = 0;
89 virtual void undoit();
90
91 private:
93 Command(const Command&);
95 Command& operator=(const Command&);
96 };
97
98
99 //--- class declarations ----------------------------------------------------
100
103 class RegularCommand : public Command
104 {
105 public:
108
109 protected:
114 };
115
116
117 //--- class declarations ----------------------------------------------------
118
128 {
129 public:
132 const CommandContext *context() const { return _context; }
133
134 protected:
136
138 };
139
140
141 //--- class declarations ----------------------------------------------------
142
145 class WaitCommand : public Command
146 {
147 public:
149 virtual ~WaitCommand();
150
152 virtual void execute();
154 virtual void undo();
156 virtual void redo();
157
158 protected:
163 };
164
165}
166
167
168#endif
CommandReader replays history files.
Definition Reader.h:58
virtual void undoit()
Undo a command.
virtual void write(Tree &com, Serializer *ser) const
Print the guts of a command into a Tree given as parent.
virtual void undo()
Undo the command - may use {\tt undoit()}.
virtual void execute()
Execute the command - may use {\tt doit()}.
virtual ~Command()
Destructor does nothing.
Command()
The programmer cannot call the constructor of an abstract base class.
virtual void doit()=0
Do a command.
virtual void redo()
Redo the command - may use {\tt doit()}.
virtual std::string name() const =0
Return the unique name of a class of commands.
RegularCommand()
The programmer cannot call the constructor of an abstract base class.
virtual ~RegularCommand()
Destructor does nothing.
Serializer is a helper class for pointer serialization.
Definition Serializer.h:56
const CommandContext * context() const
Definition Command.h:132
SerializingCommand(CommandContext *)
CommandContext * context()
Definition Command.h:131
CommandContext * _context
Definition Command.h:137
Pointer decoder (or id to pointer map)
virtual void execute()
Execute the command - may use {\tt doit()}.
WaitCommand()
The programmer cannot call the constructor of an abstract base class.
virtual void undo()
Undo the command - may use {\tt undoit()}.
virtual void redo()
Redo the command - may use {\tt doit()}.
virtual ~WaitCommand()
Destructor does nothing.
Context for commands processor readers (APipeReader etc)
Definition context.h:48