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