anatomist
5.1.2
3D neuroimaging data viewer
Processor.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_PROCESSOR_H
36
#define ANA_PROCESSOR_PROCESSOR_H
37
38
39
//--- header files ------------------------------------------------------------
40
41
#include <
anatomist/config/anatomist_config.h
>
42
#include <
anatomist/observer/Observable.h
>
43
#include <
cartobase/object/object.h
>
44
45
#include <queue>
46
#include <stack>
47
48
49
namespace
anatomist
50
{
51
class
Command;
52
struct
CommandContext;
53
54
55
//--- class declarations ----------------------------------------------------
56
66
class
Processor
:
public
Observable
67
{
68
public
:
69
Processor
();
70
virtual
~Processor
();
71
76
void
execute
(
Command
* c);
83
Command
*
execute
(
const
std::string & cname,
84
const
std::string & params =
""
,
85
CommandContext
* cc = 0 );
92
Command
*
execute
(
const
std::string & cname,
93
carto::Object
params =
carto::none
(),
94
CommandContext
* cc = 0 );
96
bool
undo
();
98
bool
redo
();
99
void
allowExecWhileIdle
(
bool
);
100
bool
execWhileIdle
()
const
;
101
bool
idle
()
const
;
102
105
106
class
Memo
107
{
108
public
:
109
enum
Type
{
EXECUTE
,
UNDO
,
REDO
};
110
Memo
(
Type
t,
Command
* c);
111
Type
type
()
const
;
112
Command
*
command
()
const
;
113
114
private
:
115
Type
_type;
116
Command
* _command;
117
};
118
120
121
private
:
124
126
Processor
(
const
Processor
&);
127
129
Processor
& operator=(
const
Processor
&);
130
132
135
137
std::queue<Command*> _todo;
138
140
std::stack<Command*> _done;
141
143
std::stack<Command*> _undone;
144
146
bool
_idle;
147
bool
_allowExecWhileIdle;
148
150
};
151
152
153
//--- global variables ------------------------------------------------------
154
156
extern
Processor*
theProcessor
;
157
158
159
//--- inline methods --------------------------------------------------------
160
161
inline
162
Processor::Memo::Memo
(
Type
t,
Command
* c)
163
: _type(t), _command(c)
164
{
165
}
166
167
168
inline
169
Processor::Memo::Type
170
Processor::Memo::type
()
const
171
{
172
return
_type;
173
}
174
175
176
inline
177
Command
*
178
Processor::Memo::command
()
const
179
{
180
return
_command;
181
}
182
183
}
184
185
#endif
Observable.h
anatomist_config.h
anatomist::Command
The abstract base class for commands.
Definition:
Command.h:60
anatomist::Observable
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition:
Observable.h:68
anatomist::Processor::Memo
Definition:
Processor.h:107
anatomist::Processor::Memo::type
Type type() const
Definition:
Processor.h:170
anatomist::Processor::Memo::command
Command * command() const
Definition:
Processor.h:178
anatomist::Processor::Memo::Memo
Memo(Type t, Command *c)
Definition:
Processor.h:162
anatomist::Processor::Memo::Type
Type
Definition:
Processor.h:109
anatomist::Processor::Memo::UNDO
@ UNDO
Definition:
Processor.h:109
anatomist::Processor::Memo::EXECUTE
@ EXECUTE
Definition:
Processor.h:109
anatomist::Processor::Memo::REDO
@ REDO
Definition:
Processor.h:109
anatomist::Processor
The command processor receives commands to manage and execute.
Definition:
Processor.h:67
anatomist::Processor::idle
bool idle() const
anatomist::Processor::undo
bool undo()
Undo last done command.
anatomist::Processor::redo
bool redo()
Redo last undone command.
anatomist::Processor::execute
Command * execute(const std::string &cname, const std::string ¶ms="", CommandContext *cc=0)
build and execute a command
anatomist::Processor::execWhileIdle
bool execWhileIdle() const
anatomist::Processor::allowExecWhileIdle
void allowExecWhileIdle(bool)
anatomist::Processor::execute
void execute(Command *c)
Give a command to execute.
anatomist::Processor::Processor
Processor()
anatomist::Processor::~Processor
virtual ~Processor()
anatomist::Processor::execute
Command * execute(const std::string &cname, carto::Object params=carto::none(), CommandContext *cc=0)
build and execute a command
carto::Object
anatomist
Definition:
anatomistinfo.h:40
anatomist::theProcessor
Processor * theProcessor
Pointer to the command processor of the application.
carto::none
Object none()
object.h
anatomist::CommandContext
Context for commands processor readers (APipeReader etc)
Definition:
context.h:48
anatomist
processor
Processor.h
Generated by
1.9.1