From 9da0ef31373c076636a2176601b51fbfd158e448 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sun, 2 Jul 2006 10:59:46 +0000 Subject: [PATCH] - Fix const methods to return containers of const objects git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@687 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/backend/concrete_environment.cc | 14 +++++----- src/backend/concrete_environment.hh | 40 +++++------------------------ src/backend/environment.hh | 6 ++--- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/backend/concrete_environment.cc b/src/backend/concrete_environment.cc index a445db4..36d69d3 100644 --- a/src/backend/concrete_environment.cc +++ b/src/backend/concrete_environment.cc @@ -59,10 +59,10 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment & c) : -const std::vector& +const std::vector ConcreteEnvironment::get_processes() const { - return _processes; + return std::vector(_processes.begin(), _processes.end()); } @@ -75,10 +75,10 @@ ConcreteEnvironment::get_processes() -const std::map& +const std::map ConcreteEnvironment::get_resources() const { - return _resources; + return std::map(_resources.begin(), _resources.end()); } @@ -91,10 +91,10 @@ ConcreteEnvironment::get_resources() -const std::vector -ConcreteEnvironment::get_request_queue(Resource * resource) const +const std::vector +ConcreteEnvironment::get_request_queue(Resource* resource) const { - std::vector request_queue; + std::vector request_queue; // TODO: fill that vector, walking over the classes, looking for // those no-more-valid requests. return request_queue; diff --git a/src/backend/concrete_environment.hh b/src/backend/concrete_environment.hh index 71aca26..60a0adb 100644 --- a/src/backend/concrete_environment.hh +++ b/src/backend/concrete_environment.hh @@ -31,13 +31,9 @@ namespace sgpem { - - - class SerializeVisitor; - /// \brief An implementation of the Environment class /// Class ConcreteEnvironment implements the Environment /// abstract class. @@ -47,26 +43,18 @@ namespace sgpem /// in the Environment class. /// /// \see Environment - class ConcreteEnvironment : public Environment { - - public: - - - /// \brief Standard constructor. /// Builds an empty environment. - ConcreteEnvironment(); /// \brief Copy constructor. /// Performs a deep copy of all structures. - ConcreteEnvironment(const ConcreteEnvironment & c); @@ -81,8 +69,7 @@ namespace sgpem /// always safe. /// /// \return a constant set of snapshots of processes - - virtual const std::vector& + virtual const std::vector get_processes() const; @@ -91,7 +78,6 @@ namespace sgpem /// /// \return a set of snapshots of processes /// \see get_processes() - virtual std::vector& get_processes(); @@ -115,8 +101,7 @@ namespace sgpem /// /// \return a indexed constant set of snapshot of resources. /// \see DynamicSybrequest::get_resource() - - virtual const std::map& + virtual const std::map get_resources() const; @@ -125,7 +110,6 @@ namespace sgpem /// /// \return an indexed set of snapshots of resources /// \see get_resources() - virtual std::map& get_resources(); @@ -140,10 +124,9 @@ namespace sgpem /// objects. A downcast to DynamicRequest is guaranteed to be /// always safe. /// - /// \param resource the resource the requests are for - /// \return the current ready requests queue. - - virtual const std::vector + /// \param resource The resource the requests are for + /// \return The current ready requests queue. + virtual const std::vector get_request_queue(Resource * resource) const; @@ -155,7 +138,6 @@ namespace sgpem /// of the CPU. /// /// \return the current ready queue (constant). - virtual const ReadyQueue& get_sorted_queue() const; @@ -165,7 +147,6 @@ namespace sgpem /// /// \return the current ready queue. /// \see get_sorted_queue() - virtual ReadyQueue& get_sorted_queue(); @@ -173,7 +154,6 @@ namespace sgpem /// \brief The standard virtual destructor. /// The standard virtual destructor. - virtual ~ConcreteEnvironment(); @@ -181,7 +161,6 @@ namespace sgpem /// \brief Serializes the whole environment. /// \see SerializeVisitor - virtual void serialize(SerializeVisitor& translator) const; @@ -189,13 +168,10 @@ namespace sgpem private: - - /// \brief The container of all Resource objecs. /// Actually contains only DynamicResource objects. // resources come before processes because of // destruction order. See destructor implementation - std::map _resources; @@ -203,7 +179,6 @@ namespace sgpem /// \brief The container of all Process objecs. /// Actually contains only DynamicProcess objects. - std::vector _processes; @@ -211,12 +186,11 @@ namespace sgpem /// \brief The queue of the ready schedulables /// Does not contain the running process. - ReadyQueue _sched_queue; - }; + }; //~ class ConcreteEnvironment -} +} //~ namespace sgpem #endif diff --git a/src/backend/environment.hh b/src/backend/environment.hh index ef64390..9913010 100644 --- a/src/backend/environment.hh +++ b/src/backend/environment.hh @@ -62,7 +62,7 @@ namespace sgpem /// /// \return a constant set of snapshots of processes - virtual const std::vector& + virtual const std::vector get_processes() const = 0; @@ -80,7 +80,7 @@ namespace sgpem /// /// \return an indexed constant set of snapshot of resources. - virtual const std::map& + virtual const std::map get_resources() const = 0; @@ -91,7 +91,7 @@ namespace sgpem /// \param resource the resource the requests are for /// \return the current ready requests queue (constant). - virtual const std::vector + virtual const std::vector get_request_queue(const Resource * resource) const = 0;