- 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:
parent
c4c4ef378f
commit
b3ba006800
3 changed files with 225 additions and 127 deletions
|
@ -30,9 +30,10 @@
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
class PolicyParametersException : public std::runtime_error {
|
||||
class PolicyParametersException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
PolicyParametersException(char* msg): std::runtime_error(msg) {}
|
||||
PolicyParametersException(char* msg): std::runtime_error(msg) {}
|
||||
};
|
||||
class PolicyParameters;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
%module sgpem
|
||||
%{
|
||||
#include "policy.hh"
|
||||
#include "policy_parameters.hh"
|
||||
#include "schedulable.hh"
|
||||
#include "schedulable_list.hh"
|
||||
|
@ -8,137 +9,153 @@
|
|||
|
||||
namespace sgpem {
|
||||
|
||||
// --------------------------------------------
|
||||
class PolicyParametersException : public std::runtime_error {
|
||||
public:
|
||||
PolicyParametersException(char* msg): std::runtime_error(msg);
|
||||
}; //~ class PolicyParametersException
|
||||
class Policy {
|
||||
public:
|
||||
virtual ~Policy() = 0;
|
||||
const PolicyParameters& get_parameters() const;
|
||||
};
|
||||
|
||||
// --------------------------------------------
|
||||
class PolicyParametersException : public std::runtime_error {
|
||||
public:
|
||||
PolicyParametersException(char* msg);
|
||||
%rename (__str__) what();
|
||||
}; //~ class PolicyParametersException
|
||||
|
||||
// --------------------------------------------
|
||||
class PolicyParameters
|
||||
{
|
||||
public:
|
||||
template<typename T>
|
||||
class Parameter;
|
||||
|
||||
//methods to CREATE PARAMETERS
|
||||
void register_int(Glib::ustring name,
|
||||
const int& lower_bound,
|
||||
const int& upper_bound,
|
||||
const bool& required,
|
||||
const int& default_value = 0);
|
||||
|
||||
void register_float(Glib::ustring name,
|
||||
const float& lower_bound,
|
||||
const float& upper_bound,
|
||||
const bool& required,
|
||||
const float& default_value = 0.0f);
|
||||
|
||||
void register_string(Glib::ustring name,
|
||||
const bool& required,
|
||||
const Glib::ustring& default_value = "");
|
||||
|
||||
void clear();
|
||||
|
||||
//methods to RETRIEVE CREATED PARAMETERS
|
||||
std::map<Glib::ustring, Parameter<int> > get_registered_int_parameters() const;
|
||||
std::map<Glib::ustring, Parameter<float> > get_registered_float_parameters() const;
|
||||
std::map<Glib::ustring, Parameter<Glib::ustring> > get_registered_string_parameters() const;
|
||||
|
||||
//methods to SET the VALUE of PARAMETERS
|
||||
bool set_int(Glib::ustring name, const int& value);
|
||||
bool set_float(Glib::ustring name, const float& value);
|
||||
bool set_string(Glib::ustring name, const Glib::ustring& value);
|
||||
|
||||
//methods to GET the VALUE of PARAMETERS
|
||||
int get_int(Glib::ustring name) const;
|
||||
float get_float(Glib::ustring name) const;
|
||||
Glib::ustring get_string(Glib::ustring name) const;
|
||||
}; //~ class PolicyParameters
|
||||
|
||||
// --------------------------------------------
|
||||
template<typename T>
|
||||
class PolicyParameters::Parameter
|
||||
{
|
||||
public:
|
||||
Parameter(Glib::ustring name,
|
||||
const T& value,
|
||||
const T& lower_bound,
|
||||
const T& upper_bound,
|
||||
const bool& required,
|
||||
const T& default_value = 0);
|
||||
|
||||
Glib::ustring get_name() const;
|
||||
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 PolicyParameters
|
||||
{
|
||||
public:
|
||||
//methods to CREATE PARAMETERS
|
||||
// (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*);
|
||||
|
||||
// --------------------------------------------
|
||||
class Schedulable
|
||||
{
|
||||
public:
|
||||
Schedulable(const Glib::ustring& name,
|
||||
const unsigned int& arrival,
|
||||
const unsigned int& total,
|
||||
const int& priority);
|
||||
virtual ~Schedulable() = 0;
|
||||
|
||||
virtual unsigned int get_arrival_time() const;
|
||||
unsigned int get_total_cpu_time() const;
|
||||
int get_priority() const;
|
||||
Glib::ustring get_name() const;
|
||||
virtual Glib::ustring get_type() const = 0;
|
||||
}; //~ class Schedulable
|
||||
%extend {
|
||||
void register_int(const char* name,
|
||||
const int& lower_bound,
|
||||
const int& upper_bound,
|
||||
const bool& required,
|
||||
const int& default_value = 0)
|
||||
{
|
||||
self->register_int(Glib::ustring(name),
|
||||
lower_bound, upper_bound,
|
||||
required, default_value);
|
||||
}
|
||||
|
||||
void register_float(const char* name,
|
||||
const float& lower_bound,
|
||||
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 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 SET the VALUE of PARAMETERS
|
||||
// (rewrapped correctly for SWIG usage)
|
||||
%ignore set_int(const Glib::ustring&, const int&);
|
||||
%ignore set_float(const Glib::ustring&, const float&);
|
||||
%ignore set_string(const Glib::ustring&, const Glib::ustring&);
|
||||
|
||||
%extend {
|
||||
bool set_int(const char* name, const int& value)
|
||||
{ return self->set_int(Glib::ustring(name), 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
|
||||
// (rewrapped correctly for SWIG usage)
|
||||
%ignore get_int(const Glib::ustring&) const;
|
||||
%ignore get_float(const Glib::ustring&) const;
|
||||
%ignore get_string(const Glib::ustring&) const;
|
||||
|
||||
%extend {
|
||||
int get_int(const char* name) const
|
||||
{ return self->get_int(Glib::ustring(name)); }
|
||||
float get_float(const char* name) const
|
||||
{ return self->get_float(Glib::ustring(name)); }
|
||||
const char* get_string(const char* name) const
|
||||
{ return self->get_string(Glib::ustring(name)).c_str(); }
|
||||
}
|
||||
|
||||
}; //~ class PolicyParameters
|
||||
|
||||
// --------------------------------------------
|
||||
class Schedulable
|
||||
{
|
||||
public:
|
||||
virtual ~Schedulable() = 0;
|
||||
|
||||
virtual unsigned int get_arrival_time() const;
|
||||
int get_priority() const;
|
||||
unsigned int get_total_cpu_time() const;
|
||||
|
||||
%ignore get_name() const;
|
||||
%extend {
|
||||
const char* get_name() const
|
||||
{ return self->get_name().c_str(); }
|
||||
}
|
||||
}; //~ class Schedulable
|
||||
|
||||
|
||||
// --------------------------------------------
|
||||
class SchedulableList
|
||||
{
|
||||
public:
|
||||
SchedulableList();
|
||||
|
||||
bool operator==(const SchedulableList&) const;
|
||||
bool has_same_objects(const SchedulableList& dx) const;
|
||||
sgpem::SchedulableStatus* top();
|
||||
sgpem::SchedulableStatus* bottom();
|
||||
void add_at_bottom(const sgpem::SchedulableStatus&);
|
||||
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 SchedulableList
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
||||
private:
|
||||
// Avoid instantiation and copy
|
||||
SchedulableList();
|
||||
SchedulableList(const SchedulableList& );
|
||||
}; //~ class Schedulable
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
class SchedulableStatus
|
||||
{
|
||||
public:
|
||||
enum state
|
||||
{
|
||||
state_running,
|
||||
state_ready,
|
||||
state_blocked,
|
||||
state_future,
|
||||
state_terminated
|
||||
};
|
||||
// ---------------------------------------------
|
||||
class SchedulableStatus
|
||||
{
|
||||
public:
|
||||
enum state
|
||||
{
|
||||
state_running,
|
||||
state_ready,
|
||||
state_blocked,
|
||||
state_future,
|
||||
state_terminated
|
||||
};
|
||||
|
||||
SchedulableStatus(const Schedulable& obj);
|
||||
bool operator==(const SchedulableStatus&) const;
|
||||
|
||||
int get_cpu_time_left() const;
|
||||
void give_cpu_time(const int& time);
|
||||
void set_last_scheduled(const int& time);
|
||||
int get_last_scheduled() const;
|
||||
state get_state() const;
|
||||
void set_state(state s);
|
||||
const Schedulable* get_schedulable() const;
|
||||
};
|
||||
SchedulableStatus(const SchedulableStatus& obj);
|
||||
|
||||
int get_cpu_time_left() const;
|
||||
void give_cpu_time(const int& time);
|
||||
int get_last_scheduled() const;
|
||||
state get_state() const;
|
||||
const Schedulable* get_schedulable() const;
|
||||
};
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue