#pragma once

#include <vector>
#include <string>
#include "DataEntry.hpp"

/*
   Class: DataGroup

     Implements a grouping of data entries with a common group name.
*/
class DataGroup {
  public:
    /*
       Constructor: DataGroup

         Initializes the object.

       Parameters:

         sName - Name of the data group.
    */
    DataGroup(std::string sName);

    /*
       Constructor: DataGroup

         Initializes the object by copying values from an existing data group. This is used to create data groups which only hold visible (not filtered) data entries.

       Parameters:

         pReferenceDataGroup - An existing data group to be copied.
    */
    DataGroup(DataGroup* pReferenceDataGroup);

    /*
       Destructor: ~DataGroup

         Releases all allocated resources. Data entries are not deleted if the copy constructor was used to initialize the object.
    */
    ~DataGroup();


    /*
       Function: AddDataEntry

         Adds the data entry to the data group.

       Parameters:

         pDataEntry - The data entry to be added.
    */
    void AddDataEntry(DataEntry* pDataEntry);

    /*
       Function: GetDataEntries

         Returns a vector containing all data entries of the data group.

       Returns:

         A vector containing all data entries of the data group.
    */
    std::vector<DataEntry*> GetDataEntries();

    /*
       Function: GetReferenceDataGroup

         Returns the reference data group of this data group. If the copy constructor was used to initialize the object, the original data group is returned, else NULL.

       Returns:

         Returns the reference data group of this data group if present, else NULL.
    */
    DataGroup* GetReferenceDataGroup();

    /*
       Function: GetName

         Returns the name of the data group.

       Returns:

         The name of the data group.
    */
    std::string GetName();

    /*
       Function: GetHighestValue

         Returns the highest value among the data entries of the data group.

       Returns:

         The highest value among the data entries of the data group.
    */
    double GetHighestValue();

    /*
       Function: SumValues

         Returns the sum of all values of the data entries of the data group.

       Returns:

         The sum of all values of the data entries of the data group.
    */
    double SumValues();

    /*
       Function: GetSize

         Returns the number of data entries of the data group.

       Returns:

         The number of data entries of the data group.
    */
    int GetSize();

    /*
       Function: IsCopy

         Indicates if the copy constructor was used to initialize the data group.

       Returns:

         A boolean value indicating if the copy constructor was used to initialize the data group.
    */
    bool IsCopy();

  private:
    DataGroup* pReferenceDataGroup;
    bool bCopy;
    std::string sName;
    std::vector<DataEntry*> vDataEntries;
};