// src/backend/static_sub_request.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 "static_request.hh"
#include "static_sub_request.hh"

#include <algorithm>
#include <cstddef>
#include <cassert>

using namespace sgpem;

StaticSubRequest::StaticSubRequest(resource_key_t resource_key,
                                   unsigned int length) :
    _resource_key(resource_key),
    _length(length)
{
  //A static request doesn't keep track of its static subrequests
  //at least for now.
  //req->get_subrequests().push_back(this);
}


StaticSubRequest::~StaticSubRequest()
{
  // See comment in constructor.

  // typedef std::vector<StaticSubRequest*> SubRequests;
  // SubRequests siblings& = _static_request.get_subrequests();
  // siblings.erase(find(siblings.begin(), siblings.end(), this));
}

SubRequest::resource_key_t
StaticSubRequest::get_resource_key() const
{
  return _resource_key;
}

SubRequest::resource_key_t
StaticSubRequest::set_resource_key(SubRequest::resource_key_t resource_key)
{
  SubRequest::resource_key_t old_resource_key = _resource_key;
  _resource_key = resource_key;
  return old_resource_key;
}



unsigned int
StaticSubRequest::get_length() const
{
  return _length;
}

unsigned int
StaticSubRequest::set_length(unsigned int length)
{
  unsigned int old_length = _length;
  _length = length;
  return old_length;
}
