#ifndef _BIP_Engine_Priority_HPP_
#define _BIP_Engine_Priority_HPP_

// inherited classes
#include <PriorityItf.hpp>

class BipError;

class Priority : public PriorityItf {
 public:
  // constructors
  Priority(Interaction *low, Interaction *high);

  // destructor
  virtual ~Priority();

  // specific
  bool appliesLow(const Interaction &interaction) const;
  bool appliesHigh(const Interaction &interaction) const;
  const vector<Priority *> &dominatingPriorities() const;
  const vector<Priority *> &dominatedPriorities() const;

  BipError &detectCycle() const;

  bool changed() const { return guard() != mPreviousGuard; }
  void updatePreviousGuard() const { mPreviousGuard = guard(); }

  void resetActive() const;
  bool active() const;
  void setActive(bool b) const { mActive = b; }

 protected:
  BipError &detectCycle(vector<const Priority *> &path) const;

  mutable bool mInitializedDominatingPriorities;
  mutable vector<Priority *> mDominatingPriorities;

  mutable bool mInitializedDominatedPriorities;
  mutable vector<Priority *> mDominatedPriorities;

  mutable bool mPreviousGuard;

  mutable bool mResetActive;
  mutable bool mActive;
};

#endif // _BIP_Engine_Priority_HPP_
