- Rewrite sgpem module interface file with adapter methods

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@360 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-02-20 19:10:16 +00:00
parent c4c4ef378f
commit b3ba006800
3 changed files with 225 additions and 127 deletions

View File

@ -1,3 +1,83 @@
2006-02-20 00:12 tchernobog
* trunk/Makefile.am, trunk/config/Doxyfile.in: - Change order on
which the libraries are listed for installation in the makefile,
thus workarounding a nasty automake bug. This problem is reported
here: http://sourceware.org/ml/automake/2004-03/msg00113.html
http://sources.redhat.com/ml/automake/2004-01/msg00171.html ...
but it doesn't seem to have been solved thus far.
2006-02-19 22:36 tchernobog
* trunk/src/backend/history.cc, trunk/src/backend/history.hh,
trunk/src/backend/observed_subject.cc,
trunk/src/backend/observed_subject.hh,
trunk/src/backend/policy.cc, trunk/src/backend/policy.hh,
trunk/src/backend/policy_manager.cc,
trunk/src/backend/policy_manager.hh,
trunk/src/backend/policy_parameters.cc,
trunk/src/backend/policy_parameters.hh,
trunk/src/backend/process.cc, trunk/src/backend/process.hh,
trunk/src/backend/pyloader/python_policy.cc,
trunk/src/backend/pyloader/python_policy.hh,
trunk/src/backend/pyloader/python_policy_manager.cc,
trunk/src/backend/pyloader/python_policy_manager.hh,
trunk/src/backend/schedulable.cc,
trunk/src/backend/schedulable.hh,
trunk/src/backend/schedulable_list.cc,
trunk/src/backend/schedulable_list.hh,
trunk/src/backend/schedulable_status.cc,
trunk/src/backend/schedulable_status.hh,
trunk/src/backend/scheduler.cc, trunk/src/backend/scheduler.hh,
trunk/src/backend/slice.cc, trunk/src/backend/slice.hh,
trunk/src/backend/string_utils.cc,
trunk/src/backend/string_utils.hh,
trunk/src/graphical_simulation.hh,
trunk/src/graphical_terminal_io.cc,
trunk/src/graphical_terminal_io.hh, trunk/src/io_manager.hh,
trunk/src/main.cc, trunk/src/main.hh, trunk/src/main_window.cc,
trunk/src/main_window.hh, trunk/src/observer.cc,
trunk/src/observer.hh, trunk/src/parse_opts.cc,
trunk/src/parse_opts.hh, trunk/src/simulation.cc,
trunk/src/simulation.hh, trunk/src/standard_io.cc,
trunk/src/standard_io.hh, trunk/src/start_gui.cc,
trunk/src/start_gui.hh, trunk/src/templates/smartp.hh,
trunk/src/text_simulation.cc, trunk/src/text_simulation.hh: - Add
newlines at the end of source files. I hope not having to do this
frequently! (it's a two-liner script, but nevertheless...)
2006-02-19 22:25 tchernobog
* trunk/Makefile.am, trunk/src/backend/pyloader/Policy.py,
trunk/src/backend/sgpem.i: - Add first draft of SWIG interface
file, and create Python loadable module. However, please note
that: - All the methods accepting a Glib::ustring should not be
exported, instead they should be replaced by wrapper functions
accepting PyObject*. - The same thing applies to every other
method accepting a ``non built-in'' data type - Return types
should probably be wrapped, too - It may be a good idea to
implement wrapper methods that print out the content of a C++
object, so that a Python user can do a simple "print schedStat".
This is achieved by adding a "__str__()" method to the class. See
the SWIG manual for further infos about returning const char*
values.
2006-02-19 16:22 tchernobog
* trunk/src/backend/pyloader/Abstract.py,
trunk/src/backend/pyloader/Policy.py: - Fix documentation for
Python Abstract module
2006-02-19 15:49 tchernobog
* trunk/ChangeLog, trunk/configure.ac: - Change version number for
first milestone release
2006-02-19 14:54 tchernobog
* trunk/README: - Add some temporary infos about how to perform the
build process.
2006-02-19 14:34 tchernobog 2006-02-19 14:34 tchernobog
* trunk/ChangeLog, trunk/Makefile.am, trunk/configure.ac, * trunk/ChangeLog, trunk/Makefile.am, trunk/configure.ac,

View File

@ -30,9 +30,10 @@
namespace sgpem namespace sgpem
{ {
class PolicyParametersException : public std::runtime_error { class PolicyParametersException : public std::runtime_error
{
public: public:
PolicyParametersException(char* msg): std::runtime_error(msg) {} PolicyParametersException(char* msg): std::runtime_error(msg) {}
}; };
class PolicyParameters; class PolicyParameters;

View File

@ -1,5 +1,6 @@
%module sgpem %module sgpem
%{ %{
#include "policy.hh"
#include "policy_parameters.hh" #include "policy_parameters.hh"
#include "schedulable.hh" #include "schedulable.hh"
#include "schedulable_list.hh" #include "schedulable_list.hh"
@ -8,137 +9,153 @@
namespace sgpem { namespace sgpem {
// -------------------------------------------- class Policy {
class PolicyParametersException : public std::runtime_error { public:
public: virtual ~Policy() = 0;
PolicyParametersException(char* msg): std::runtime_error(msg); const PolicyParameters& get_parameters() const;
}; //~ class PolicyParametersException };
// -------------------------------------------- // --------------------------------------------
class PolicyParameters class PolicyParametersException : public std::runtime_error {
{ public:
public: PolicyParametersException(char* msg);
template<typename T> %rename (__str__) what();
class Parameter; }; //~ class PolicyParametersException
//methods to CREATE PARAMETERS // --------------------------------------------
void register_int(Glib::ustring name, class PolicyParameters
const int& lower_bound, {
const int& upper_bound, public:
const bool& required, //methods to CREATE PARAMETERS
const int& default_value = 0); // (rewrapped correctly for SWIG usage)
%ignore register_int(const Glib::ustring&, const int&,
const int&, const bool&, const int&);
%ignore register_float(const Glib::ustring&, const float&,
const float&, const bool&, const float&);
%ignore register_string(const Glib::ustring&, const bool&,
const char*);
void register_float(Glib::ustring name, %extend {
const float& lower_bound, void register_int(const char* name,
const float& upper_bound, const int& lower_bound,
const bool& required, const int& upper_bound,
const float& default_value = 0.0f); const bool& required,
const int& default_value = 0)
{
self->register_int(Glib::ustring(name),
lower_bound, upper_bound,
required, default_value);
}
void register_string(Glib::ustring name, void register_float(const char* name,
const bool& required, const float& lower_bound,
const Glib::ustring& default_value = ""); const float& upper_bound,
const bool& required,
const float& default_value = 0.0f)
{
self->register_float(Glib::ustring(name),
lower_bound, upper_bound,
required, default_value);
}
void clear(); void register_string(const char* name,
const bool& required,
const char* default_value = "")
{
self->register_string(Glib::ustring(name),
required,
Glib::ustring(default_value));
}
}
//methods to RETRIEVE CREATED PARAMETERS //methods to SET the VALUE of PARAMETERS
std::map<Glib::ustring, Parameter<int> > get_registered_int_parameters() const; // (rewrapped correctly for SWIG usage)
std::map<Glib::ustring, Parameter<float> > get_registered_float_parameters() const; %ignore set_int(const Glib::ustring&, const int&);
std::map<Glib::ustring, Parameter<Glib::ustring> > get_registered_string_parameters() const; %ignore set_float(const Glib::ustring&, const float&);
%ignore set_string(const Glib::ustring&, const Glib::ustring&);
//methods to SET the VALUE of PARAMETERS %extend {
bool set_int(Glib::ustring name, const int& value); bool set_int(const char* name, const int& value)
bool set_float(Glib::ustring name, const float& value); { return self->set_int(Glib::ustring(name), value); }
bool set_string(Glib::ustring name, const Glib::ustring& value); bool set_float(const char* name, const float& value)
{ return self->set_float(Glib::ustring(name), value); }
bool set_string(const char* name, const char* value)
{ return self->set_string(Glib::ustring(name), value); }
}
//methods to GET the VALUE of PARAMETERS //methods to GET the VALUE of PARAMETERS
int get_int(Glib::ustring name) const; // (rewrapped correctly for SWIG usage)
float get_float(Glib::ustring name) const; %ignore get_int(const Glib::ustring&) const;
Glib::ustring get_string(Glib::ustring name) const; %ignore get_float(const Glib::ustring&) const;
}; //~ class PolicyParameters %ignore get_string(const Glib::ustring&) const;
// -------------------------------------------- %extend {
template<typename T> int get_int(const char* name) const
class PolicyParameters::Parameter { return self->get_int(Glib::ustring(name)); }
{ float get_float(const char* name) const
public: { return self->get_float(Glib::ustring(name)); }
Parameter(Glib::ustring name, const char* get_string(const char* name) const
const T& value, { return self->get_string(Glib::ustring(name)).c_str(); }
const T& lower_bound, }
const T& upper_bound,
const bool& required,
const T& default_value = 0);
Glib::ustring get_name() const; }; //~ class PolicyParameters
T get_lower_bound() const;
T get_upper_bound() const;
bool is_required() const;
T get_default() const;
T get_value() const;
void set_value(const T&);
}; //~ class PolicyParameters::Parameter<>
// -------------------------------------------- // --------------------------------------------
class Schedulable class Schedulable
{ {
public: public:
Schedulable(const Glib::ustring& name, virtual ~Schedulable() = 0;
const unsigned int& arrival,
const unsigned int& total,
const int& priority);
virtual ~Schedulable() = 0;
virtual unsigned int get_arrival_time() const; virtual unsigned int get_arrival_time() const;
unsigned int get_total_cpu_time() const; int get_priority() const;
int get_priority() const; unsigned int get_total_cpu_time() const;
Glib::ustring get_name() const;
virtual Glib::ustring get_type() const = 0; %ignore get_name() const;
}; //~ class Schedulable %extend {
const char* get_name() const
{ return self->get_name().c_str(); }
}
}; //~ class Schedulable
// -------------------------------------------- // --------------------------------------------
class SchedulableList class SchedulableList
{ {
public: public:
SchedulableList(); sgpem::SchedulableStatus* top();
sgpem::SchedulableStatus* bottom();
bool insert_at(const uint&, const uint&);
uint size() const;
SchedulableStatus* get_item_at(const uint&);
const SchedulableStatus* get_item_at(const uint&) const;
bool operator==(const SchedulableList&) const; private:
bool has_same_objects(const SchedulableList& dx) const; // Avoid instantiation and copy
sgpem::SchedulableStatus* top(); SchedulableList();
sgpem::SchedulableStatus* bottom(); SchedulableList(const SchedulableList& );
void add_at_bottom(const sgpem::SchedulableStatus&); }; //~ class Schedulable
void add_at_top(const sgpem::SchedulableStatus&);
memory::smart_ptr<sgpem::SchedulableStatus> remove(const uint& position);
bool insert_at(const uint&, const uint&);
uint size() const;
SchedulableStatus* get_item_at(const uint&);
const SchedulableStatus* get_item_at(const uint&) const;
void clear();
}; //~ class Schedulable
// --------------------------------------------- // ---------------------------------------------
class SchedulableStatus class SchedulableStatus
{ {
public: public:
enum state enum state
{ {
state_running, state_running,
state_ready, state_ready,
state_blocked, state_blocked,
state_future, state_future,
state_terminated state_terminated
}; };
SchedulableStatus(const Schedulable& obj); SchedulableStatus(const SchedulableStatus& obj);
bool operator==(const SchedulableStatus&) const;
int get_cpu_time_left() const; int get_cpu_time_left() const;
void give_cpu_time(const int& time); void give_cpu_time(const int& time);
void set_last_scheduled(const int& time); int get_last_scheduled() const;
int get_last_scheduled() const; state get_state() const;
state get_state() const; const Schedulable* get_schedulable() const;
void set_state(state s); };
const Schedulable* get_schedulable() const;
};
} //~ namespace sgpem } //~ namespace sgpem