From 052016928880f251767868ccba128e88df0b9878 Mon Sep 17 00:00:00 2001 From: matrevis Date: Mon, 28 Aug 2006 22:45:02 +0000 Subject: [PATCH] - I forgot to include a pair of files. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@959 3ecf2c5c-341e-0410-92b4-d18e462d057c --- .../default_resource_policy_manager.cc | 45 +++++++++ .../default_resource_policy_manager.hh | 63 +++++++++++++ src/backend/resource_policy_lifo.cc | 69 ++++++++++++++ src/backend/resource_policy_lifo.hh | 91 +++++++++++++++++++ 4 files changed, 268 insertions(+) create mode 100644 src/backend/default_resource_policy_manager.cc create mode 100644 src/backend/default_resource_policy_manager.hh create mode 100644 src/backend/resource_policy_lifo.cc create mode 100644 src/backend/resource_policy_lifo.hh diff --git a/src/backend/default_resource_policy_manager.cc b/src/backend/default_resource_policy_manager.cc new file mode 100644 index 0000000..efd6a94 --- /dev/null +++ b/src/backend/default_resource_policy_manager.cc @@ -0,0 +1,45 @@ +// src/backend/default_resource_policy_manager.cc - 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 + + +#include "resource_policy_lifo.hh" +#include "default_resource_policy_manager.hh" +#include "resource_policies_gatekeeper.hh" + +using namespace sgpem; + +DefaultResourcePolicyManager::DefaultResourcePolicyManager() +{ + ResourcePolicy * lifo = new ResourcePolicyLiFo(); + _policies.push_back(lifo); + ResourcePoliciesGatekeeper::get_instance().register_manager(this); +} + + +DefaultResourcePolicyManager::~DefaultResourcePolicyManager() +{ + ResourcePoliciesGatekeeper::get_instance().unregister_manager(this); +} + +const std::vector& +DefaultResourcePolicyManager::get_avail_policies() const +{ + return _policies; +} diff --git a/src/backend/default_resource_policy_manager.hh b/src/backend/default_resource_policy_manager.hh new file mode 100644 index 0000000..d0ed3c9 --- /dev/null +++ b/src/backend/default_resource_policy_manager.hh @@ -0,0 +1,63 @@ +// src/backend/default_resource_policy_manager.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 DEFAULT_RESOURCE_POLICY_MANAGER_HH +#define DEFAULT_RESOURCE_POLICY_MANAGER_HH 1 + +namespace sgpem +{ + class ResourcePolicy; +} + +#include "config.h" + +#include "resource_policy_manager.hh" + +#include + + +namespace sgpem +{ + class DefaultResourcePolicyManager; + + /** + ResourcePolicyManager is the Abstract Factory for \ref ResourcePolicy objects. + */ + class SG_DLLEXPORT DefaultResourcePolicyManager : public ResourcePolicyManager + { + public: + /** \brief DefaultResourcePolicyManager constructor + * + * Registers itself to the ResourcePoliciesGatekeeper singleton. + */ + DefaultResourcePolicyManager(); + + virtual ~DefaultResourcePolicyManager(); + + virtual const std::vector& get_avail_policies() const; + + private: + std::vector _policies; + }; + +} //~ namespace sgpem + +#endif + diff --git a/src/backend/resource_policy_lifo.cc b/src/backend/resource_policy_lifo.cc new file mode 100644 index 0000000..6f09a00 --- /dev/null +++ b/src/backend/resource_policy_lifo.cc @@ -0,0 +1,69 @@ +// src/backend/resource_policy_lifo.cc - 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 + +#include "resource_policy_lifo.hh" +using namespace std; +using namespace sgpem; + +ResourcePolicyLiFo::~ResourcePolicyLiFo() +{} + + +PolicyParameters& +ResourcePolicyLiFo::get_parameters() +{ + return _parameters; +} + +void +ResourcePolicyLiFo::configure() + throw(UserInterruptException) +{ +} + +void +ResourcePolicyLiFo::enforce() + throw(UserInterruptException) +{ + printf("\nResourcePolicy 'LiFo' has been called."); +} + +Glib::ustring +ResourcePolicyLiFo::get_description() const +{ + return "A resource policy which allows a request to be immediately allocated if there is enough space."; +} + +Glib::ustring +ResourcePolicyLiFo::get_name() const +{ + return "Last In, First Out"; +} + + +void +ResourcePolicyLiFo::activate() +{ +} + +void +ResourcePolicyLiFo::deactivate() +{ +} diff --git a/src/backend/resource_policy_lifo.hh b/src/backend/resource_policy_lifo.hh new file mode 100644 index 0000000..591ad97 --- /dev/null +++ b/src/backend/resource_policy_lifo.hh @@ -0,0 +1,91 @@ +// src/backend/resource_policy_lifo.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 RESOURCE_POLICY_LIFO_HH +#define RESOURCE_POLICY_LIFO_HH 1 + +#include "config.h" +#include "gettext.h" + +#include "glibmm/ustring.h" + +#include "resource_policy.hh" +#include "policy_parameters.hh" +#include "user_interrupt_exception.hh" + +namespace sgpem +{ + class ResourcePolicyLiFo; + + /** \brief + It's a Strategy wich stay for a resource allocating algorithm. + It implements the related resource allocation policy. + */ + class SG_DLLEXPORT ResourcePolicyLiFo : public ResourcePolicy + { + public: + virtual ~ResourcePolicyLiFo(); + + /** + Initialize the inner components of the policy. + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + */ + virtual void configure() throw(UserInterruptException); + + /** + Mixes the queues. + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + */ + virtual void enforce() throw(UserInterruptException); + + /** + Gets a string description of the policy. + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + \return String description of the policy. + */ + virtual Glib::ustring get_description() const; + + virtual Glib::ustring get_name() const; + + virtual void activate(); + + virtual void deactivate(); + + /** + Gets the parameters related with this policy. + + \return The policy parameters. + */ + PolicyParameters& get_parameters(); + + protected: + PolicyParameters _parameters; + }; + +}//~ namespace sgpem + + +#endif