]> Creatis software - creaEnvironment.git/blob - lib/kernel_Environment/InstantHandler.h
053ea9a1b6063f28895b77a99984c49ae4bdd84c
[creaEnvironment.git] / lib / kernel_Environment / InstantHandler.h
1 /*=========================================================================
2
3   Program:  instantHandler
4   Module:    $RCSfile: InstantHandler.h,v $
5   Language:  C++
6   Date:      $Date: 2008/10/31 15:08:40 $
7   Version:   $Revision: 1.1 $
8   Objective: Handles the change of instant among the concept already inscribed
9   Authot:       Monica Maria Lozano Romero
10
11   Copyright: (c) 2007
12   License:
13
14      This software is distributed WITHOUT ANY WARRANTY; without even
15      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16      PURPOSE.  See the above copyright notice for more information.
17
18
19 =========================================================================*/
20
21
22 //      MACRO
23 #ifndef __INSTANTHANDLER_H_INCLUDED__
24 #define __INSTANTHANDLER_H_INCLUDED__
25
26 // SYSTEM INCLUDES
27
28 #include <iostream>
29 #include <map>
30 #include <vector>
31 #include <string>
32
33 // PROJECT INCLUDES
34
35 #include "SomeEnvironment.h"
36 #include "ConceptInstantHandler.h"
37 #include "ViewerNDimensionsException.h"
38
39 // LOCAL INCLUDES
40
41 // FORWARD REFERENCES
42
43
44
45 /*
46 *       COMMENT
47 *       @param
48 *       @return
49 */
50
51 template <class P>
52
53 class InstantHandler
54         {
55                                 public:
56                                                 //==========    CONSTANTS =======
57                                                 
58                                                 //====== LIFECYCLE ========
59                                                 InstantHandler(SomeEnvironment<P>* environment)throw (ViewerNDimensionsException);
60                                                 ~InstantHandler();
61                                                                                                         
62                                                 //====== OPERATIONS =======
63                                                 
64                                                 /*
65                                                 *       Adds a concept to handled in the instant, it means, when 
66                                                 *       the next instant is used we are going to change this concepts in the instant
67                                                 *       PRECONDITION
68                                                 *       the calls to this functions are made in order of position, where the last position (it means
69                                                 *       the higher position defined) is the concept thats is going to handled the real time
70                                                 *       THE LAST POSITION HANDLEDS THE REAL TIME DOESNT MATTER THE CONCEPT
71                                                 *       EXAMPLE
72                                                 *       The user wants to reproduce doctors, pacients and time, and positions given are:
73                                                 *       0=reproduce doctors, 1= reproduce pacients, 2= time, then  1,2 are going to be reproduced
74                                                 *       by PLUS PLUS, and time by REAL TIME
75                                                 *       @param nameConcept, name of the concept
76                                                 *       @param mode, mode of change
77                                                 *       @param position, position of reproduction
78                                                 *       @return true if succesful, false otherwise
79                                                 */
80                                                 bool addConceptToHandled(std::string nameConcept,int mode,int position)throw (ViewerNDimensionsException);
81                                                 
82                                                 
83                                                 /*
84                                                 *       Next instant of the concepts to change
85                                                 *       @param 
86                                                 *       @return
87                                                 */
88                                                 void nextInstant()throw (ViewerNDimensionsException);
89
90                                                 
91                                                 /*
92                                                 *       Previous instant of the actual concept
93                                                 *       @param 
94                                                 *       @return
95                                                 */
96                                                 void previousInstant()throw (ViewerNDimensionsException);
97                                                 
98                                                 /*
99                                                 * Removes all the concept handled
100                                                 */
101                                                 void removeAllConcepts();
102                                                 
103                                                 /*
104                                                 *       Removes the concept with the name given
105                                                 *       @param nameConcept, name of the concept to remove
106                                                 *       WARNING the user know wich concept is erasing, also knows the
107                                                 *       mode of other concepts, if the user is deleting the concept that
108                                                 *       handled the real time, should change the mode to other concept that exist
109                                                 */
110                                                 void removeConceptToHandled(std::string nameConcept);
111
112                                                 /*
113                                                 * sets all the concept to handled in 0
114                                                 */
115                                                 void resetConceptsHandled();
116                                                 
117                                                 /*
118                                                 * Pause
119                                                 */
120                                                 //void pause();
121                                                 
122                                                 //====== INQUIRY =========
123                                                 
124                                                 /*
125                                                 * get the actual instant for the concept identified by the name
126                                                 */
127                                                 Instant* getActualInstant()throw (ViewerNDimensionsException);
128                                                 
129                                                 
130                                                 /*
131                                                 * If the actual concept has next instant, it means, if the index of the concept
132                                                 * in the  instant is less that the maximum value
133                                                 * @return true if IS NOT in the maximum, false otherwise 
134                                                 */
135                                                 bool hasNextInstant();                  
136                                                 
137                                                 /*
138                                                 * If the concept has previous instant, it means, if the index of the concept
139                                                 * in the  instant is positive
140                                                 * @return true if IS NOT in zero, false otherwise 
141                                                 */
142                                                 bool hasPreviousInstant();
143                                                 
144                                                 /*
145                                                 * returns the number con conceptsToHandled
146                                                 */
147                                                 int getSizeConceptsToChange();
148
149                                                 /*
150                                                 * returns the number of possibles instants of the handler
151                                                 * it depends of the concepts added in conceptsTochange
152                                                 */
153                                                 int getNumOfInstants();
154                                                 
155                                                 /*
156                                                 *       Returns the names of the concepts handled and its modes
157                                                 *       DEPRECATED
158                                                 */
159                                                 void getConceptsInfo(std::vector<std::string>& namesConcepts,std::vector<int>& modes);
160                                                 /*
161                                                 *       Returns the name of the concept that handled the real time
162                                                 *       DEPRECATED
163                                                 */
164                                                 void getTimeConcept(std::string& nameConcept);
165                                                 //====== ACCESS ==========
166                                                 /*
167                                                 *       Sets the environment that is going to be handled
168                                                 *       @param environment, a pointer to the environmen
169                                                 *       @return
170                                                 */
171                                                 void setEnvironment(SomeEnvironment<P>* environment);
172                                                 /*
173                                                 *       Sets the actual instant of the instant handler
174                                                 *       @param instant
175                                                 */
176                                                 void setActualInstant(Instant* instant);
177                                                 /*
178                                                 *       Sets the  time of reproduction to the concept
179                                                 *       that depends of the real time of the reproduction
180                                                 *       (miliseconds)
181                                                 *       @param  time
182                                                 */
183                                                 void setTimeReproduction(double time);
184                                                 /*
185                                                 *       Sets the actual time of the reproduction,
186                                                 *       is the real time (seconds)
187                                                 *       @param actualTime
188                                                 */
189                                                 void setActualTime(double actualTime);
190                                                 /*
191                                                 * Set the mode of a concept that's being handled
192                                                 */
193                                                 void setModeOfConcept(std::string nameConcept,int mode);
194                                                 /*
195                                                 * Set handler
196                                                 */
197                                                 void set();
198                                                  /*
199                                                 * Set the increase Value for changing the instant
200                                                 */
201                                                 void setIncreaseValue(int increase);
202                                                 /*
203                                                 * Set the decrease Value for changing the instant
204                                                 */
205                                                 void setDecreaseValue(int decrease);
206                                                 
207                                                 
208                                                 
209                                 private:
210                                         
211                                         //======= ATTRIBUTES=======
212                                         
213                                         /*
214                                         *       actual instant of the InstantHandler
215                                         */
216                                         Instant*        actualInstant;
217
218                                         /*
219                                         *       Environment that's being handled
220                                         */
221                                         SomeEnvironment<P>* environment;
222
223                                         /*
224                                         * concepts to change in the actual instant
225                                         */
226                                         std::vector<ConceptInstantHandler*> conceptsToChange;
227                                         
228                                         /*
229                                         *       actual concept being manipulated
230                                         */
231                                         ConceptInstantHandler* actualConcept;
232
233                                         /*
234                                         * if the actual concept has next
235                                         */
236                                         bool hasNext;
237                                         /*
238                                         * if the actual concept has previous
239                                         */
240                                         bool hasPrevious;
241
242                                         /*
243                                         *       actual time of the reproduction
244                                         */
245                                         double actualTime;
246
247                                         /*
248                                         * time of pause
249                                         */
250                                         double pauseTime;
251
252                                         //====== PRIVATE METHODS=========
253                                         /*
254                                         *  Sets if the instant has next or not
255                                         */
256                                                 
257                                         void setHasNext();
258                                         /*
259                                         *  Sets if the instant has previous or not
260                                         */
261                                                 
262                                         void setHasPrevious();
263                                         /*
264                                         * actualize the actual index of the concepts handled
265                                         */
266                                         void setConceptsToChange();
267                                         /*
268                                         *       resets all the next concepts to zero
269                                         */
270                                         void resetNextConcepts();
271                                         /*
272                                         *       Sets the next index of concepts to handled to the maximum value
273                                         */
274                                         void setNextConcepts();
275                                         /*
276                                         * this method locates the new actual concept
277                                         * @param next, if has to locate the actual concept to the first concept that has next
278                                         * next=true, else search for the first concept that has previous
279                                         */
280                                         void toLocateActualConcept(bool next);
281
282                                                         
283         };
284 //include the implementation of the template
285 #include "InstantHandler_Txx.h"
286 #endif