2006-02-12 18:12:54 +01:00
|
|
|
// src/backend/policy_parameters.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 POLICY_PARAMETERS_HH
|
|
|
|
#define POLICY_PARAMETERS_HH 1
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
#include <map>
|
|
|
|
#include <stdexcept>
|
2006-02-12 18:12:54 +01:00
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
#include "glibmm/ustring.h"
|
2006-02-12 18:12:54 +01:00
|
|
|
|
|
|
|
namespace sgpem
|
|
|
|
{
|
2006-02-13 12:32:05 +01:00
|
|
|
class PolicyParametersException : public std::runtime_error {
|
|
|
|
public:
|
|
|
|
PolicyParametersException(char* msg): std::runtime_error(msg) {}
|
|
|
|
};
|
2006-02-12 18:12:54 +01:00
|
|
|
class PolicyParameters;
|
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
|
2006-02-12 18:12:54 +01:00
|
|
|
/** \brief
|
2006-02-13 12:32:05 +01:00
|
|
|
Represents all configurable parameters of a single scheduling algorithm. Is is used by the user
|
|
|
|
interface: it's useful to know which parameters the user will be asked for.
|
|
|
|
Each Policy object owns only one instance of this class.
|
2006-02-12 18:12:54 +01:00
|
|
|
*/
|
|
|
|
class SG_DLLEXPORT PolicyParameters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template<typename T>
|
|
|
|
class Parameter;
|
2006-02-13 12:32:05 +01:00
|
|
|
|
2006-02-12 18:12:54 +01:00
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
//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;
|
|
|
|
|
|
|
|
|
2006-02-12 18:12:54 +01:00
|
|
|
|
|
|
|
private:
|
2006-02-13 12:32:05 +01:00
|
|
|
std::map<Glib::ustring, Parameter<int> > int_map;
|
|
|
|
std::map<Glib::ustring, Parameter<float> > float_map;
|
|
|
|
std::map<Glib::ustring, Parameter<Glib::ustring> > string_map;
|
2006-02-12 18:12:54 +01:00
|
|
|
};
|
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
This class is useful only to store informations about each parameter. No checks
|
|
|
|
on the values entered are done.
|
|
|
|
*/
|
2006-02-12 18:12:54 +01:00
|
|
|
template<typename T>
|
|
|
|
class PolicyParameters::Parameter
|
|
|
|
{
|
2006-02-13 12:32:05 +01:00
|
|
|
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;
|
2006-02-12 18:12:54 +01:00
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
void set_value(const T&);
|
2006-02-12 18:12:54 +01:00
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
private:
|
|
|
|
Glib::ustring _name;
|
|
|
|
T _value;
|
|
|
|
T _lower_bound;
|
|
|
|
T _upper_bound;
|
|
|
|
bool _is_required;
|
|
|
|
T _default;
|
|
|
|
};
|
2006-02-12 18:12:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
}//~ namespace sgpem
|
|
|
|
|
2006-02-13 12:32:05 +01:00
|
|
|
#include "../templates/parameter.tcc"
|
2006-02-12 18:12:54 +01:00
|
|
|
|
2006-02-19 23:36:24 +01:00
|
|
|
#endif
|