- 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
This commit is contained in:
tchernobog 2006-07-02 10:59:46 +00:00
parent 1c72695c2b
commit 9da0ef3137
3 changed files with 17 additions and 43 deletions

View File

@ -59,10 +59,10 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment & c) :
const std::vector<Process*>&
const std::vector<const Process*>
ConcreteEnvironment::get_processes() const
{
return _processes;
return std::vector<const Process*>(_processes.begin(), _processes.end());
}
@ -75,10 +75,10 @@ ConcreteEnvironment::get_processes()
const std::map<int, Resource*>&
const std::map<int, const Resource*>
ConcreteEnvironment::get_resources() const
{
return _resources;
return std::map<int, const Resource*>(_resources.begin(), _resources.end());
}
@ -91,10 +91,10 @@ ConcreteEnvironment::get_resources()
const std::vector<Request*>
const std::vector<const Request*>
ConcreteEnvironment::get_request_queue(Resource* resource) const
{
std::vector<Request *> request_queue;
std::vector<const Request *> request_queue;
// TODO: fill that vector, walking over the classes, looking for
// those no-more-valid requests.
return request_queue;

View File

@ -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<Process*>&
virtual const std::vector<const Process*>
get_processes() const;
@ -91,7 +78,6 @@ namespace sgpem
///
/// \return a set of snapshots of processes
/// \see get_processes()
virtual std::vector<Process*>&
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<int, Resource*>&
virtual const std::map<int, const Resource*>
get_resources() const;
@ -125,7 +110,6 @@ namespace sgpem
///
/// \return an indexed set of snapshots of resources
/// \see get_resources()
virtual std::map<int, Resource*>&
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<Request*>
/// \param resource The resource the requests are for
/// \return The current ready requests queue.
virtual const std::vector<const Request*>
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<int, Resource *>
_resources;
@ -203,7 +179,6 @@ namespace sgpem
/// \brief The container of all Process objecs.
/// Actually contains only DynamicProcess objects.
std::vector<Process *>
_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

View File

@ -62,7 +62,7 @@ namespace sgpem
///
/// \return a constant set of snapshots of processes
virtual const std::vector<Process*>&
virtual const std::vector<const Process*>
get_processes() const = 0;
@ -80,7 +80,7 @@ namespace sgpem
///
/// \return an indexed constant set of snapshot of resources.
virtual const std::map<int, Resource*>&
virtual const std::map<int, const Resource*>
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<Request*>
virtual const std::vector<const Request*>
get_request_queue(const Resource * resource) const = 0;