- Give finishing touches to PythonCPUPolicy: implement describe()

taking the __doc__ class attribute from the Python policy


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@896 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-17 22:04:25 +00:00
parent 7447bf82ec
commit 2ff87baadf
3 changed files with 11 additions and 2 deletions

View File

@ -24,6 +24,8 @@ import sys
#from sgpem import policy_sorts_processes
class fcfs(CPUPolicy) :
"""First Come First Served"""
def __init__(self):
pass;

View File

@ -38,7 +38,7 @@ Glib::StaticRecMutex PythonCPUPolicy::_mtx = GLIBMM_STATIC_REC_MUTEX_INIT;
// *strong* exception checking / handling!
PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyException)
: _upolicy_dict(NULL), _adapter(NULL), _name(name)
: _upolicy_dict(NULL), _adapter(NULL), _name(name), _description()
{
PyObject* pLoadmeStr = PyString_FromString(name);
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
@ -63,6 +63,12 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
PyObject* pCPUPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
assert(pCPUPolicyClass); // FIXME needs stricter checking and exception throwing
// Retrieve a description for the policy using the __doc__ attribute
PyObject* pDescriptionString = PyObject_GetAttrString(pCPUPolicyClass, "__doc__");
if(pDescriptionString != Py_None)
_description = PyString_AsString(pDescriptionString);
Py_DECREF(pDescriptionString);
// Creates a new object of type ScriptAdapter :
// takes init function from ScriptAdapter class
PyObject* pAdapterClass = PyDict_GetItemString(pAdapterDict, "ScriptAdapter");
@ -157,7 +163,7 @@ PythonCPUPolicy::sort_queue() const throw(UserInterruptException, MalformedPolic
Glib::ustring
PythonCPUPolicy::get_description() const
{
return _name;
return _description;
}

View File

@ -94,6 +94,7 @@ namespace sgpem
PyObject* _adapter;
Glib::ustring _name;
Glib::ustring _description;
};
}