//
// 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 _DURATIVE_GROUND_ACTION_H
#define _DURATIVE_GROUND_ACTION_H

#include "DurativeAction.h"
#include "IGroundAction.h"
#include "../Exp/ILogicalExp.h"
#include "../Exp/Bindings.h"

namespace planning
{
  /// <summary>
  /// This interface is implemented by all types of action defined in the PDDL language.
  /// </summary>
  class DurativeGroundAction : public IGroundAction
  {
  public:
    DurativeGroundAction(const DurativeAction* durativeAction, const Bindings* bindings);

    ~DurativeGroundAction();

    virtual bool isApplicable(const IClosedWorld* world) const;

    virtual const IEffect* getStartEffect() const;

    virtual void getDelayedEffects(const IClosedWorld* evaluationWorld, 
                                   std::vector<std::pair<double, const IEffect*>>& delayedEffects) const;

    //virtual void evaluateAtStart(const IClosedWorld* world, ActionContext* context) const;
    //virtual bool evaluateOverAll(const IClosedWorld* world, ActionContext* context) const;
    //virtual bool evaluateAtEnd(const IClosedWorld* world, ActionContext* context) const;

  protected:
    virtual void _output(std::ostream& out) const;

    typedef std::vector<const Object*>::const_iterator object_iterator;

    const std::vector<const Object*> m_arguments;

    const DurativeAction *m_durativeAction;

    const ILogicalExp* m_precondition;

    const IEffect* m_startEffect;

    const std::vector<std::pair<const INumericExp*, const IEffect*>> m_delayedEffects;

  };
}

#endif