- Added editing features to History.
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@934 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
7756a56b25
commit
8c8ce4c818
|
@ -337,6 +337,27 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConcreteHistory::edit_resource(Resource& resource,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
bool preemptable,
|
||||||
|
size_t places,
|
||||||
|
size_t availability)
|
||||||
|
{
|
||||||
|
reset(false);
|
||||||
|
|
||||||
|
// And preemptable and availability?? FIXME!
|
||||||
|
|
||||||
|
DynamicResource* res = dynamic_cast<DynamicResource*>(&resource);
|
||||||
|
StaticResource& core = res->get_core();
|
||||||
|
core.set_name(name);
|
||||||
|
core.set_places(places);
|
||||||
|
|
||||||
|
notify_change();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProcess&
|
DynamicProcess&
|
||||||
ConcreteHistory::add_process(const Glib::ustring& name,
|
ConcreteHistory::add_process(const Glib::ustring& name,
|
||||||
time_t arrival_time,
|
time_t arrival_time,
|
||||||
|
@ -355,6 +376,25 @@ ConcreteHistory::add_process(const Glib::ustring& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConcreteHistory::edit_process(Process& process,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t arrival_time,
|
||||||
|
prio_t base_priority)
|
||||||
|
{
|
||||||
|
reset(false);
|
||||||
|
|
||||||
|
DynamicProcess* proc = dynamic_cast<DynamicProcess*>(&process);
|
||||||
|
StaticProcess& core = proc->get_core();
|
||||||
|
core.set_name(name);
|
||||||
|
core.set_arrival_time(arrival_time);
|
||||||
|
core.set_priority(base_priority);
|
||||||
|
|
||||||
|
notify_change();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DynamicThread&
|
DynamicThread&
|
||||||
ConcreteHistory::add_thread(const Glib::ustring& name,
|
ConcreteHistory::add_thread(const Glib::ustring& name,
|
||||||
Process& parent,
|
Process& parent,
|
||||||
|
@ -374,6 +414,24 @@ ConcreteHistory::add_thread(const Glib::ustring& name,
|
||||||
return *thread;
|
return *thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConcreteHistory::edit_thread(Thread& thread,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t cpu_time,
|
||||||
|
time_t arrival_time,
|
||||||
|
prio_t base_priority)
|
||||||
|
{
|
||||||
|
reset(false);
|
||||||
|
|
||||||
|
DynamicThread* thre = dynamic_cast<DynamicThread*>(&thread);
|
||||||
|
StaticThread& core = thre->get_core();
|
||||||
|
core.set_name(name);
|
||||||
|
core.set_total_cpu_time(cpu_time);
|
||||||
|
core.set_arrival_time(arrival_time);
|
||||||
|
core.set_priority(base_priority);
|
||||||
|
|
||||||
|
notify_change();
|
||||||
|
}
|
||||||
|
|
||||||
DynamicRequest&
|
DynamicRequest&
|
||||||
ConcreteHistory::add_request(Thread& owner,
|
ConcreteHistory::add_request(Thread& owner,
|
||||||
|
@ -393,6 +451,19 @@ ConcreteHistory::add_request(Thread& owner,
|
||||||
return *req;
|
return *req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConcreteHistory::edit_request(Request& request,
|
||||||
|
time_t instant)
|
||||||
|
{
|
||||||
|
reset(false);
|
||||||
|
|
||||||
|
DynamicRequest* req = dynamic_cast<DynamicRequest*>(&request);
|
||||||
|
StaticRequest& core = req->get_core();
|
||||||
|
core.set_instant(instant);
|
||||||
|
|
||||||
|
notify_change();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicSubRequest&
|
DynamicSubRequest&
|
||||||
ConcreteHistory::add_subrequest(Request& request,
|
ConcreteHistory::add_subrequest(Request& request,
|
||||||
|
@ -412,6 +483,20 @@ ConcreteHistory::add_subrequest(Request& request,
|
||||||
return *subreq;
|
return *subreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConcreteHistory::edit_subrequest(SubRequest& subrequest,
|
||||||
|
resource_key_t resource_key,
|
||||||
|
time_t duration)
|
||||||
|
{
|
||||||
|
reset(false);
|
||||||
|
|
||||||
|
DynamicSubRequest* sreq = dynamic_cast<DynamicSubRequest*>(&subrequest);
|
||||||
|
StaticSubRequest& core = sreq->get_core();
|
||||||
|
core.set_resource_key(resource_key);
|
||||||
|
core.set_length(duration);
|
||||||
|
|
||||||
|
notify_change();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConcreteHistory::reset(bool notify)
|
ConcreteHistory::reset(bool notify)
|
||||||
|
|
|
@ -67,23 +67,50 @@ namespace sgpem
|
||||||
size_t places = 1,
|
size_t places = 1,
|
||||||
size_t availability = 0);
|
size_t availability = 0);
|
||||||
|
|
||||||
|
virtual void edit_resource(Resource& resource,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
bool preemptable = false,
|
||||||
|
size_t places = 1,
|
||||||
|
size_t availability = 0);
|
||||||
|
|
||||||
virtual DynamicProcess& add_process(const Glib::ustring& name,
|
virtual DynamicProcess& add_process(const Glib::ustring& name,
|
||||||
time_t arrival_time,
|
time_t arrival_time,
|
||||||
prio_t base_priority = 0);
|
prio_t base_priority = 0);
|
||||||
|
|
||||||
|
virtual void edit_process(Process& process,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t arrival_time,
|
||||||
|
prio_t base_priority = 0);
|
||||||
|
|
||||||
virtual DynamicThread& add_thread(const Glib::ustring& name,
|
virtual DynamicThread& add_thread(const Glib::ustring& name,
|
||||||
Process& parent,
|
Process& parent,
|
||||||
time_t cpu_time,
|
time_t cpu_time,
|
||||||
time_t arrival_time = 0,
|
time_t arrival_time = 0,
|
||||||
prio_t base_priority = 0);
|
prio_t base_priority = 0);
|
||||||
|
|
||||||
|
virtual void edit_thread(Thread& thread,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t cpu_time,
|
||||||
|
time_t arrival_time = 0,
|
||||||
|
prio_t base_priority = 0);
|
||||||
|
|
||||||
|
|
||||||
virtual DynamicRequest& add_request(Thread& owner,
|
virtual DynamicRequest& add_request(Thread& owner,
|
||||||
time_t instant);
|
time_t instant);
|
||||||
|
|
||||||
|
virtual void edit_request(Request& request,
|
||||||
|
time_t instant);
|
||||||
|
|
||||||
virtual DynamicSubRequest& add_subrequest(Request& request,
|
virtual DynamicSubRequest& add_subrequest(Request& request,
|
||||||
resource_key_t resource_key,
|
resource_key_t resource_key,
|
||||||
time_t duration);
|
time_t duration);
|
||||||
|
|
||||||
|
virtual void edit_subrequest(SubRequest& subrequest,
|
||||||
|
resource_key_t resource_key,
|
||||||
|
time_t duration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void reset(bool notify = true);
|
virtual void reset(bool notify = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -89,19 +89,39 @@ namespace sgpem
|
||||||
time_t arrival_time,
|
time_t arrival_time,
|
||||||
prio_t base_priority = 0) = 0;
|
prio_t base_priority = 0) = 0;
|
||||||
|
|
||||||
|
virtual void edit_process(Process& process,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t arrival_time,
|
||||||
|
prio_t base_priority = 0) = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual Thread& add_thread(const Glib::ustring& name,
|
virtual Thread& add_thread(const Glib::ustring& name,
|
||||||
Process& parent,
|
Process& parent,
|
||||||
time_t cpu_time,
|
time_t cpu_time,
|
||||||
time_t arrival_time = 0,
|
time_t arrival_time = 0,
|
||||||
prio_t base_priority = 0) = 0;
|
prio_t base_priority = 0) = 0;
|
||||||
|
|
||||||
|
virtual void edit_thread(Thread& thread,
|
||||||
|
const Glib::ustring& name,
|
||||||
|
time_t cpu_time,
|
||||||
|
time_t arrival_time = 0,
|
||||||
|
prio_t base_priority = 0) = 0;
|
||||||
|
|
||||||
virtual Request& add_request(Thread& owner,
|
virtual Request& add_request(Thread& owner,
|
||||||
time_t instant) = 0;
|
time_t instant) = 0;
|
||||||
|
|
||||||
|
virtual void edit_request(Request& request,
|
||||||
|
time_t instant) = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual SubRequest& add_subrequest(Request& request,
|
virtual SubRequest& add_subrequest(Request& request,
|
||||||
resource_key_t resource_key,
|
resource_key_t resource_key,
|
||||||
time_t duration) = 0;
|
time_t duration) = 0;
|
||||||
|
|
||||||
|
virtual void edit_subrequest(SubRequest& subrequest,
|
||||||
|
resource_key_t resource_key,
|
||||||
|
time_t duration) = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual void attach(HistoryObserver& observer);
|
virtual void attach(HistoryObserver& observer);
|
||||||
virtual void detach(const HistoryObserver& observer);
|
virtual void detach(const HistoryObserver& observer);
|
||||||
|
|
|
@ -37,6 +37,15 @@ StaticProcess::get_arrival_time() const
|
||||||
return _start_time;
|
return _start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticProcess::set_arrival_time(unsigned int time)
|
||||||
|
{
|
||||||
|
unsigned int old_start_time = _start_time;
|
||||||
|
_start_time = time;
|
||||||
|
return old_start_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
StaticProcess::get_total_cpu_time() const
|
StaticProcess::get_total_cpu_time() const
|
||||||
|
|
|
@ -49,6 +49,7 @@ namespace sgpem
|
||||||
|
|
||||||
virtual unsigned int get_total_cpu_time() const;
|
virtual unsigned int get_total_cpu_time() const;
|
||||||
virtual unsigned int get_arrival_time() const;
|
virtual unsigned int get_arrival_time() const;
|
||||||
|
virtual unsigned int set_arrival_time(unsigned int time);
|
||||||
|
|
||||||
// Does the job also of add_thread() and remove_thread(). :-)
|
// Does the job also of add_thread() and remove_thread(). :-)
|
||||||
// Since we're touching backend internals, we can do this safely
|
// Since we're touching backend internals, we can do this safely
|
||||||
|
|
|
@ -47,6 +47,14 @@ StaticRequest::get_instant() const
|
||||||
return _instant;
|
return _instant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticRequest::set_instant(unsigned int instant)
|
||||||
|
{
|
||||||
|
unsigned int old_instant = _instant;
|
||||||
|
_instant = instant;
|
||||||
|
return old_instant;
|
||||||
|
}
|
||||||
|
|
||||||
StaticThread&
|
StaticThread&
|
||||||
StaticRequest::get_thread()
|
StaticRequest::get_thread()
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace sgpem
|
||||||
~StaticRequest();
|
~StaticRequest();
|
||||||
|
|
||||||
unsigned int get_instant() const;
|
unsigned int get_instant() const;
|
||||||
|
unsigned int set_instant(unsigned int instant);
|
||||||
StaticThread& get_thread();
|
StaticThread& get_thread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -33,9 +33,26 @@ StaticResource::get_name() const
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::ustring
|
||||||
|
StaticResource::set_name(Glib::ustring name)
|
||||||
|
{
|
||||||
|
Glib::ustring old_name = _name;
|
||||||
|
_name = name;
|
||||||
|
return old_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
StaticResource::get_places() const
|
StaticResource::get_places() const
|
||||||
{
|
{
|
||||||
return _places;
|
return _places;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticResource::set_places(unsigned int places)
|
||||||
|
{
|
||||||
|
unsigned int old_places = _places;
|
||||||
|
_places = places;
|
||||||
|
return old_places;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ namespace sgpem
|
||||||
StaticResource(const Glib::ustring& name, unsigned int places = 1);
|
StaticResource(const Glib::ustring& name, unsigned int places = 1);
|
||||||
|
|
||||||
Glib::ustring get_name() const;
|
Glib::ustring get_name() const;
|
||||||
|
Glib::ustring set_name(Glib::ustring name);
|
||||||
|
|
||||||
unsigned int get_places() const;
|
unsigned int get_places() const;
|
||||||
|
unsigned int set_places(unsigned int places);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StaticResource(const StaticResource&);
|
StaticResource(const StaticResource&);
|
||||||
|
|
|
@ -38,9 +38,25 @@ StaticSchedulable::get_priority() const
|
||||||
return _priority;
|
return _priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
StaticSchedulable::set_priority(int priority)
|
||||||
|
{
|
||||||
|
int old_priority = priority;
|
||||||
|
_priority = priority;
|
||||||
|
return old_priority;
|
||||||
|
}
|
||||||
|
|
||||||
const Glib::ustring&
|
const Glib::ustring&
|
||||||
StaticSchedulable::get_name() const
|
StaticSchedulable::get_name() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Glib::ustring
|
||||||
|
StaticSchedulable::set_name(const Glib::ustring& name)
|
||||||
|
{
|
||||||
|
Glib::ustring old_name = _name;
|
||||||
|
_name = name;
|
||||||
|
return old_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,14 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual unsigned int get_arrival_time() const = 0;
|
virtual unsigned int get_arrival_time() const = 0;
|
||||||
|
|
||||||
|
/** \brief Modifies the arrival time for this process
|
||||||
|
*
|
||||||
|
* see ::get_arrival_time().
|
||||||
|
* \return the old arrival time.
|
||||||
|
*/
|
||||||
|
virtual unsigned int set_arrival_time(unsigned int time) = 0;
|
||||||
|
|
||||||
|
|
||||||
/** \brief Returns the amount of CPU time this process is going to require */
|
/** \brief Returns the amount of CPU time this process is going to require */
|
||||||
virtual unsigned int get_total_cpu_time() const = 0;
|
virtual unsigned int get_total_cpu_time() const = 0;
|
||||||
|
|
||||||
|
@ -62,6 +70,13 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual int get_priority() const;
|
virtual int get_priority() const;
|
||||||
|
|
||||||
|
/** \brief Modifies the priority of this process
|
||||||
|
*
|
||||||
|
* see ::get_priority().
|
||||||
|
* \return the old priority.
|
||||||
|
*/
|
||||||
|
virtual int set_priority(int priority);
|
||||||
|
|
||||||
/** \brief Returns a string representing this object
|
/** \brief Returns a string representing this object
|
||||||
*
|
*
|
||||||
* The name of a process is a human readable string assigned to it by the
|
* The name of a process is a human readable string assigned to it by the
|
||||||
|
@ -69,6 +84,13 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual const Glib::ustring& get_name() const;
|
virtual const Glib::ustring& get_name() const;
|
||||||
|
|
||||||
|
/** \brief Modifies the string representing this object
|
||||||
|
*
|
||||||
|
* see ::get_name().
|
||||||
|
* \return the old name.
|
||||||
|
*/
|
||||||
|
virtual const Glib::ustring set_name(const Glib::ustring& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glib::ustring _name;
|
Glib::ustring _name;
|
||||||
int _priority;
|
int _priority;
|
||||||
|
|
|
@ -53,8 +53,26 @@ StaticSubRequest::get_resource_key() const
|
||||||
return _resource_key;
|
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
|
unsigned int
|
||||||
StaticSubRequest::get_length() const
|
StaticSubRequest::get_length() const
|
||||||
{
|
{
|
||||||
return _length;
|
return _length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticSubRequest::set_length(unsigned int length)
|
||||||
|
{
|
||||||
|
unsigned int old_length = _length;
|
||||||
|
_length = length;
|
||||||
|
return old_length;
|
||||||
|
}
|
||||||
|
|
|
@ -42,8 +42,9 @@ namespace sgpem
|
||||||
~StaticSubRequest();
|
~StaticSubRequest();
|
||||||
|
|
||||||
resource_key_t get_resource_key() const;
|
resource_key_t get_resource_key() const;
|
||||||
|
resource_key_t set_resource_key(resource_key_t resource_key);
|
||||||
unsigned int get_length() const;
|
unsigned int get_length() const;
|
||||||
|
unsigned int set_length(unsigned int length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StaticSubRequest(const StaticSubRequest&);
|
StaticSubRequest(const StaticSubRequest&);
|
||||||
|
|
|
@ -55,12 +55,29 @@ StaticThread::get_total_cpu_time() const
|
||||||
return _required_cpu_time;
|
return _required_cpu_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticThread::set_total_cpu_time(unsigned int cpu_time)
|
||||||
|
{
|
||||||
|
unsigned int old_required_cpu_time = _required_cpu_time;
|
||||||
|
_required_cpu_time = cpu_time;
|
||||||
|
return old_required_cpu_time;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
StaticThread::get_arrival_time() const
|
StaticThread::get_arrival_time() const
|
||||||
{
|
{
|
||||||
return _start_time_delta;
|
return _start_time_delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
StaticThread::set_arrival_time(unsigned int arrival_time)
|
||||||
|
{
|
||||||
|
unsigned int old_start_time_delta = _start_time_delta;
|
||||||
|
_start_time_delta = arrival_time;
|
||||||
|
return old_start_time_delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
StaticProcess&
|
StaticProcess&
|
||||||
StaticThread::get_process()
|
StaticThread::get_process()
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,8 +50,12 @@ namespace sgpem
|
||||||
|
|
||||||
virtual unsigned int get_total_cpu_time() const;
|
virtual unsigned int get_total_cpu_time() const;
|
||||||
|
|
||||||
|
unsigned int set_total_cpu_time(unsigned int cpu_time);
|
||||||
|
|
||||||
virtual unsigned int get_arrival_time() const;
|
virtual unsigned int get_arrival_time() const;
|
||||||
|
|
||||||
|
virtual unsigned int set_arrival_time(unsigned int arrival_time);
|
||||||
|
|
||||||
virtual StaticProcess& get_process();
|
virtual StaticProcess& get_process();
|
||||||
|
|
||||||
// Caller can use directly the vector instead that
|
// Caller can use directly the vector instead that
|
||||||
|
|
Loading…
Reference in New Issue