- I forgot to include a pair of files.

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@959 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-08-28 22:45:02 +00:00
parent f3dc9b77df
commit 0520169288
4 changed files with 268 additions and 0 deletions

View File

@ -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<ResourcePolicy*>&
DefaultResourcePolicyManager::get_avail_policies() const
{
return _policies;
}

View File

@ -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 <vector>
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<ResourcePolicy*>& get_avail_policies() const;
private:
std::vector<ResourcePolicy*> _policies;
};
} //~ namespace sgpem
#endif

View File

@ -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()
{
}

View File

@ -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