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;
37 ConceptInstantHandler::~ConceptInstantHandler()
41 //====== OPERATIONS =======
43 * change the actual index by increasing
44 * the index until the maximum by the increaseValue
46 void ConceptInstantHandler::nextIndex()
51 actualIndex+=increaseValue;
55 time_t seconds=time(NULL);
57 initialTime=seconds*1000;
58 int time=seconds*1000;
59 actualTime=time-initialTime;
60 actualIndex=(int)actualTime*scaleTime;
64 if(actualIndex>=maximumIndex)
65 actualIndex=maximumIndex-1;
70 * change the actual index by decreasing
71 * the index until zero by the decreaseValue
73 void ConceptInstantHandler::previousIndex()
77 actualIndex-=decreaseValue;
80 actualIndex=(int)actualTime*scaleTime;
87 //====== INQUIRY =========
91 std::string ConceptInstantHandler::getName()
96 * @return PositionInReproduction
98 int ConceptInstantHandler::getPosition()
100 return this->positionInReproduction;
105 int ConceptInstantHandler::getMode()
110 * @return increaseValue
112 int ConceptInstantHandler::getIncreaseValue()
114 return this->increaseValue;
118 * @return decreaseValue
120 int ConceptInstantHandler::getDecreaseValue()
122 return this->decreaseValue;
126 * @return indexInInstant
128 int ConceptInstantHandler::getIndexInInstant()
130 return this->indexInInstant;
133 * @return actualIndex
135 int ConceptInstantHandler::geActualIndex()
140 * @return maximumIndex
143 int ConceptInstantHandler::getMaximumIndex()
148 * @return timeReproduction
150 double ConceptInstantHandler::getTimeReproduction()
152 return timeReproduction;
157 double ConceptInstantHandler::getScale()
162 * if the actual index is not the maximum index
164 bool ConceptInstantHandler::hasNextIndex()
166 if(actualIndex<maximumIndex-1)
171 * if the actual index is not zero
173 bool ConceptInstantHandler::hasPreviousIndex()
182 double ConceptInstantHandler::getInitialTime()
184 return this->initialTime;
187 //====== ACCESS ==========
189 * Sets the name of the concept
190 * @param name, new name
192 void ConceptInstantHandler::setName(std::string name)
197 * Sets the position of the concept
198 * @param position, position
200 void ConceptInstantHandler::setPosition(int position)
202 this->positionInReproduction=position;
205 * Sets the mode of the concept
206 * @param mode, new mode= REAL_TIME or
209 void ConceptInstantHandler::setMode(int mode)
211 if(this->mode==PLUS_PLUS)
213 time_t seconds=time(NULL);
214 int time=seconds*1000;
215 actualTime=actualIndex/scaleTime;
216 initialTime=time-actualTime;
221 * Set Increase of the instant
223 void ConceptInstantHandler::setIncreaseValue(int increaseValue)
225 this->increaseValue=increaseValue;
229 * Set decrease of the instant
231 void ConceptInstantHandler::setDecreaseValue(int decreaseValue)
233 this->decreaseValue=decreaseValue;
236 * Sets the index of the concept in the instant
237 * @param indexInInstant
239 void ConceptInstantHandler::setIndexInInstant(int indexInInstant)
241 this->indexInInstant=indexInInstant;
244 * Sets sets the maximum value
245 * @param maximumIndex
247 void ConceptInstantHandler::setMaximumIndex(int maximumIndex)
249 this->maximumIndex=maximumIndex;
250 scaleTime=(maximumIndex-1)/timeReproduction;
254 * set the actualIndex
256 void ConceptInstantHandler::setActualIndex(int index)
258 if(index<=maximumIndex-1)
260 //TODO else thow exception of out of bounds
263 * set the timeReproduction
264 * @param timeReproduction
266 void ConceptInstantHandler::setTimeReproduction(double time)
268 this->timeReproduction=(this->maximumIndex-1)*time;
269 scaleTime=(maximumIndex-1)/timeReproduction;
275 void ConceptInstantHandler::setScale(double scale)
277 this->scaleTime=scale;
283 void ConceptInstantHandler::setActualTime(double actualTime)
285 this->actualTime=actualTime;
288 * reset the initial time
290 void ConceptInstantHandler::resetInitialTime()
295 * Sets the initial time
297 void ConceptInstantHandler::setInitialTime(double time)
299 this->initialTime=time;