#pragma once
#include "../../Utils/Process/PeriodicProcess.h"
#include "../InfluenceMap/InfluenceMap.h"

/**
 * @brief Process in charge of updating a specific influence map.
 * @tparam InfluenceType Type of influence.
 */
template <class InfluenceType>
class UpdateInfluenceMapProcess : public PeriodicProcess
{
public:
  /**
   * @brief Creates a new intance of UpdateInfluenceMapProcess.
   * @param parent The parent process (typically the PerceptualState itself).
   * @param influenceMap The influence map to update.
   * @param waitingTimeBeforeExecution The initial waiting time before execution (should not be necessary if we had some sort
   *                                   of flexible scheduleur).
   */
  UpdateInfluenceMapProcess(const Process* parent, InfluenceMapRef<InfluenceType>& influenceMap, size_t period, size_t waitingTimeBeforeExecution)
    : PeriodicProcess(parent, Scheduler::SCHEDULING_MEDIUM_PRIORITY, period, waitingTimeBeforeExecution)
    , m_influenceMap(influenceMap)
  {}
  /**
   * @brief Runs this process, which updates the influence map.
   */
  virtual void run()
  {
    m_influenceMap.update();
  }
protected:
  void _output(std::ostream& out) const
  {
    out << "Update " << m_influenceMap;
  }

  /**
   * @brief The influence map to update.
   */
  InfluenceMapRef<InfluenceType>& m_influenceMap;
};
