15 #include "ConceptInstantHandler.h"
22 //====== LIFECYCLE ========
23 ConceptInstantHandler::ConceptInstantHandler(std::string name,int mode,int positionInReproduction)
27 this->positionInReproduction=positionInReproduction;
28 this->increaseValue=1;
29 this->decreaseValue=1;
32 //timeReproduction=intervalTimer*maximumValue
33 this->timeReproduction=100;
38 ConceptInstantHandler::~ConceptInstantHandler()
42 //====== OPERATIONS =======
44 * change the actual index by increasing
45 * the index until the maximum by the increaseValue
47 void ConceptInstantHandler::nextIndex()
52 actualIndex+=increaseValue;
56 time_t seconds=time(NULL);
58 initialTime=seconds*1000;
59 int time=seconds*1000;
60 actualTime=time-initialTime;
61 actualIndex=(int)actualTime*scaleTime;
65 if(actualIndex>=maximumIndex)
66 actualIndex=maximumIndex-1;
69 * change the actual index by decreasing
70 * the index until zero by the decreaseValue
72 void ConceptInstantHandler::previousIndex()
76 actualIndex-=decreaseValue;
79 actualIndex=(int)actualTime*scaleTime;
86 //====== INQUIRY =========
90 std::string ConceptInstantHandler::getName()
95 * @return PositionInReproduction
97 int ConceptInstantHandler::getPosition()
99 return this->positionInReproduction;
104 int ConceptInstantHandler::getMode()
109 * @return increaseValue
111 int ConceptInstantHandler::getIncreaseValue()
113 return this->increaseValue;
117 * @return decreaseValue
119 int ConceptInstantHandler::getDecreaseValue()
121 return this->decreaseValue;
125 * @return indexInInstant
127 int ConceptInstantHandler::getIndexInInstant()
129 return this->indexInInstant;
132 * @return actualIndex
134 int ConceptInstantHandler::geActualIndex()
139 * @return maximumIndex
142 int ConceptInstantHandler::getMaximumIndex()
147 * @return timeReproduction
149 double ConceptInstantHandler::getTimeReproduction()
151 return timeReproduction;
156 double ConceptInstantHandler::getScale()
161 * if the actual index is not the maximum index
163 bool ConceptInstantHandler::hasNextIndex()
165 if(actualIndex<maximumIndex-1)
170 * if the actual index is not zero
172 bool ConceptInstantHandler::hasPreviousIndex()
181 double ConceptInstantHandler::getInitialTime()
183 return this->initialTime;
186 //====== ACCESS ==========
188 * Sets the name of the concept
189 * @param name, new name
191 void ConceptInstantHandler::setName(std::string name)
196 * Sets the position of the concept
197 * @param position, position
199 void ConceptInstantHandler::setPosition(int position)
201 this->positionInReproduction=position;
204 * Sets the mode of the concept
205 * @param mode, new mode= REAL_TIME or
208 void ConceptInstantHandler::setMode(int mode)
210 if(this->mode==PLUS_PLUS)
212 time_t seconds=time(NULL);
213 int time=seconds*1000;
214 actualTime=actualIndex/scaleTime;
215 initialTime=time-actualTime;
220 * Set Increase of the instant
222 void ConceptInstantHandler::setIncreaseValue(int increaseValue)
224 this->increaseValue=increaseValue;
228 * Set decrease of the instant
230 void ConceptInstantHandler::setDecreaseValue(int decreaseValue)
232 this->decreaseValue=decreaseValue;
235 * Sets the index of the concept in the instant
236 * @param indexInInstant
238 void ConceptInstantHandler::setIndexInInstant(int indexInInstant)
240 this->indexInInstant=indexInInstant;
243 * Sets sets the maximum value
244 * @param maximumIndex
246 void ConceptInstantHandler::setMaximumIndex(int maximumIndex)
248 this->maximumIndex=maximumIndex;
249 scaleTime=(maximumIndex-1)/timeReproduction;
253 * set the actualIndex
255 void ConceptInstantHandler::setActualIndex(int index)
257 if(index<=maximumIndex-1)
259 //TODO else thow exception of out of bounds
262 * set the timeReproduction
263 * @param timeReproduction
265 void ConceptInstantHandler::setTimeReproduction(double time)
267 this->timeReproduction=(this->maximumIndex-1)*time;
268 scaleTime=(maximumIndex-1)/timeReproduction;
274 void ConceptInstantHandler::setScale(double scale)
276 this->scaleTime=scale;
282 void ConceptInstantHandler::setActualTime(double actualTime)
284 this->actualTime=actualTime;
287 * reset the initial time
289 void ConceptInstantHandler::resetInitialTime()
294 * Sets the initial time
296 void ConceptInstantHandler::setInitialTime(double time)
298 this->initialTime=time;