sgpemv2/plugins/pyloader/python_policy.hh

93 lines
2.4 KiB
C++

// src/backend/pyloader/python_policy.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 PYTHON_POLICY_HH
#define PYTHON_POLICY_HH 1
#include "config.h"
#include <Python.h>
#include <glibmm/ustring.h>
#include <iostream>
#include "policy.hh"
#include "user_interrupt_exception.hh"
namespace sgpem
{
class PythonPolicy;
class PythonPolicyManager;
class UserInterruptException;
/** \brief A specialization of abstract class Policy
This class represents a policy written in Python. Its methods interact with Python interpreter.
See the documentation of class Policy for more detailed informations.
*/
class SG_DLLEXPORT PythonPolicy : public Policy
{
public:
PythonPolicy(const char* name);
virtual ~PythonPolicy();
/**
Calls the method \c async_configure
*/
void configure() throw(UserInterruptException);
/**
Calls the method \c async_sort_queue
*/
void sort_queue(Scheduler::event) const throw(UserInterruptException);
/**
\returns A textual description of this policy.
*/
Glib::ustring get_description() const;
/**
\returns \c TRUE if the policy is preemptive.
\returns \c FALSE if the policy is not preemptive.
*/
bool is_pre_emptive() const throw(UserInterruptException);
/**
\returns The integer value of its time-slice.
*/
int get_time_slice() const throw(UserInterruptException);
private:
PythonPolicy(const PythonPolicy&);
PythonPolicy& operator=(const PythonPolicy&);
void wait_unlock() const throw(UserInterruptException);
PyObject* _adapter;
PyObject* _adapter_dict;
Glib::ustring _name;
};
}
#endif