git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1322 3ecf2c5c-341e-0410-92b4-d18e462d057c
93 lines
2.9 KiB
C++
93 lines
2.9 KiB
C++
// src/python_cpu_policy_manager.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 3 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, see http://www.gnu.org/licenses/.
|
|
|
|
|
|
#ifndef PYTHON_CPU_POLICY_MANAGER_HH
|
|
#define PYTHON_CPU_POLICY_MANAGER_HH 1
|
|
|
|
#include "config.h"
|
|
|
|
#include "python_cpu_policy.hh"
|
|
|
|
#include <sgpemv2/cpu_policy_manager.hh>
|
|
|
|
#include <Python.h>
|
|
|
|
namespace sgpem
|
|
{
|
|
|
|
/// \brief Manages Python user-implemented policies
|
|
///
|
|
/// Manages the creation, the organization and the destruction of the
|
|
/// cpu policies implemented using Python.
|
|
///
|
|
/// It is also responsible for handling malformed policies: as soon as the
|
|
/// application detects the presence of a malformed policy, it will ask this
|
|
/// class to terminate the Python interpreter and to reinitialize the objects
|
|
/// which were previously created by the manager itself.
|
|
class PythonCPUPolicyManager;
|
|
|
|
class SG_DLLEXPORT PythonCPUPolicyManager : public CPUPolicyManager
|
|
{
|
|
public:
|
|
|
|
/// \brief Standard constructor.
|
|
///
|
|
/// Standard constructor.
|
|
/// Calls collect_policies() to instantiate all manageable .py policy scripts.
|
|
PythonCPUPolicyManager();
|
|
|
|
/// \brief Standard virtual destructor.
|
|
///
|
|
/// Standard virtual desctuctor.
|
|
~PythonCPUPolicyManager();
|
|
|
|
/// \brief Returns policies found and instantiated by collect_policies().
|
|
///
|
|
/// Returns policies found and instantiated by collect_policies().
|
|
/// \return the policies found and instantiated by collect_policies().
|
|
const std::vector<CPUPolicy*>& get_avail_policies();
|
|
|
|
protected:
|
|
|
|
/// \brief Scans through directories for loadable Python scripts.
|
|
///
|
|
/// Scans through directories for loadable Python scripts.
|
|
/// For each found valid python script, tries to load it, and assess if it contains at least a class which:
|
|
/// -# type(classname) is of type "classobj"
|
|
/// -# classname.__bases is a tuple containing Policy::Policy
|
|
void collect_policies();
|
|
|
|
private:
|
|
/// \brief Standard copy constructor.
|
|
///
|
|
/// Standard private copy constructor.
|
|
PythonCPUPolicyManager(const PythonCPUPolicyManager&);
|
|
|
|
/// \brief Standard private operator assign.
|
|
///
|
|
/// Standard private operator assign.
|
|
PythonCPUPolicyManager& operator=(const PythonCPUPolicyManager&);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|