//
// Copyright (c) 2009 Froduald Kabanza and the Université de Sherbrooke.
// Use of this software is permitted for non-commercial research purposes, and
// it may be copied or applied only for that use. All copies must include this
// copyright message.
// 
// This is a research prototype that has not gone through intensive tests and
// is delivered as is. It may still contain bugs. Froduald Kabanza and the
// Université de Sherbrooke disclaim any responsibility for damage that may be
// caused by using it.
//
// Please note that some files were inspired in part by the PDDL4J library:
// http://www.math-info.univ-paris5.fr/~pellier/software/software.php 
//
// Implementation: Simon Chamberland
// Project Manager: Froduald Kabanza
//

#include "stdafx.h"
#include "NumericFluentApplication.h"
#include "NumericFluent.h"

using namespace planning;

const std::string NumericFluentApplication::description("numeric fluent");

NumericFluentApplication::NumericFluentApplication(const NumericFluent* numericFluent, const ITerm** arguments)
  : FluentApplication(numericFluent, arguments)
{
  INITIALIZE_HASH_CODE();
}

const NumericFluentApplication* NumericFluentApplication::apply(const Bindings* bindings) const
{
  return static_cast<const NumericFluentApplication*>(FormulaApplication::apply(bindings));
}

const NumericFluentApplication* NumericFluentApplication::evaluateArguments(
                                            const IClosedWorld* world, 
                                            const Bindings* bindings) const
{
  return static_cast<const NumericFluentApplication*>(FormulaApplication::evaluateArguments(world, bindings));
}

double NumericFluentApplication::evaluate(const IClosedWorld* world, const Bindings* bindings) const
{
  const NumericFluentApplication* groundFormula = evaluateArguments(world, bindings);

  return world->getNumericFluent(groundFormula);
}

const NumericFluent* NumericFluentApplication::getNumericFluent() const
{
  return static_cast<const NumericFluent*>(m_rootFormula);
}