2006-02-23 12:29:25 +01:00
|
|
|
// src/backend/pyloader/python_policy_manager.hh - Copyright 2005, 2006, University
|
2006-02-17 17:08:54 +01:00
|
|
|
// 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>
|
|
|
|
|
2006-04-06 21:01:13 +02:00
|
|
|
#include "policy_manager.hh"
|
2006-02-17 17:08:54 +01:00
|
|
|
#include "python_policy.hh"
|
|
|
|
|
|
|
|
namespace sgpem
|
|
|
|
{
|
2006-02-21 11:31:01 +01:00
|
|
|
//class PolicyManager;
|
|
|
|
class PythonPolicyManager;
|
2006-02-23 19:55:14 +01:00
|
|
|
|
|
|
|
/** \brief Manages Python user-implemented policies
|
|
|
|
*
|
|
|
|
* This singleton manages the creation and destruction
|
|
|
|
* of a Python policy.
|
|
|
|
*/
|
2006-02-21 11:31:01 +01:00
|
|
|
class SG_DLLEXPORT PythonPolicyManager : public PolicyManager
|
|
|
|
{
|
2006-02-23 19:55:14 +01:00
|
|
|
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.
|
|
|
|
*/
|
2006-02-21 11:31:01 +01:00
|
|
|
Policy& get_policy();
|
2006-02-23 19:55:14 +01:00
|
|
|
|
|
|
|
/** \brief Initialize the Python interpreter.
|
|
|
|
*
|
|
|
|
* If the interpreter has already been initialized, it terminates it, cleanups old policies,
|
|
|
|
* and restarts it.
|
|
|
|
*/
|
2006-02-21 11:31:01 +01:00
|
|
|
void init();
|
2006-02-23 19:55:14 +01:00
|
|
|
|
|
|
|
/** \brief Returns the singleton instance of
|
|
|
|
* PythonPolicyManager.
|
|
|
|
*
|
|
|
|
* Please note that the first time you'll request
|
|
|
|
* it, it will be still uninitialized.
|
|
|
|
* @see init()
|
|
|
|
*/
|
2006-02-21 23:57:14 +01:00
|
|
|
static PythonPolicyManager* const get_instance();
|
2006-02-17 17:08:54 +01:00
|
|
|
|
2006-03-08 17:47:39 +01:00
|
|
|
protected:
|
|
|
|
/** The selected and active PyhonPolicy object. */
|
2006-02-21 11:31:01 +01:00
|
|
|
PythonPolicyManager();
|
2006-03-08 17:47:39 +01:00
|
|
|
std::auto_ptr<PythonPolicy> _python_policy;
|
|
|
|
|
|
|
|
private:
|
2006-02-21 11:31:01 +01:00
|
|
|
PythonPolicyManager(const PythonPolicyManager&);
|
|
|
|
PythonPolicyManager& operator=(const PythonPolicyManager&);
|
|
|
|
|
2006-02-23 19:55:14 +01:00
|
|
|
/** Singleton support. */
|
2006-02-21 11:31:01 +01:00
|
|
|
static PythonPolicyManager* _instance;
|
2006-02-23 19:55:14 +01:00
|
|
|
|
2006-02-21 11:31:01 +01:00
|
|
|
bool _initialized;
|
|
|
|
};
|
2006-02-17 17:08:54 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2006-02-19 23:36:24 +01:00
|
|
|
|