// __author__ = Juan Carlos De Abreu (jcabreur@gmail.com)

#include "DataReturn.h"
#include "../SceneFile.h"

BEGIN_TEG_NAMESPACE();

// DataReturn constructor.
DataReturn::DataReturn(const SmartPointer<IData>& value_)
    : IData(DATA_BOOL), value(value_) { }

// DataReturn destructor.
DataReturn::~DataReturn() { }

// Function to try to convert a data in a DataReturn.
SmartPointer<DataReturn> castToDataReturn(SmartPointer<IData> d) {
  return dynamic_cast<DataReturn*>((IData*) d);
}

// Method to execute the expresion.
SmartPointer<IData> DataReturn::resolve(
    std::map<std::string, SmartPointer<IData>>& variables) {
  const	SmartPointer<IData> tmp = value->resolve(variables);
  SceneFileManagement::GetInstance().isReturning = true;
  return tmp;
}

END_TEG_NAMESPACE();
