- 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:
parent
1c72695c2b
commit
9da0ef3137
|
@ -59,10 +59,10 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment & c) :
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<Process*>&
|
const std::vector<const Process*>
|
||||||
ConcreteEnvironment::get_processes() const
|
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
|
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
|
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
|
// TODO: fill that vector, walking over the classes, looking for
|
||||||
// those no-more-valid requests.
|
// those no-more-valid requests.
|
||||||
return request_queue;
|
return request_queue;
|
||||||
|
|
|
@ -31,13 +31,9 @@
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SerializeVisitor;
|
class SerializeVisitor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief An implementation of the Environment class
|
/// \brief An implementation of the Environment class
|
||||||
/// Class ConcreteEnvironment implements the Environment
|
/// Class ConcreteEnvironment implements the Environment
|
||||||
/// abstract class.
|
/// abstract class.
|
||||||
|
@ -47,26 +43,18 @@ namespace sgpem
|
||||||
/// in the Environment class.
|
/// in the Environment class.
|
||||||
///
|
///
|
||||||
/// \see Environment
|
/// \see Environment
|
||||||
|
|
||||||
class ConcreteEnvironment : public Environment
|
class ConcreteEnvironment : public Environment
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief Standard constructor.
|
/// \brief Standard constructor.
|
||||||
/// Builds an empty environment.
|
/// Builds an empty environment.
|
||||||
|
|
||||||
ConcreteEnvironment();
|
ConcreteEnvironment();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief Copy constructor.
|
/// \brief Copy constructor.
|
||||||
/// Performs a deep copy of all structures.
|
/// Performs a deep copy of all structures.
|
||||||
|
|
||||||
ConcreteEnvironment(const ConcreteEnvironment & c);
|
ConcreteEnvironment(const ConcreteEnvironment & c);
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,8 +69,7 @@ namespace sgpem
|
||||||
/// always safe.
|
/// always safe.
|
||||||
///
|
///
|
||||||
/// \return a constant set of snapshots of processes
|
/// \return a constant set of snapshots of processes
|
||||||
|
virtual const std::vector<const Process*>
|
||||||
virtual const std::vector<Process*>&
|
|
||||||
get_processes() const;
|
get_processes() const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +78,6 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return a set of snapshots of processes
|
/// \return a set of snapshots of processes
|
||||||
/// \see get_processes()
|
/// \see get_processes()
|
||||||
|
|
||||||
virtual std::vector<Process*>&
|
virtual std::vector<Process*>&
|
||||||
get_processes();
|
get_processes();
|
||||||
|
|
||||||
|
@ -115,8 +101,7 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return a indexed constant set of snapshot of resources.
|
/// \return a indexed constant set of snapshot of resources.
|
||||||
/// \see DynamicSybrequest::get_resource()
|
/// \see DynamicSybrequest::get_resource()
|
||||||
|
virtual const std::map<int, const Resource*>
|
||||||
virtual const std::map<int, Resource*>&
|
|
||||||
get_resources() const;
|
get_resources() const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +110,6 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return an indexed set of snapshots of resources
|
/// \return an indexed set of snapshots of resources
|
||||||
/// \see get_resources()
|
/// \see get_resources()
|
||||||
|
|
||||||
virtual std::map<int, Resource*>&
|
virtual std::map<int, Resource*>&
|
||||||
get_resources();
|
get_resources();
|
||||||
|
|
||||||
|
@ -140,10 +124,9 @@ namespace sgpem
|
||||||
/// objects. A downcast to DynamicRequest is guaranteed to be
|
/// objects. A downcast to DynamicRequest is guaranteed to be
|
||||||
/// always safe.
|
/// always safe.
|
||||||
///
|
///
|
||||||
/// \param resource the resource the requests are for
|
/// \param resource The resource the requests are for
|
||||||
/// \return the current ready requests queue.
|
/// \return The current ready requests queue.
|
||||||
|
virtual const std::vector<const Request*>
|
||||||
virtual const std::vector<Request*>
|
|
||||||
get_request_queue(Resource * resource) const;
|
get_request_queue(Resource * resource) const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +138,6 @@ namespace sgpem
|
||||||
/// of the CPU.
|
/// of the CPU.
|
||||||
///
|
///
|
||||||
/// \return the current ready queue (constant).
|
/// \return the current ready queue (constant).
|
||||||
|
|
||||||
virtual const ReadyQueue&
|
virtual const ReadyQueue&
|
||||||
get_sorted_queue() const;
|
get_sorted_queue() const;
|
||||||
|
|
||||||
|
@ -165,7 +147,6 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return the current ready queue.
|
/// \return the current ready queue.
|
||||||
/// \see get_sorted_queue()
|
/// \see get_sorted_queue()
|
||||||
|
|
||||||
virtual ReadyQueue&
|
virtual ReadyQueue&
|
||||||
get_sorted_queue();
|
get_sorted_queue();
|
||||||
|
|
||||||
|
@ -173,7 +154,6 @@ namespace sgpem
|
||||||
|
|
||||||
/// \brief The standard virtual destructor.
|
/// \brief The standard virtual destructor.
|
||||||
/// The standard virtual destructor.
|
/// The standard virtual destructor.
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
~ConcreteEnvironment();
|
~ConcreteEnvironment();
|
||||||
|
|
||||||
|
@ -181,7 +161,6 @@ namespace sgpem
|
||||||
|
|
||||||
/// \brief Serializes the whole environment.
|
/// \brief Serializes the whole environment.
|
||||||
/// \see SerializeVisitor
|
/// \see SerializeVisitor
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
serialize(SerializeVisitor& translator) const;
|
serialize(SerializeVisitor& translator) const;
|
||||||
|
|
||||||
|
@ -189,13 +168,10 @@ namespace sgpem
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief The container of all Resource objecs.
|
/// \brief The container of all Resource objecs.
|
||||||
/// Actually contains only DynamicResource objects.
|
/// Actually contains only DynamicResource objects.
|
||||||
// resources come before processes because of
|
// resources come before processes because of
|
||||||
// destruction order. See destructor implementation
|
// destruction order. See destructor implementation
|
||||||
|
|
||||||
std::map<int, Resource *>
|
std::map<int, Resource *>
|
||||||
_resources;
|
_resources;
|
||||||
|
|
||||||
|
@ -203,7 +179,6 @@ namespace sgpem
|
||||||
|
|
||||||
/// \brief The container of all Process objecs.
|
/// \brief The container of all Process objecs.
|
||||||
/// Actually contains only DynamicProcess objects.
|
/// Actually contains only DynamicProcess objects.
|
||||||
|
|
||||||
std::vector<Process *>
|
std::vector<Process *>
|
||||||
_processes;
|
_processes;
|
||||||
|
|
||||||
|
@ -211,12 +186,11 @@ namespace sgpem
|
||||||
|
|
||||||
/// \brief The queue of the ready schedulables
|
/// \brief The queue of the ready schedulables
|
||||||
/// Does not contain the running process.
|
/// Does not contain the running process.
|
||||||
|
|
||||||
ReadyQueue
|
ReadyQueue
|
||||||
_sched_queue;
|
_sched_queue;
|
||||||
|
|
||||||
};
|
}; //~ class ConcreteEnvironment
|
||||||
|
|
||||||
}
|
} //~ namespace sgpem
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return a constant set of snapshots of processes
|
/// \return a constant set of snapshots of processes
|
||||||
|
|
||||||
virtual const std::vector<Process*>&
|
virtual const std::vector<const Process*>
|
||||||
get_processes() const = 0;
|
get_processes() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace sgpem
|
||||||
///
|
///
|
||||||
/// \return an indexed constant set of snapshot of resources.
|
/// \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;
|
get_resources() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace sgpem
|
||||||
/// \param resource the resource the requests are for
|
/// \param resource the resource the requests are for
|
||||||
/// \return the current ready requests queue (constant).
|
/// \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;
|
get_request_queue(const Resource * resource) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue