]> Creatis software - creaEnvironment.git/blobdiff - lib/kernel_Environment/ConceptInstantHandler.cxx
reindent
[creaEnvironment.git] / lib / kernel_Environment / ConceptInstantHandler.cxx
index 91f5fa7b3a10154fb15b11e0807ac40d6c92909e..61fd0b6aef0d193b7301e6a881d8c2f563465ce3 100644 (file)
@@ -1,4 +1,4 @@
-                                               
+   
 
 // SYSTEM INCLUDES
 #include <iostream>
 
 // FORWARD REFERENCES
 
-                                               
+   
 
-                                               
-                                               //====== LIFECYCLE ========
-                                               ConceptInstantHandler::ConceptInstantHandler(std::string name,int mode,int positionInReproduction)
-                                                       {
-                                                                       this->name=name;
-                                                                       this->mode=mode;
-                                                                       this->positionInReproduction=positionInReproduction;
-                                                                       this->increaseValue=1;
-                                                                       this->decreaseValue=1;
-                                                                       this->actualIndex=0;
-                                                                       this->scaleTime=0;
-                                                                       //timeReproduction=intervalTimer*maximumValue
-                                                                       this->timeReproduction=100;
-                                                                       this->actualTime=0;
-                                                                       this->initialTime=0;
-                                                       }
-                                               ConceptInstantHandler::~ConceptInstantHandler()
-                                                       {
-                                                               name.clear();
-                                                       }
-                                               //====== OPERATIONS =======
-                                               /*
-                                               * change the actual index by increasing
-                                               * the index until the maximum by the increaseValue
-                                               */
-                                               void ConceptInstantHandler::nextIndex()
-                                                       {
-                                                               
-                                                               //just plus plus
-                                                               if(mode==PLUS_PLUS)
-                                                                               actualIndex+=increaseValue;
-                                                               //time scale
-                                                               else
-                                                                       {
-                                                                               time_t seconds=time(NULL);
-                                                                               if(initialTime==0)                                                                      
-                                                                                       initialTime=seconds*1000;
-                                                                               int time=seconds*1000;
-                                                                               actualTime=time-initialTime;                    
-                                                                               actualIndex=(int)actualTime*scaleTime;
-                                                                       }
-                                                                       
+   
+  //====== LIFECYCLE ========
+   ConceptInstantHandler::ConceptInstantHandler(std::string name,int mode,int positionInReproduction)
+   {
+       this->name=name;
+       this->mode=mode;
+       this->positionInReproduction=positionInReproduction;
+       this->increaseValue=1;
+       this->decreaseValue=1;
+       this->actualIndex=0;
+       this->scaleTime=0;
+       //timeReproduction=intervalTimer*maximumValue
+       this->timeReproduction=100;
+       this->actualTime=0;
+       this->initialTime=0;
+   }
+   
+   ConceptInstantHandler::~ConceptInstantHandler()
+   {
+      name.clear();
+   }
+   //====== OPERATIONS =======
+   /*
+   * change the actual index by increasing
+   * the index until the maximum by the increaseValue
+   */
+   void ConceptInstantHandler::nextIndex()
+   {
+      
+      //just plus plus
+      if(mode==PLUS_PLUS)
+         actualIndex+=increaseValue;
+      //time scale
+      else
+      {
+         time_t seconds=time(NULL);
+         if(initialTime==0)            
+               initialTime=seconds*1000;
+         int time=seconds*1000;
+         actualTime=time-initialTime;                  
+         actualIndex=(int)actualTime*scaleTime;
+      }
+       
 
-                                                               if(actualIndex>=maximumIndex)
-                                                                               actualIndex=maximumIndex-1;
-       
-                                                                       
-                                                       }
-                                               /*
-                                               * change the actual index by decreasing
-                                               * the index until zero  by the decreaseValue
-                                               */
-                                               void ConceptInstantHandler::previousIndex()
-                                                       {
-                                                               //just plus plus
-                                                               if(mode==PLUS_PLUS)
-                                                                       actualIndex-=decreaseValue;
-                                                               
-                                                               else
-                                                                       actualIndex=(int)actualTime*scaleTime;
-                                                               
-                                                               if(actualIndex<0)
-                                                                               actualIndex=0;
-                                                                       
-                                                       }
-                                               
-                                               //====== INQUIRY =========
-                                               /*
-                                               *       @return name
-                                               */
-                                               std::string ConceptInstantHandler::getName()
-                                                       {
-                                                               return this->name;
-                                                       }
-                                               /*
-                                               *       @return PositionInReproduction
-                                               */
-                                               int ConceptInstantHandler::getPosition()
-                                                       {
-                                                               return this->positionInReproduction;
-                                                       }
-                                               /*
-                                               *       @return mode
-                                               */
-                                               int ConceptInstantHandler::getMode()
-                                                       {
-                                                               return this->mode;
-                                                       }
-                                               /*
-                                               *       @return increaseValue
-                                               */
-                                               int ConceptInstantHandler::getIncreaseValue()
-                                                       {
-                                                               return this->increaseValue;
-                                                       }
-                                                       
-                                               /*
-                                               *       @return decreaseValue
-                                               */
-                                               int ConceptInstantHandler::getDecreaseValue()
-                                                       {
-                                                               return this->decreaseValue;
-                                                       }
-                                               
-                                               /*
-                                               * @return indexInInstant
-                                               */
-                                               int ConceptInstantHandler::getIndexInInstant()
-                                                       {
-                                                               return this->indexInInstant;
-                                                       }
-                                               /*
-                                               *       @return actualIndex
-                                               */
-                                               int ConceptInstantHandler::geActualIndex()
-                                                       {       
-                                                               return actualIndex;
-                                                       }
-                                               /*
-                                               *       @return maximumIndex
-                                               */
-                                               
-                                               int ConceptInstantHandler::getMaximumIndex()
-                                                       {
-                                                       return maximumIndex;
-                                                       }
-                                               /*
-                                               *       @return timeReproduction
-                                               */
-                                               double ConceptInstantHandler::getTimeReproduction()
-                                                       {
-                                                               return timeReproduction;
-                                                       }
-                                               /*
-                                               *       @return scaleTime
-                                               */
-                                               double ConceptInstantHandler::getScale()
-                                                       {
-                                                               return scaleTime;
-                                                       }
-                                               /*
-                                               * if the actual index is not the maximum index
-                                               */
-                                               bool ConceptInstantHandler::hasNextIndex()
-                                                       {
-                                                               if(actualIndex<maximumIndex-1)
-                                                                        return true;
-                                                               else return false;
-                                                       }
-                                               /*
-                                               * if the actual index is not zero
-                                               */
-                                               bool ConceptInstantHandler::hasPreviousIndex()
-                                                       {
-                                                               if(actualIndex>0)
-                                                                        return true;
-                                                               else return false;
-                                                       }
-                                               /*
-                                               * Get initial time
-                                               */
-                                               double ConceptInstantHandler::getInitialTime()
-                                                       {
-                                                               return this->initialTime;
-                                                       }
+      if(actualIndex>=maximumIndex)
+         actualIndex=maximumIndex-1;           
+   }
+   /*
+   * change the actual index by decreasing
+   * the index until zero  by the decreaseValue
+   */
+   void ConceptInstantHandler::previousIndex()
+   {
+      //just plus plus
+      if(mode==PLUS_PLUS)
+       actualIndex-=decreaseValue;
+      
+      else
+       actualIndex=(int)actualTime*scaleTime;
+      
+      if(actualIndex<0)
+         actualIndex=0;
+       
+   }
+   
+   //====== INQUIRY =========
+   /*
+   *   @return name
+   */
+   std::string ConceptInstantHandler::getName()
+   {
+      return this->name;
+   }
+   /*
+   *   @return PositionInReproduction
+   */
+   int ConceptInstantHandler::getPosition()
+   {
+      return this->positionInReproduction;
+   }
+   /*
+   *   @return mode
+   */
+   int ConceptInstantHandler::getMode()
+   {
+      return this->mode;
+   }
+   /*
+   *   @return increaseValue
+   */
+   int ConceptInstantHandler::getIncreaseValue()
+   {
+      return this->increaseValue;
+   }
+       
+   /*
+   *   @return decreaseValue
+   */
+   int ConceptInstantHandler::getDecreaseValue()
+   {
+      return this->decreaseValue;
+   }
+   
+   /*
+   * @return indexInInstant
+   */
+   int ConceptInstantHandler::getIndexInInstant()
+   {
+      return this->indexInInstant;
+   }
+   /*
+   *   @return actualIndex
+   */
+   int ConceptInstantHandler::geActualIndex()
+   {   
+      return actualIndex;
+   }
+   /*
+   *   @return maximumIndex
+   */
+   
+   int ConceptInstantHandler::getMaximumIndex()
+   {
+       return maximumIndex;
+   }
+   /*
+   *   @return timeReproduction
+   */
+   double ConceptInstantHandler::getTimeReproduction()
+   {
+      return timeReproduction;
+   }
+   /*
+   *   @return scaleTime
+   */
+   double ConceptInstantHandler::getScale()
+   {
+      return scaleTime;
+   }
+   /*
+   * if the actual index is not the maximum index
+   */
+   bool ConceptInstantHandler::hasNextIndex()
+   {
+      if(actualIndex<maximumIndex-1)
+        return true;
+      else return false;
+   }
+   /*
+   * if the actual index is not zero
+   */
+   bool ConceptInstantHandler::hasPreviousIndex()
+   {
+      if(actualIndex>0)
+        return true;
+      else return false;
+   }
+   /*
+   * Get initial time
+   */
+   double ConceptInstantHandler::getInitialTime()
+   {
+      return this->initialTime;
+   }
 
-                                               //====== ACCESS ==========
-                                               /*
-                                               *       Sets the name of the concept
-                                               *       @param name, new name
-                                               */
-                                               void ConceptInstantHandler::setName(std::string name)
-                                                       {
-                                                               this->name=name;
-                                                       }
-                                               /*
-                                               *       Sets the position of the concept
-                                               *       @param position, position
-                                               */
-                                               void ConceptInstantHandler::setPosition(int position)
-                                                       {
-                                                               this->positionInReproduction=position;
-                                                       }
-                                               /*
-                                               *       Sets the mode of the concept
-                                               *       @param mode, new mode= REAL_TIME or
-                                               *       PLUS_PLUS
-                                               */
-                                               void ConceptInstantHandler::setMode(int mode)
-                                                       {
-                                                               if(this->mode==PLUS_PLUS)
-                                                                       {
-                                                                               time_t seconds=time(NULL);
-                                                                               int time=seconds*1000;  
-                                                                               actualTime=actualIndex/scaleTime;
-                                                                               initialTime=time-actualTime;
-                                                                       }
-                                                               this->mode=mode;
-                                                       }
-                                               /*
-                                               *       Set Increase of the instant
-                                               */
-                                               void ConceptInstantHandler::setIncreaseValue(int increaseValue)
-                                                       {
-                                                               this->increaseValue=increaseValue;
-                                                       }
+   //====== ACCESS ==========
+   /*
+   *   Sets the name of the concept
+   *   @param name, new name
+   */
+   void ConceptInstantHandler::setName(std::string name)
+   {
+      this->name=name;
+   }
+   /*
+   *   Sets the position of the concept
+   *   @param position, position
+   */
+   void ConceptInstantHandler::setPosition(int position)
+   {
+      this->positionInReproduction=position;
+   }
+   /*
+   *   Sets the mode of the concept
+   *   @param mode, new mode= REAL_TIME or
+   *   PLUS_PLUS
+   */
+   void ConceptInstantHandler::setMode(int mode)
+   {
+      if(this->mode==PLUS_PLUS)
+      {
+         time_t seconds=time(NULL);
+         int time=seconds*1000;        
+         actualTime=actualIndex/scaleTime;
+         initialTime=time-actualTime;
+      }
+      this->mode=mode;
+   }
+   /*
+   *   Set Increase of the instant
+   */
+   void ConceptInstantHandler::setIncreaseValue(int increaseValue)
+   {
+      this->increaseValue=increaseValue;
+   }
 
-                                               /*
-                                               *       Set decrease of the instant
-                                               */
-                                               void ConceptInstantHandler::setDecreaseValue(int decreaseValue)
-                                                       {
-                                                               this->decreaseValue=decreaseValue;
-                                                       }
-                                               /*
-                                               *  Sets  the index of the concept in the instant
-                                               *  @param indexInInstant
-                                               */
-                                               void ConceptInstantHandler::setIndexInInstant(int indexInInstant)
-                                                       {
-                                                               this->indexInInstant=indexInInstant;
-                                                       }
-                                               /*
-                                               *  Sets  sets the maximum value
-                                               *  @param maximumIndex
-                                               */
-                                               void ConceptInstantHandler::setMaximumIndex(int maximumIndex)
-                                                       {
-                                                               this->maximumIndex=maximumIndex;
-                                                               scaleTime=(maximumIndex-1)/timeReproduction;
-                                                       }
+   /*
+   *   Set decrease of the instant
+   */
+   void ConceptInstantHandler::setDecreaseValue(int decreaseValue)
+   {
+      this->decreaseValue=decreaseValue;
+   }
+   /*
+   *  Sets  the index of the concept in the instant
+   *  @param indexInInstant
+   */
+   void ConceptInstantHandler::setIndexInInstant(int indexInInstant)
+   {
+      this->indexInInstant=indexInInstant;
+   }
+   /*
+   *  Sets  sets the maximum value
+   *  @param maximumIndex
+   */
+   void ConceptInstantHandler::setMaximumIndex(int maximumIndex)
+   {
+      this->maximumIndex=maximumIndex;
+      scaleTime=(maximumIndex-1)/timeReproduction;
+   }
 
-                                               /*
-                                               * set the actualIndex
-                                               */
-                                               void ConceptInstantHandler::setActualIndex(int index)
-                                                       {
-                                                               if(index<=maximumIndex-1)
-                                                                       actualIndex=index;
-                                                               //TODO else thow exception of out of bounds
-                                                       }
-                                               /*
-                                               * set the timeReproduction
-                                               * @param timeReproduction
-                                               */
-                                               void ConceptInstantHandler::setTimeReproduction(double time)
-                                                       {
-                                                               this->timeReproduction=(this->maximumIndex-1)*time;
-                                                               scaleTime=(maximumIndex-1)/timeReproduction;
-                                                       }
-                                               /*
-                                               * set the scaleTime
-                                               * @param scale
-                                               */
-                                               void ConceptInstantHandler::setScale(double scale)
-                                                       {
-                                                               this->scaleTime=scale;
-                                                       }
-                                               /*
-                                               * set the actualTime
-                                               * @param actualTime
-                                               */
-                                               void ConceptInstantHandler::setActualTime(double actualTime)
-                                                       {
-                                                               this->actualTime=actualTime;
-                                                       }
-                                               /*
-                                               *       reset the initial time
-                                               */
-                                               void ConceptInstantHandler::resetInitialTime()
-                                                       {
-                                                               this->initialTime=0;
-                                                       }
-                                               /*
-                                               * Sets the initial time
-                                               */
-                                               void ConceptInstantHandler::setInitialTime(double time)
-                                                       {
-                                                               this->initialTime=time;
-                                                       }
+   /*
+   * set the actualIndex
+   */
+   void ConceptInstantHandler::setActualIndex(int index)
+   {
+      if(index<=maximumIndex-1)
+       actualIndex=index;
+      //TODO else thow exception of out of bounds
+   }
+   /*
+   * set the timeReproduction
+   * @param timeReproduction
+   */
+   void ConceptInstantHandler::setTimeReproduction(double time)
+   {
+      this->timeReproduction=(this->maximumIndex-1)*time;
+      scaleTime=(maximumIndex-1)/timeReproduction;
+   }
+   /*
+   * set the scaleTime
+   * @param scale
+   */
+   void ConceptInstantHandler::setScale(double scale)
+   {
+      this->scaleTime=scale;
+   }
+   /*
+   * set the actualTime
+   * @param actualTime
+   */
+   void ConceptInstantHandler::setActualTime(double actualTime)
+   {
+      this->actualTime=actualTime;
+   }
+   /*
+   *   reset the initial time
+   */
+   void ConceptInstantHandler::resetInitialTime()
+   {
+      this->initialTime=0;
+   }
+   /*
+   * Sets the initial time
+   */
+   void ConceptInstantHandler::setInitialTime(double time)
+   {
+      this->initialTime=time;
+   }
 
-
-
-