#pragma once
#include "../QTreeWidgetItemCustom.h"
#include <QtCore/QString>
#include <Scheduler/Scheduler.h>
//#include <DecisionMaking/Layer1Reactive/Layer1FSM/Behaviors/Behavior.h>
//#include <DecisionMaking/Layer2Actions/Interface/Actions/TacticalAction.h>

class TaskWrapper
{
public:
  class QTreeWidgetItemTask : public QTreeWidgetItemCustom<size_t>
  {
  public:
    QTreeWidgetItemTask(QTreeWidget *view, const void* key) : QTreeWidgetItemCustom<size_t>(view, key) {}
    QTreeWidgetItemTask(QTreeWidgetItem *item, const void* key) : QTreeWidgetItemCustom<size_t>(item, key) {}
  };

  TaskWrapper(const SchedulerTask* task)
    : m_key(task)
    , m_name(QString::fromStdString(toString(task)))
    , m_priority(task->getPriority())
    , m_executionFrame(task->getExecutionFrame())
    , m_period(task->getPeriod())
  {
  }

  size_t getExecutionFrame() const
  {
    return m_executionFrame;
  }

  virtual void display(QTreeWidget* parent, size_t snapshotFrame) const
  {
    QTreeWidgetItemTask* item = new QTreeWidgetItemTask(parent, m_key);
    displayIn(item, snapshotFrame);
  }

  void display(QTreeWidgetItem* parent, size_t snapshotFrame) const
  {
    QTreeWidgetItemTask* item = new QTreeWidgetItemTask(parent, m_key);
    displayIn(item, snapshotFrame);
  }

protected:
  void displayIn(QTreeWidgetItemTask* item, size_t snapshotFrame) const;

  const void* const m_key;
  const QString m_name;
  const unsigned int m_priority;
  const size_t m_executionFrame;
  const size_t m_period;
};
