- 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:
matrevis 2006-08-23 22:55:08 +00:00
parent 7756a56b25
commit 8c8ce4c818
15 changed files with 252 additions and 3 deletions

View File

@ -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&
ConcreteHistory::add_process(const Glib::ustring& name,
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&
ConcreteHistory::add_thread(const Glib::ustring& name,
Process& parent,
@ -374,6 +414,24 @@ ConcreteHistory::add_thread(const Glib::ustring& name,
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&
ConcreteHistory::add_request(Thread& owner,
@ -393,6 +451,19 @@ ConcreteHistory::add_request(Thread& owner,
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&
ConcreteHistory::add_subrequest(Request& request,
@ -412,6 +483,20 @@ ConcreteHistory::add_subrequest(Request& request,
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
ConcreteHistory::reset(bool notify)

View File

@ -67,22 +67,49 @@ namespace sgpem
size_t places = 1,
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,
time_t arrival_time,
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,
Process& parent,
time_t cpu_time,
time_t arrival_time = 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,
time_t instant);
virtual void edit_request(Request& request,
time_t instant);
virtual DynamicSubRequest& add_subrequest(Request& request,
resource_key_t resource_key,
time_t duration);
resource_key_t resource_key,
time_t duration);
virtual void edit_subrequest(SubRequest& subrequest,
resource_key_t resource_key,
time_t duration);
virtual void reset(bool notify = true);

View File

@ -89,19 +89,39 @@ namespace sgpem
time_t arrival_time,
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,
Process& parent,
time_t cpu_time,
time_t arrival_time = 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,
time_t instant) = 0;
virtual void edit_request(Request& request,
time_t instant) = 0;
virtual SubRequest& add_subrequest(Request& request,
resource_key_t resource_key,
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 detach(const HistoryObserver& observer);

View File

@ -37,6 +37,15 @@ StaticProcess::get_arrival_time() const
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
StaticProcess::get_total_cpu_time() const

View File

@ -49,6 +49,7 @@ namespace sgpem
virtual unsigned int get_total_cpu_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(). :-)
// Since we're touching backend internals, we can do this safely

View File

@ -47,6 +47,14 @@ StaticRequest::get_instant() const
return _instant;
}
unsigned int
StaticRequest::set_instant(unsigned int instant)
{
unsigned int old_instant = _instant;
_instant = instant;
return old_instant;
}
StaticThread&
StaticRequest::get_thread()
{

View File

@ -38,6 +38,7 @@ namespace sgpem
~StaticRequest();
unsigned int get_instant() const;
unsigned int set_instant(unsigned int instant);
StaticThread& get_thread();
private:

View File

@ -33,9 +33,26 @@ StaticResource::get_name() const
return _name;
}
Glib::ustring
StaticResource::set_name(Glib::ustring name)
{
Glib::ustring old_name = _name;
_name = name;
return old_name;
}
unsigned int
StaticResource::get_places() const
{
return _places;
}
unsigned int
StaticResource::set_places(unsigned int places)
{
unsigned int old_places = _places;
_places = places;
return old_places;
}

View File

@ -35,7 +35,10 @@ namespace sgpem
StaticResource(const Glib::ustring& name, unsigned int places = 1);
Glib::ustring get_name() const;
Glib::ustring set_name(Glib::ustring name);
unsigned int get_places() const;
unsigned int set_places(unsigned int places);
private:
StaticResource(const StaticResource&);

View File

@ -38,9 +38,25 @@ StaticSchedulable::get_priority() const
return _priority;
}
int
StaticSchedulable::set_priority(int priority)
{
int old_priority = priority;
_priority = priority;
return old_priority;
}
const Glib::ustring&
StaticSchedulable::get_name() const
{
return _name;
}
const Glib::ustring
StaticSchedulable::set_name(const Glib::ustring& name)
{
Glib::ustring old_name = _name;
_name = name;
return old_name;
}

View File

@ -52,6 +52,14 @@ namespace sgpem
*/
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 */
virtual unsigned int get_total_cpu_time() const = 0;
@ -62,6 +70,13 @@ namespace sgpem
*/
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
*
* 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;
/** \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:
Glib::ustring _name;
int _priority;

View File

@ -53,8 +53,26 @@ StaticSubRequest::get_resource_key() const
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
StaticSubRequest::get_length() const
{
return _length;
}
unsigned int
StaticSubRequest::set_length(unsigned int length)
{
unsigned int old_length = _length;
_length = length;
return old_length;
}

View File

@ -42,8 +42,9 @@ namespace sgpem
~StaticSubRequest();
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 set_length(unsigned int length);
private:
StaticSubRequest(const StaticSubRequest&);

View File

@ -55,12 +55,29 @@ StaticThread::get_total_cpu_time() const
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
StaticThread::get_arrival_time() const
{
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&
StaticThread::get_process()
{

View File

@ -50,8 +50,12 @@ namespace sgpem
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 set_arrival_time(unsigned int arrival_time);
virtual StaticProcess& get_process();
// Caller can use directly the vector instead that