// src/backend/static_sub_request.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 3 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, see http://www.gnu.org/licenses/.


#ifndef STATIC_SUB_REQUEST_HH
#define STATIC_SUB_REQUEST_HH 1



#include <sgpemv2/sub_request.hh>

namespace sgpem
{


  /// \brief Represents the static description of a request.
  ///
  /// Represents the static description of a request.
  /// The attributes stored in a static entity are static in the sense that
  /// they are user-set and no inner mechanism of the Backend component may
  /// change these attributes without the user having explicitly asked it.
  ///
  /// This is enforced by not providing any setter method, and by making the
  /// copy constructor private. This makes clear that if you want to edit a
  /// static entity, you should reset the ::History, remove the old static
  /// entity, and create a new dynamic entity for the new static one.
  class StaticSubRequest;

  class StaticRequest;
  class StaticResource;

  class SG_DLLLOCAL StaticSubRequest
  {
  public:
    typedef SubRequest::resource_key_t resource_key_t;

    /// \brief Constructor taking the resource id, and the length.
    /// 
    /// Create a StaticSubRequest with assigned StaticResource, 
    /// for one single places, and for a defined length.
    /// \param resource_key the id of the requested resource
    /// \param length the time the resource is needed.
    StaticSubRequest(resource_key_t resource_key, unsigned int length);

    /// \brief Standard virtual destructor.
    ///
    /// Standard virtual destructor.
    ~StaticSubRequest();

    /// \brief Returns the id of the requested resource.
    ///
    /// Returns the id of the requested resource.
    /// \return the id of the requested resource.
    resource_key_t get_resource_key() const;

    /// \brief Changes the requested resource.
    ///
    /// Changes the requested resource by changing the related id.
    /// \param resource_key the id of the new requested resource.
    /// \return the id of the old requested resource.
    resource_key_t set_resource_key(resource_key_t resource_key);

    /// \brief Returns the length of the request.
    ///
    /// Returns the length of the request.
    /// \return the length of the request.
    unsigned int get_length() const;

    /// \brief Modifies the length of the request.
    ///
    /// Modifies the length of the request.
    /// \param length the new lenght of the request.
    /// \return the old length of the request.
    unsigned int set_length(unsigned int length);

  private:
    /// \brief Private standard copy constructor
    ///
    StaticSubRequest(const StaticSubRequest&);

    /// \brief Private standard operator assingment.
    ///
    StaticSubRequest& operator=(const StaticSubRequest&);

    /// The id of the requested resource
    ///
    resource_key_t _resource_key;

    /// How long (how many time cycles) the resource is needed.
    ///
    unsigned int _length;
  };

}

#endif

