// src/backend/schedulable.hh - Copyright 2005, 2006, University
//               of Padova, dept. of Pure and Applied
//               Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef SCHEDULABLE_HH
#define SCHEDULABLE_HH 1

#include "config.h"

#include <glibmm/ustring.h>

namespace sgpem
{
  class Schedulable;
  class SerializeVisitor;

  class SG_DLLEXPORT Schedulable
  {
  public:
    /** \brief This flag describes the actual state of the schedulable
     *
     * You can think of this flag as the particular stack in the OS where the
     * process are placed during their lifetime.  In the OS there are three
     * main stacks that are Running processes, Read processes, and Blocked
     * processes. These are emulated in a single list by this flag.
     */
    enum state
    {
      state_running    = 1 << 0,
      state_ready      = 1 << 1,
      state_blocked    = 1 << 2,
      state_future     = 1 << 3,
      state_terminated = 1 << 4
    };

    virtual ~Schedulable() = 0;

    virtual bool operator==(const Schedulable& op2) const = 0;

    virtual Glib::ustring get_name() const = 0;

    virtual unsigned int get_arrival_time() const = 0;

    virtual unsigned int get_elapsed_time() const = 0;

    virtual int get_last_acquisition() const = 0;

    virtual int get_last_release() const = 0;

    virtual int get_base_priority() const = 0;

    virtual unsigned int get_total_cpu_time() const = 0;

    virtual int get_current_priority() const = 0;

    virtual int set_priority_push(int new_value = 0) = 0;

    virtual state get_state() const = 0;

    virtual void serialize(SerializeVisitor& translator) const = 0;
  };
}

#endif
