sgpemv2/plugins/pyloader/src/python_policy_manager.hh

95 lines
2.7 KiB
C++
Raw Normal View History

// src/backend/pyloader/python_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 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_MANAGER_HH
#define PYTHON_POLICY_MANAGER_HH 1
#include "config.h"
#include <Python.h>
#include "policy_manager.hh"
#include "python_policy.hh"
namespace sgpem
{
//class PolicyManager;
class PythonPolicyManager;
/** \brief Manages Python user-implemented policies
*
* This singleton manages the creation and destruction
* of a Python policy.
*/
class SG_DLLEXPORT PythonPolicyManager : public PolicyManager
{
public:
/** \brief Returns a reference to the active policy.
*
* For the moment, it will sufficit to keep and return
* just one Policy for PolicyManager.
* In the next milestones it will be possible to manage
* more than one, and to retrieve the correct Policy by
* passing a unique ID.
*/
Policy& get_policy();
/** \brief Initialize the Python interpreter.
*
* If the interpreter has already been initialized, it terminates it, cleanups old policies,
* and restarts it.
*/
void init();
std::vector<Policy*> get_avail_policies()
{
//FIXME write code for me
return std::vector<Policy*>();
}
/** \brief Returns the singleton instance of
* PythonPolicyManager.
*
* Please note that the first time you'll request
* it, it will be still uninitialized.
* @see init()
*/
static PythonPolicyManager* const get_instance();
protected:
/** The selected and active PyhonPolicy object. */
PythonPolicyManager();
std::auto_ptr<PythonPolicy> _python_policy;
private:
PythonPolicyManager(const PythonPolicyManager&);
PythonPolicyManager& operator=(const PythonPolicyManager&);
/** Singleton support. */
static PythonPolicyManager* _instance;
bool _initialized;
};
}
#endif