]> Creatis software - creaContours.git/blob - lib/kernel_ManagerContour_NDimensions/CommandsRegisterStructure.h
377939734f036e42b784be61009395cced4e7c06
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / CommandsRegisterStructure.h
1 #ifndef __COMMANDS_REGISTER_STRUCTURE__
2 #define __COMMANDS_REGISTER_STRUCTURE__
3
4 //------------------------------------------------------------------------------------------------------------
5 // Includes
6 //------------------------------------------------------------------------------------------------------------
7
8 #include <vector>
9 #include <iostream>
10 #include "CommandObject.h"
11
12 class CommandsRegisterStructure{
13
14 //------------------------------------------------------------------------------------------------------------
15 // Constructors & Destructors
16 //------------------------------------------------------------------------------------------------------------
17 public:
18
19         /*
20         * Creates the CommandsRegisterStructure
21         */
22         CommandsRegisterStructure();
23
24         /*
25         * Destroys the CommandsRegisterStructure
26         */
27         ~CommandsRegisterStructure();
28
29 //------------------------------------------------------------------------------------------------------------
30 // Methods
31 //------------------------------------------------------------------------------------------------------------
32
33         /**
34         * Registers a command in the vector with no verification, is should be well constructed
35         * @param theCommand The command to register
36         */
37         void registerCommand(CommandObject * theCommand);
38
39         /*
40         * Gets the -ACTUAL- command text 
41         * @return
42         */
43         //std::string getActualCommandText();
44
45         /*
46         * Gets the -LAST- command text 
47         * @return
48         */
49         //std::string getLastCommandText();
50
51         /*
52         * Deletes all the registered actions and reinitialize the -ACTUAL- and  -LAST- iterators
53         */
54         void clearActions();
55
56         /*
57         * Moves to the the previous position the -ACTUAL- iterator
58         * @return Indicates true if it was done
59         */
60         bool moveBack_Actual();
61
62         /*
63         * Moves to the the next position the -ACTUAL- iterator
64         * @return Indicates true if it was done
65         */
66         bool moveForward_Actual();
67
68         /*
69         * Moves to the the previous position the -LAST- iterator
70         * @return Indicates true if it was done
71         */
72         bool moveBack_Last();
73
74         /*
75         * Moves to the the next position the -LAST- iterator
76         * @return Indicates true if it was done
77         */
78         bool moveForward_Last();
79
80         /*
81         * Indicates if the -LAST- iterator has a next action or not
82         * @return Returns true if it has
83         */
84         bool hasLastNext();
85
86         /*
87         * Indicates if the -ACTUAL- iterator has a next action or not
88         * @return Returns true if it has
89         */
90         bool hasActualNext();
91
92         /*
93         * Indicates if the -LAST- iterator has a previous action or not
94         * @return Returns true if it has
95         */
96         bool hasLastPrevious();
97
98         /*
99         * Indicates if the -ACTUAL- iterator has a previous action or not
100         * @return Returns true if it has
101         */
102         bool hasActualPrevious();
103
104         /*
105         * Puts to point the -ACTUAL- iterator up to the -LAST-  iterator.
106         */
107         void levelActualToLast();
108
109         /*
110         * Puts to point the -LAST- iterator up to the -ACTUAL- iterator and erases automatically the actions after the 
111         * referenced last and the end of the registered actions if nothing is given by parameter.       
112         */
113         void levelLastToActual(bool clearingAfterLast = true);
114
115         /*
116         * Clear all the elements in the vector bettween the -LAST- iterator and the end of the vector
117         */
118         void clearAll_afterLast();
119
120         /*
121         * Clear all the elements in the vector bettween the -ACTUAL- iterator and the start of the vector       
122         */
123         void clearAll_beforeActual();
124
125         /**
126         * Indicates if there are actions in the vector of not
127         * @return Returns true is there are not registered actions      
128         */
129         bool isEmpty();
130
131         /**
132         * Indicates the quantity of actions that are registered
133         * @return Returns the total amount of registered actions in the vector
134         */
135         int getCommandsCount();
136
137         /*
138         * Gets the -ACTUAL-  iterator information data pointer
139         * @return The pointer to the referenced object by the -ACTUAL- iterator
140         */
141         CommandObject * getActual_Pointer();
142
143         /*
144         * Gets the -LAST-  iterator information data pointer
145         * @return The pointer to the referenced object by the -LAST- iterator
146         */
147         CommandObject * getLast_Pointer();
148
149         /*
150         * Gets the command at the given position 
151         * @return The pointer to the referenced object by the position
152         */
153         CommandObject * getCommandAt(int position);
154
155         /*
156         * Gets the index of the actualAction in the vector
157         * @return actualIndexToExec Is the corresponding index
158         */
159         int getActualIndex();
160
161         /*
162         * Gets the index of the lasAction in the vector
163         * @return lasAction Is the corresponding index
164         */
165         int getLasIndex();
166
167         /*
168         * Sets the index of the actualAction in the vector
169         * @param newActualIndex Is the corresponding index
170         */
171         void setActualIndex(int newActualIndex);
172
173         /*
174         * Sets the index of the lasAction in the vector
175         * @param newLasIndex Is the corresponding index
176         */
177         void setLasIndex(int newLasIndex);
178
179         /*
180         * Gets the registered commands vector size
181         * @return Returns the vector size
182         */
183         int getRegistereCommandsCount();
184
185         /*
186         * Gets the total registered commands 
187         * @return Returns the total of commands
188         */
189         int getTotalCommandsCount();
190
191
192         
193
194 //------------------------------------------------------------------------------------------------------------
195 // Constants
196 //------------------------------------------------------------------------------------------------------------
197
198 private:        
199 //------------------------------------------------------------------------------------------------------------
200 // Attributes
201 //------------------------------------------------------------------------------------------------------------
202         
203         /*
204         * Represents the actions successfully registered 
205         */
206         std::vector<CommandObject*> registeredActions;
207         
208         /*
209         * Represents the index to the actual action to execute at the registered actions vector
210         */
211         //std::vector <CommandObject*>::iterator actualAction;
212         int actualIndexToExec;
213         
214         /*
215         * Represents the index to the last action executed at the registered actions vector
216         */
217         //std::vector <CommandObject*>::iterator lastAction;   
218         int lastAction;   
219
220 };
221 #endif