#pragma once
#include "../../../Utils/Component.h"
#include "ArbitratorUnitData.h"
#include <boost/iterator/transform_iterator.hpp>

class Layer1FSMUnitData : public ArbitratorUnitData
{
public:
  Layer1FSMUnitData(BWAPI::Unit* unit)
    : ArbitratorUnitData(unit)
    , UnitData(unit)
//#ifdef USE_SPAR_GUI
//    , m_behaviorTerminateEventHandler(*this)
//#endif
  {
  }

//#ifndef USE_SPAR_GUI
//
//  void addBehavior(UnitBehavior* behavior)
//  {
//    unused(behavior);
//  }
//
//#else
//
//protected:
//  struct BehaviorWrapper
//  {
//    BehaviorWrapper() {}
//    BehaviorWrapper(UnitBehavior* behavior)
//      : m_behavior(behavior) {}
//
//    UnitBehavior* m_behavior;
//    std::list<BehaviorWrapper>::iterator m_behaviorID;
//    UnitBehavior::OnTerminate::SubscriberID m_subscriberID;
//  };
//  struct extract_behavior : std::unary_function<BehaviorWrapper,const UnitBehavior*>
//  {
//    const UnitBehavior* operator()(const BehaviorWrapper& behaviorWrapper) const
//    {
//      return behaviorWrapper.m_behavior;
//    }
//  };
//
//public:
//  /**
//   * @brief Attachs a new behavior to this unit.
//   * @param behavior the new behavior.
//   */
//  void addBehavior(UnitBehavior* behavior)
//  {
//    std::list<BehaviorWrapper>::iterator behaviorID = m_behaviors.insert(m_behaviors.end(), BehaviorWrapper(behavior));
//    BehaviorWrapper& behaviorWrapper = *behaviorID;
//    behaviorWrapper.m_behaviorID = behaviorID;
//    behaviorWrapper.m_subscriberID = behavior->getTerminateEvent().subscribe(&m_behaviorTerminateEventHandler, &behaviorWrapper);
//  }
//
//  typedef boost::transform_iterator<extract_behavior, std::list<BehaviorWrapper>::const_iterator> behavior_iterator;
//  behavior_iterator behaviorsBegin()
//  {
//    return behavior_iterator(m_behaviors.begin());
//  }
//  behavior_iterator behaviorsEnd()
//  {
//    return behavior_iterator(m_behaviors.end());
//  }
//
//protected:
//  /**
//   * @brief Notification that a behavior terminated.
//   * @param data data that was sent along to the behavior when subscribing.
//   */
//  void onBehaviorTerminate(void* data)
//  {
//    BehaviorWrapper* behaviorWrapper = reinterpret_cast<BehaviorWrapper*>(data);
//#ifdef _DEBUG_COMPONENT
//    behaviorWrapper->m_behavior->getTerminateEvent().unsubscribe(behaviorWrapper->m_subscriberID);
//#endif
//    m_behaviors.erase(behaviorWrapper->m_behaviorID);
//  }
//
//  EVENT_HANDLER(Layer1FSMUnitData, onBehaviorTerminate) m_behaviorTerminateEventHandler;
//
//  std::list<BehaviorWrapper> m_behaviors;
//#endif
};