]> Creatis software - creaContours.git/blob - lib/kernel_ManagerContour_NDimensions/CommandsRegisterStructure.h
Feature #1772 Add licence terms for all files.
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / CommandsRegisterStructure.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #ifndef __COMMANDS_REGISTER_STRUCTURE__
27 #define __COMMANDS_REGISTER_STRUCTURE__
28
29 //------------------------------------------------------------------------------------------------------------
30 // Includes
31 //------------------------------------------------------------------------------------------------------------
32
33 #include <vector>
34 #include <iostream>
35 #include "CommandObject.h"
36
37 class CommandsRegisterStructure{
38
39 //------------------------------------------------------------------------------------------------------------
40 // Constructors & Destructors
41 //------------------------------------------------------------------------------------------------------------
42 public:
43
44         /*
45         * Creates the CommandsRegisterStructure
46         */
47         CommandsRegisterStructure();
48
49         /*
50         * Destroys the CommandsRegisterStructure
51         */
52         ~CommandsRegisterStructure();
53
54 //------------------------------------------------------------------------------------------------------------
55 // Methods
56 //------------------------------------------------------------------------------------------------------------
57
58         /**
59         * Registers a command in the vector with no verification, is should be well constructed
60         * @param theCommand The command to register
61         */
62         void registerCommand(CommandObject * theCommand);
63
64         /*
65         * Gets the -ACTUAL- command text 
66         * @return
67         */
68         //std::string getActualCommandText();
69
70         /*
71         * Gets the -LAST- command text 
72         * @return
73         */
74         //std::string getLastCommandText();
75
76         /*
77         * Deletes all the registered actions and reinitialize the -ACTUAL- and  -LAST- iterators
78         */
79         void clearActions();
80
81         /*
82         * Moves to the the previous position the -ACTUAL- iterator
83         * @return Indicates true if it was done
84         */
85         bool moveBack_Actual();
86
87         /*
88         * Moves to the the next position the -ACTUAL- iterator
89         * @return Indicates true if it was done
90         */
91         bool moveForward_Actual();
92
93         /*
94         * Moves to the the previous position the -LAST- iterator
95         * @return Indicates true if it was done
96         */
97         bool moveBack_Last();
98
99         /*
100         * Moves to the the next position the -LAST- iterator
101         * @return Indicates true if it was done
102         */
103         bool moveForward_Last();
104
105         /*
106         * Indicates if the -LAST- iterator has a next action or not
107         * @return Returns true if it has
108         */
109         bool hasLastNext();
110
111         /*
112         * Indicates if the -ACTUAL- iterator has a next action or not
113         * @return Returns true if it has
114         */
115         bool hasActualNext();
116
117         /*
118         * Indicates if the -LAST- iterator has a previous action or not
119         * @return Returns true if it has
120         */
121         bool hasLastPrevious();
122
123         /*
124         * Indicates if the -ACTUAL- iterator has a previous action or not
125         * @return Returns true if it has
126         */
127         bool hasActualPrevious();
128
129         /*
130         * Puts to point the -ACTUAL- iterator up to the -LAST-  iterator.
131         */
132         void levelActualToLast();
133
134         /*
135         * Puts to point the -LAST- iterator up to the -ACTUAL- iterator and erases automatically the actions after the 
136         * referenced last and the end of the registered actions if nothing is given by parameter.       
137         */
138         void levelLastToActual(bool clearingAfterLast = true);
139
140         /*
141         * Clear all the elements in the vector bettween the -LAST- iterator and the end of the vector
142         */
143         void clearAll_afterLast();
144
145         /*
146         * Clear all the elements in the vector bettween the -ACTUAL- iterator and the start of the vector       
147         */
148         void clearAll_beforeActual();
149
150         /**
151         * Indicates if there are actions in the vector of not
152         * @return Returns true is there are not registered actions      
153         */
154         bool isEmpty();
155
156         /**
157         * Indicates the quantity of actions that are registered
158         * @return Returns the total amount of registered actions in the vector
159         */
160         int getCommandsCount();
161
162         /*
163         * Gets the -ACTUAL-  iterator information data pointer
164         * @return The pointer to the referenced object by the -ACTUAL- iterator
165         */
166         CommandObject * getActual_Pointer();
167
168         /*
169         * Gets the -LAST-  iterator information data pointer
170         * @return The pointer to the referenced object by the -LAST- iterator
171         */
172         CommandObject * getLast_Pointer();
173
174         /*
175         * Gets the command at the given position 
176         * @return The pointer to the referenced object by the position
177         */
178         CommandObject * getCommandAt(int position);
179
180         /*
181         * Gets the index of the actualAction in the vector
182         * @return actualIndexToExec Is the corresponding index
183         */
184         int getActualIndex();
185
186         /*
187         * Gets the index of the lasAction in the vector
188         * @return lasAction Is the corresponding index
189         */
190         int getLasIndex();
191
192         /*
193         * Sets the index of the actualAction in the vector
194         * @param newActualIndex Is the corresponding index
195         */
196         void setActualIndex(int newActualIndex);
197
198         /*
199         * Sets the index of the lasAction in the vector
200         * @param newLasIndex Is the corresponding index
201         */
202         void setLasIndex(int newLasIndex);
203
204         /*
205         * Gets the registered commands vector size
206         * @return Returns the vector size
207         */
208         int getRegistereCommandsCount();
209
210         /*
211         * Gets the total registered commands 
212         * @return Returns the total of commands
213         */
214         int getTotalCommandsCount();
215
216
217         
218
219 //------------------------------------------------------------------------------------------------------------
220 // Constants
221 //------------------------------------------------------------------------------------------------------------
222
223 private:        
224 //------------------------------------------------------------------------------------------------------------
225 // Attributes
226 //------------------------------------------------------------------------------------------------------------
227         
228         /*
229         * Represents the actions successfully registered 
230         */
231         std::vector<CommandObject*> registeredActions;
232         
233         /*
234         * Represents the index to the actual action to execute at the registered actions vector
235         */
236         //std::vector <CommandObject*>::iterator actualAction;
237         int actualIndexToExec;
238         
239         /*
240         * Represents the index to the last action executed at the registered actions vector
241         */
242         //std::vector <CommandObject*>::iterator lastAction;   
243         int lastAction;   
244
245 };
246 #endif