#pragma once

#include "CompoundTransition.hpp"

/*
   Class: ValueChangeTransition

     Implements a complex sequence of transitions that maps data entries of another data set to the data elements of the current chart, thus providing a value change between data sets.

     *Inherits* from <CompoundTransition>.
*/
class ValueChangeTransition: public CompoundTransition {
  public:
    /*
       Constructor: ValueChangeTransition

         Initializes the object by creating all transitions and intermediate objects.

       Parameters:

         pInitialChart - Pointer to the chart to be modified.
         pNewDataSet - Pointer to the data set of the new chart.
    */
    ValueChangeTransition(Chart* pInitialChart, DataSet* pNewDataSet);

    /*
       Destructor: ~ValueChangeTransition

         Releases all allocated resources.
    */
    ~ValueChangeTransition();


    /*
       Function: Update

         Updates the transition by executing the active child transition. *Inherited* from <Transition>.
    */
    void Update();

    /*
       Function: Draw

         Draws the transition by drawing the initial chart. *Inherited* from <CompoundTransition>.

       Parameters:

         pPainter - The QPainter object that shall be used for painting.
    */
    void Draw(QPainter* pPainter);

    /*
       Function: Complete

         Checks if all child transitions are completed. *Inherited* from <Transition>.

       Returns:

         A boolean value indicating if all child transitions are completed.
    */
    bool Complete();

    /*
       Function: GetActiveChart

         Returns the active chart of the transition. This is the active chart of the active transition if present, else the initial chart. *Inherited* from <CompoundTransition>.

       Returns:

         Returns the active chart of the transition.
    */
    Chart* GetActiveChart();

  private:
    /*
       Function: GetDataEntryByName

         Help function which searches for a data entry of the given name in the given vector of data entries and returns it if present, else NULL.

       Parameters:

         vDataEntries - A vector of data entries to be searched for the data entry.
         sName - Name of the data entry to be searched.

       Returns:

         The data entry of the searched name if present, else NULL.
    */
    DataEntry* GetDataEntryByName(std::vector<DataEntry*> vDataEntries, std::string sName);
};