//
// 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
//

#ifndef _I_CLOSED_WORLD_H
#define _I_CLOSED_WORLD_H

#include "../../Utils/ReferenceCounted.h"

namespace planning
{
  class AtomicFormulaApplication;
  class NumericFluentApplication;
  class ObjectFluentApplication;
  class Object;

  class ArithmeticFunction
  {
  public :
    virtual double operator() (double d1, double d2) const = 0;
  };

  /// <summary>
  /// Updatable closed world supporting read and write operations.
  /// </summary>
  class IClosedWorld : public ReferenceCounted
  {
  public:
    virtual ~IClosedWorld() {}

    virtual bool isSet(const AtomicFormulaApplication* formula) const = 0;

    virtual void set(const AtomicFormulaApplication* formula) = 0;

    virtual void unset(const AtomicFormulaApplication* formula) = 0;

    virtual double getNumericFluent(const NumericFluentApplication* fluent) const = 0;

    virtual const Object* getObjectFluent(const ObjectFluentApplication* fluent) const = 0;

    virtual void setNumericFluent(const NumericFluentApplication* fluent, double value) = 0;

    virtual void setNumericFluent(const NumericFluentApplication* fluent, 
                                  const ArithmeticFunction& function, 
                                  double argument) = 0;

    virtual void setObjectFluent(const ObjectFluentApplication* fluent, const Object* value) = 0;

    virtual void undefineObjectFluent(const ObjectFluentApplication* fluent) = 0;

    ///////////////////////////////////////////////

    virtual IClosedWorld* copy() const = 0;

    virtual size_t getHashCode() const = 0;

    virtual int compareTo(const IClosedWorld& other) const = 0;
  };
}

#endif