#pragma once
#include "../../Utils/Component.h"
#include "UnitTypeCreatable.h"
#include "UnitTypeInstanceCompleted.h"
#include "SparObject.h"
#include <Exp/ILogicalExp.h>
#include <Exp/Term/Object.h>
#include <Exp/Term/Type/PrimitiveType.h>

class CurrentWorld;

class UnitTypeObject : public SparObject
{
public:
  UnitTypeObject(BWAPI::UnitType unitType, planning::PrimitiveType* type);
  virtual ~UnitTypeObject();
  BWAPI::UnitType getUnitType() const
  {
    return m_unitType;
  }
  bool isCreatable() const
  {
    return m_cachedIsCreatable;
  }
  bool isCompleted() const
  {
    return m_cachedOneCompleted;
  }
  const UnitTypeCreatable* getUnitTypeCreatableExpression() const
  {
    return m_unitTypeCreatable;
  }
  const UnitTypeInstanceCompleted* getUnitTypeCompletedExpression() const
  {
    return m_unitTypeInstanceCompleted;
  }

protected:
  friend class SparObject;
  friend class CurrentWorld;
  virtual void initialize();
  virtual void releaseMembers();
  void update();

  const BWAPI::UnitType m_unitType;

  AutoPtr<const UnitTypeCreatable> m_unitTypeCreatable;
  mutable bool m_cachedIsCreatable;

  AutoPtr<const UnitTypeInstanceCompleted> m_unitTypeInstanceCompleted;
  mutable bool m_cachedOneCompleted;
};