Reformat using clang-format

This commit is contained in:
Matteo Settenvini 2018-09-25 10:20:45 +02:00
parent c1ac6f279b
commit ffd4b6b319
197 changed files with 13059 additions and 13569 deletions

View File

@ -22,26 +22,25 @@
#include <sgpemv2/templates/sequences.tcc> #include <sgpemv2/templates/sequences.tcc>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh> #include <sgpemv2/environment.hh>
#include <sgpemv2/simulation.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/resource.hh> #include <sgpemv2/resource.hh>
#include <sgpemv2/simulation.hh>
#include "gettext.h" #include "gettext.h"
#include <gtkmm/spinbutton.h> #include <gtkmm/spinbutton.h>
#include <cassert>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cassert>
using namespace sgpem; using namespace sgpem;
using namespace Gtk; using namespace Gtk;
using namespace Glib; using namespace Glib;
using std::vector; using std::vector;
AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Builder>& ui) : AddRequestDialog::AddRequestDialog (BaseObjectType *cobject, const RefPtr<Builder> &ui) : Dialog (cobject), _ui (ui)
Dialog(cobject), _ui(ui)
{ {
_ui->get_widget ("SubRequests.View", _list); _ui->get_widget ("SubRequests.View", _list);
_ui->get_widget ("Add", _add_button); _ui->get_widget ("Add", _add_button);
@ -54,11 +53,9 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Builder
/** ATTACH SIGNAL HANDLERS FOR BUTTONS **/ /** ATTACH SIGNAL HANDLERS FOR BUTTONS **/
_add_button->signal_clicked().connect( _add_button->signal_clicked ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_add));
sigc::mem_fun(*this, &AddRequestDialog::_on_add));
_remove_button->signal_clicked().connect( _remove_button->signal_clicked ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_remove));
sigc::mem_fun(*this, &AddRequestDialog::_on_remove));
_ok_button->set_sensitive (false); _ok_button->set_sensitive (false);
_remove_button->set_sensitive (false); _remove_button->set_sensitive (false);
@ -73,8 +70,7 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Builder
_resource_combo->pack_start (_combo_key_column, false); _resource_combo->pack_start (_combo_key_column, false);
_resource_combo->pack_start (_combo_resource_column, true); _resource_combo->pack_start (_combo_resource_column, true);
_resource_combo->signal_changed().connect( _resource_combo->signal_changed ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_combo_selection_changed));
sigc::mem_fun(*this, &AddRequestDialog::_on_combo_selection_changed));
/** INITIALIZE LISTVIEW **/ /** INITIALIZE LISTVIEW **/
@ -85,18 +81,15 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Builder
_list_model = ListStore::create (_list_columns); _list_model = ListStore::create (_list_columns);
_list->set_model (_list_model); _list->set_model (_list_model);
_list_model->signal_row_deleted().connect( _list_model->signal_row_deleted ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_row_removed));
sigc::mem_fun(*this, &AddRequestDialog::_on_row_removed));
_list_model->signal_row_inserted().connect( _list_model->signal_row_inserted ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_row_added));
sigc::mem_fun(*this, &AddRequestDialog::_on_row_added));
_list->append_column (_ ("key"), _list_key_column); _list->append_column (_ ("key"), _list_key_column);
_list->append_column (_ ("resource"), _list_resource_column); _list->append_column (_ ("resource"), _list_resource_column);
_list->append_column (_ ("duration"), _list_duration_column); _list->append_column (_ ("duration"), _list_duration_column);
_list->get_selection()->signal_changed().connect( _list->get_selection ()->signal_changed ().connect (sigc::mem_fun (*this, &AddRequestDialog::_on_list_selection_changed));
sigc::mem_fun(*this, &AddRequestDialog::_on_list_selection_changed));
} }
Request * Request *
@ -186,8 +179,7 @@ AddRequestDialog::update_combo()
{ {
typedef Environment::Resources::const_iterator ResourceIt; typedef Environment::Resources::const_iterator ResourceIt;
const Environment::Resources& resources = const Environment::Resources &resources = Simulation::get_instance ().get_history ().get_last_environment ().get_resources ();
Simulation::get_instance().get_history().get_last_environment().get_resources();
_combo_model->clear (); _combo_model->clear ();
@ -228,8 +220,7 @@ AddRequestDialog::_on_remove()
void void
AddRequestDialog::_on_list_selection_changed () AddRequestDialog::_on_list_selection_changed ()
{ {
_remove_button->set_sensitive( _remove_button->set_sensitive (_list->get_selection ()->count_selected_rows () > 0);
_list->get_selection()->count_selected_rows() > 0);
} }
void void

View File

@ -26,14 +26,14 @@ namespace sgpem
class Request; class Request;
class Thread; class Thread;
class AddRequestDialog; class AddRequestDialog;
} } // namespace sgpem
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
#include <gtkmm/dialog.h>
#include <gtkmm/combobox.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/builder.h> #include <gtkmm/builder.h>
#include <gtkmm/combobox.h>
#include <gtkmm/dialog.h>
#include <gtkmm/liststore.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/treeview.h>
namespace sgpem namespace sgpem
{ {
@ -124,7 +124,7 @@ namespace sgpem
Gtk::TreeModelColumn<Glib::ustring> _combo_resource_column; Gtk::TreeModelColumn<Glib::ustring> _combo_resource_column;
}; };
} //~ namespace sgpem } // namespace sgpem
#endif //~ ADD_REQUEST_DIALOG_HH #endif //~ ADD_REQUEST_DIALOG_HH

View File

@ -42,8 +42,8 @@ ConcreteEnvironment::ConcreteEnvironment()
} }
ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) : ConcreteEnvironment::ConcreteEnvironment (const ConcreteEnvironment &ce)
Environment(ce), _resources(ce._resources), _processes(), _sched_queue(), _sreq_queues(ce._sreq_queues) : Environment (ce), _resources (ce._resources), _processes (), _sched_queue (), _sreq_queues (ce._sreq_queues)
{ {
// The ReadyQueue won't be copied. Pointers to objects contained into // The ReadyQueue won't be copied. Pointers to objects contained into
// the ready queue _will_ have changed in the new one. The ready queue // the ready queue _will_ have changed in the new one. The ready queue
@ -65,7 +65,6 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
} }
// Update the subrequest queues. // Update the subrequest queues.
// for each subrequest // for each subrequest
@ -117,12 +116,9 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
} }
} }
} }
} }
const Environment::Processes & const Environment::Processes &
ConcreteEnvironment::get_processes () const ConcreteEnvironment::get_processes () const
{ {
@ -130,7 +126,6 @@ ConcreteEnvironment::get_processes() const
} }
ConcreteEnvironment::Processes & ConcreteEnvironment::Processes &
ConcreteEnvironment::get_processes () ConcreteEnvironment::get_processes ()
{ {
@ -138,7 +133,6 @@ ConcreteEnvironment::get_processes()
} }
const Environment::Resources & const Environment::Resources &
ConcreteEnvironment::get_resources () const ConcreteEnvironment::get_resources () const
{ {
@ -146,7 +140,6 @@ ConcreteEnvironment::get_resources() const
} }
ConcreteEnvironment::Resources & ConcreteEnvironment::Resources &
ConcreteEnvironment::get_resources () ConcreteEnvironment::get_resources ()
{ {
@ -154,7 +147,6 @@ ConcreteEnvironment::get_resources()
} }
const Environment::SubRequestQueue & const Environment::SubRequestQueue &
ConcreteEnvironment::get_request_queue (resource_key_t resource_key) const ConcreteEnvironment::get_request_queue (resource_key_t resource_key) const
{ {
@ -177,7 +169,6 @@ ConcreteEnvironment::get_subrequest_queues()
} }
const ReadyQueue & const ReadyQueue &
ConcreteEnvironment::get_sorted_queue () const ConcreteEnvironment::get_sorted_queue () const
{ {
@ -185,7 +176,6 @@ ConcreteEnvironment::get_sorted_queue() const
} }
ReadyQueue & ReadyQueue &
ConcreteEnvironment::get_sorted_queue () ConcreteEnvironment::get_sorted_queue ()
{ {
@ -193,13 +183,11 @@ ConcreteEnvironment::get_sorted_queue()
} }
ConcreteEnvironment::~ConcreteEnvironment () ConcreteEnvironment::~ConcreteEnvironment ()
{ {
// This call will invoke the DynamicProcess virtual destructor // This call will invoke the DynamicProcess virtual destructor
// Which will delete on cascade all DynamicThreads and so on. // Which will delete on cascade all DynamicThreads and so on.
for_each(_processes.begin(), _processes.end(), for_each (_processes.begin (), _processes.end (), [](auto *p) { delete p; });
[] (auto *p) { delete p; });
// We do the same with Resources. // We do the same with Resources.
for (Resources::iterator it = _resources.begin (); it != _resources.end (); it++) for (Resources::iterator it = _resources.begin (); it != _resources.end (); it++)
@ -211,7 +199,4 @@ ConcreteEnvironment::~ConcreteEnvironment()
} }
// -------------------------------- TO BE FIXED ---------------- // -------------------------------- TO BE FIXED ----------------

View File

@ -25,14 +25,14 @@ namespace sgpem
{ {
class ConcreteEnvironment; class ConcreteEnvironment;
class SerializeVisitor; class SerializeVisitor;
} } // namespace sgpem
#include "dynamic_process.hh" #include "dynamic_process.hh"
#include "dynamic_request.hh" #include "dynamic_request.hh"
#include <sgpemv2/environment.hh> #include <sgpemv2/environment.hh>
#include <sgpemv2/resource.hh>
#include <sgpemv2/ready_queue.hh> #include <sgpemv2/ready_queue.hh>
#include <sgpemv2/resource.hh>
namespace sgpem namespace sgpem
{ {
@ -152,7 +152,6 @@ namespace sgpem
virtual ReadyQueue &get_sorted_queue (); virtual ReadyQueue &get_sorted_queue ();
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.
@ -174,6 +173,6 @@ namespace sgpem
}; //~ class ConcreteEnvironment }; //~ class ConcreteEnvironment
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -18,19 +18,17 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include "dynamic_process.hh" #include "dynamic_process.hh"
#include "dynamic_thread.hh"
#include "dynamic_resource.hh"
#include "dynamic_request.hh" #include "dynamic_request.hh"
#include "dynamic_resource.hh"
#include "dynamic_sub_request.hh" #include "dynamic_sub_request.hh"
#include "dynamic_thread.hh"
#include "static_process.hh" #include "static_process.hh"
#include "static_thread.hh"
#include "static_resource.hh"
#include "static_request.hh" #include "static_request.hh"
#include "static_resource.hh"
#include "static_sub_request.hh" #include "static_sub_request.hh"
#include "static_thread.hh"
#include "concrete_history.hh" #include "concrete_history.hh"
@ -55,7 +53,8 @@ using namespace std;
// remove a template object from vector of pointers // remove a template object from vector of pointers
template <typename T> template <typename T>
static bool deep_remove(std::vector<T*>& v, const T& obj) static bool
deep_remove (std::vector<T *> &v, const T &obj)
{ {
typedef typename std::vector<T *> Vector; typedef typename std::vector<T *> Vector;
for (typename Vector::iterator it = v.begin (); it != v.end (); it++) for (typename Vector::iterator it = v.begin (); it != v.end (); it++)
@ -71,7 +70,8 @@ static bool deep_remove(std::vector<T*>& v, const T& obj)
// find a template T object into a vector of T pointers // find a template T object into a vector of T pointers
template <typename T> template <typename T>
static T* deep_find(const std::vector<T*>& v, const T& obj) static T *
deep_find (const std::vector<T *> &v, const T &obj)
{ {
typedef typename std::vector<T *> Vector; typedef typename std::vector<T *> Vector;
for (typename Vector::const_iterator it = v.begin (); it != v.end (); it++) for (typename Vector::const_iterator it = v.begin (); it != v.end (); it++)
@ -85,8 +85,7 @@ static T* deep_find(const std::vector<T*>& v, const T& obj)
// ----------------- // -----------------
ConcreteHistory::ConcreteHistory() ConcreteHistory::ConcreteHistory () : History (), _snapshots (), _sealed (false)
: History(), _snapshots(), _sealed(false)
{ {
_snapshots.push_back (new ConcreteEnvironment ()); _snapshots.push_back (new ConcreteEnvironment ());
} }
@ -94,12 +93,10 @@ ConcreteHistory::ConcreteHistory()
ConcreteHistory::~ConcreteHistory () ConcreteHistory::~ConcreteHistory ()
{ {
for_each(_snapshots.begin(), _snapshots.end(), for_each (_snapshots.begin (), _snapshots.end (), [](auto *p) { delete p; });
[] (auto *p) { delete p; });
} }
ConcreteHistory::ConcreteHistory(const ConcreteHistory& h) : ConcreteHistory::ConcreteHistory (const ConcreteHistory &h) : History (h), _sealed (h._sealed)
History(h), _sealed(h._sealed)
{ {
typedef Snapshots::const_iterator SnapIt; typedef Snapshots::const_iterator SnapIt;
for (SnapIt it = h._snapshots.begin (); it != h._snapshots.end (); ++it) for (SnapIt it = h._snapshots.begin (); it != h._snapshots.end (); ++it)
@ -301,10 +298,7 @@ ConcreteHistory::clear()
ConcreteHistory::ResourcePair ConcreteHistory::ResourcePair
ConcreteHistory::add_resource(const Glib::ustring& name, ConcreteHistory::add_resource (const Glib::ustring &name, bool /*preemptable*/, size_t places, size_t /*availability*/)
bool /*preemptable*/,
size_t places,
size_t /*availability*/)
{ {
typedef ConcreteEnvironment::Resources Resources; typedef ConcreteEnvironment::Resources Resources;
typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue; typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue;
@ -334,11 +328,7 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
void void
ConcreteHistory::edit_resource(Resource& resource, ConcreteHistory::edit_resource (Resource &resource, const Glib::ustring &name, bool /*preemptable*/, size_t places, size_t /*availability*/)
const Glib::ustring& name,
bool /*preemptable*/,
size_t places,
size_t /*availability*/)
{ {
// And preemptable and availability?? FIXME! // And preemptable and availability?? FIXME!
@ -352,9 +342,7 @@ ConcreteHistory::edit_resource(Resource& resource,
DynamicProcess & DynamicProcess &
ConcreteHistory::add_process(const Glib::ustring& name, ConcreteHistory::add_process (const Glib::ustring &name, time_t arrival_time, prio_t base_priority)
time_t arrival_time,
prio_t base_priority)
{ {
StaticProcess *core = new StaticProcess (name, arrival_time, base_priority); StaticProcess *core = new StaticProcess (name, arrival_time, base_priority);
DynamicProcess *proc = new DynamicProcess (core); DynamicProcess *proc = new DynamicProcess (core);
@ -369,10 +357,7 @@ ConcreteHistory::add_process(const Glib::ustring& name,
void void
ConcreteHistory::edit_process(Process& process, ConcreteHistory::edit_process (Process &process, const Glib::ustring &name, time_t arrival_time, prio_t base_priority)
const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority)
{ {
DynamicProcess *proc = down_cast<DynamicProcess *> (&process); DynamicProcess *proc = down_cast<DynamicProcess *> (&process);
StaticProcess &core = proc->get_core (); StaticProcess &core = proc->get_core ();
@ -384,17 +369,13 @@ ConcreteHistory::edit_process(Process& process,
} }
DynamicThread & DynamicThread &
ConcreteHistory::add_thread(const Glib::ustring& name, ConcreteHistory::add_thread (const Glib::ustring &name, Process &parent, time_t cpu_time, time_t arrival_time, prio_t base_priority)
Process& parent,
time_t cpu_time,
time_t arrival_time,
prio_t base_priority)
{ {
ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes (); ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes ();
Process *p = deep_find<Process> (processes, parent); Process *p = deep_find<Process> (processes, parent);
if(!p) throw std::runtime_error(_("History::add_thread() : Parent process not part of this History")); if (!p)
throw std::runtime_error (_ ("History::add_thread() : Parent process not part of this History"));
DynamicProcess &parent_process = down_cast<DynamicProcess &> (*p); DynamicProcess &parent_process = down_cast<DynamicProcess &> (*p);
StaticProcess &parent_core = parent_process.get_core (); StaticProcess &parent_core = parent_process.get_core ();
@ -407,11 +388,7 @@ ConcreteHistory::add_thread(const Glib::ustring& name,
} }
void void
ConcreteHistory::edit_thread(Thread& thread, ConcreteHistory::edit_thread (Thread &thread, const Glib::ustring &name, time_t cpu_time, time_t arrival_time, prio_t base_priority)
const Glib::ustring& name,
time_t cpu_time,
time_t arrival_time,
prio_t base_priority)
{ {
DynamicThread *thre = down_cast<DynamicThread *> (&thread); DynamicThread *thre = down_cast<DynamicThread *> (&thread);
StaticThread &core = thre->get_core (); StaticThread &core = thre->get_core ();
@ -424,15 +401,16 @@ ConcreteHistory::edit_thread(Thread& thread,
} }
DynamicRequest & DynamicRequest &
ConcreteHistory::add_request(Thread& owner, ConcreteHistory::add_request (Thread &owner, time_t instant)
time_t instant)
{ {
ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes (); ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes ();
Process *p = deep_find (processes, owner.get_process ()); Process *p = deep_find (processes, owner.get_process ());
if(!p) throw std::runtime_error(_("History::add_request() : Parent process not part of this History")); if (!p)
throw std::runtime_error (_ ("History::add_request() : Parent process not part of this History"));
Thread *t = deep_find (p->get_threads (), owner); Thread *t = deep_find (p->get_threads (), owner);
if(!t) throw std::runtime_error(_("History::add_request() : Parent thread not part of this History")); if (!t)
throw std::runtime_error (_ ("History::add_request() : Parent thread not part of this History"));
DynamicThread &dyn_owner = down_cast<DynamicThread &> (*t); DynamicThread &dyn_owner = down_cast<DynamicThread &> (*t);
StaticThread &owner_core = dyn_owner.get_core (); StaticThread &owner_core = dyn_owner.get_core ();
@ -446,8 +424,7 @@ ConcreteHistory::add_request(Thread& owner,
} }
void void
ConcreteHistory::edit_request(Request& request, ConcreteHistory::edit_request (Request &request, time_t instant)
time_t instant)
{ {
DynamicRequest *req = down_cast<DynamicRequest *> (&request); DynamicRequest *req = down_cast<DynamicRequest *> (&request);
StaticRequest &core = req->get_core (); StaticRequest &core = req->get_core ();
@ -458,18 +435,19 @@ ConcreteHistory::edit_request(Request& request,
DynamicSubRequest & DynamicSubRequest &
ConcreteHistory::add_subrequest(Request& request, ConcreteHistory::add_subrequest (Request &request, resource_key_t resource_key, time_t duration)
resource_key_t resource_key,
time_t duration)
{ {
ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes (); ConcreteEnvironment::Processes &processes = _snapshots.front ()->get_processes ();
Process *p = deep_find (processes, request.get_thread ().get_process ()); Process *p = deep_find (processes, request.get_thread ().get_process ());
if(!p) throw std::runtime_error(_("History::add_subrequest() : Parent process not part of this History")); if (!p)
throw std::runtime_error (_ ("History::add_subrequest() : Parent process not part of this History"));
Thread *t = deep_find (p->get_threads (), request.get_thread ()); Thread *t = deep_find (p->get_threads (), request.get_thread ());
if(!t) throw std::runtime_error(_("History::add_subrequest() : Parent thread not part of this History")); if (!t)
throw std::runtime_error (_ ("History::add_subrequest() : Parent thread not part of this History"));
Request *r = deep_find (t->get_requests (), request); Request *r = deep_find (t->get_requests (), request);
if(!r) throw std::runtime_error(_("History::add_subrequest() : Parent request not part of this History")); if (!r)
throw std::runtime_error (_ ("History::add_subrequest() : Parent request not part of this History"));
DynamicRequest &dyn_request = down_cast<DynamicRequest &> (*r); DynamicRequest &dyn_request = down_cast<DynamicRequest &> (*r);
@ -482,9 +460,7 @@ ConcreteHistory::add_subrequest(Request& request,
} }
void void
ConcreteHistory::edit_subrequest(SubRequest& subrequest, ConcreteHistory::edit_subrequest (SubRequest &subrequest, resource_key_t resource_key, time_t duration)
resource_key_t resource_key,
time_t duration)
{ {
DynamicSubRequest *sreq = down_cast<DynamicSubRequest *> (&subrequest); DynamicSubRequest *sreq = down_cast<DynamicSubRequest *> (&subrequest);
StaticSubRequest &core = sreq->get_core (); StaticSubRequest &core = sreq->get_core ();

View File

@ -64,52 +64,30 @@ namespace sgpem
virtual void clear (); virtual void clear ();
virtual ResourcePair add_resource(const Glib::ustring& name, virtual ResourcePair
bool preemptable = false, add_resource (const Glib::ustring &name, bool preemptable = false, size_t places = 1, size_t availability = 0);
size_t places = 1,
size_t availability = 0);
virtual void edit_resource(Resource& resource, virtual void edit_resource (Resource &resource, const Glib::ustring &name, bool preemptable = false,
const Glib::ustring& name, size_t places = 1, size_t availability = 0);
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, prio_t base_priority = 0);
time_t arrival_time,
prio_t base_priority = 0);
virtual void edit_process(Process& process, virtual void edit_process (Process &process, const Glib::ustring &name, time_t arrival_time, prio_t base_priority = 0);
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, time_t cpu_time,
Process& parent, time_t arrival_time = 0, prio_t base_priority = 0);
time_t cpu_time,
time_t arrival_time = 0,
prio_t base_priority = 0);
virtual void edit_thread(Thread& thread, virtual void edit_thread (Thread &thread, const Glib::ustring &name, time_t cpu_time, time_t arrival_time = 0,
const Glib::ustring& name,
time_t cpu_time,
time_t arrival_time = 0,
prio_t base_priority = 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, virtual void edit_request (Request &request, time_t instant);
time_t instant);
virtual DynamicSubRequest& add_subrequest(Request& request, 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, virtual void edit_subrequest (SubRequest &subrequest, resource_key_t resource_key, time_t duration);
resource_key_t resource_key,
time_t duration);
// sets the front to position p // sets the front to position p
virtual void set_front (position p); virtual void set_front (position p);
@ -130,11 +108,8 @@ namespace sgpem
ConcreteHistory &operator= (const ConcreteHistory &op2); ConcreteHistory &operator= (const ConcreteHistory &op2);
bool _sealed; bool _sealed;
} }; //~ class ConcreteHistory
; //~ class ConcreteHistory
}//~ namespace sgpem } // namespace sgpem
#endif //~ CONCRETE_HISTORY_HH #endif //~ CONCRETE_HISTORY_HH

View File

@ -20,11 +20,11 @@
#include "concrete_process_statistics.hh" #include "concrete_process_statistics.hh"
#include "concrete_thread_statistics.hh" #include "concrete_thread_statistics.hh"
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh> #include <sgpemv2/environment.hh>
#include <sgpemv2/schedulable.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/process.hh> #include <sgpemv2/process.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/thread.hh> #include <sgpemv2/thread.hh>
#include <iostream> #include <iostream>
@ -41,8 +41,7 @@ using namespace sgpem;
\param _threads_stats The statistics of the threads belonging to "core" \param _threads_stats The statistics of the threads belonging to "core"
*/ */
ConcreteProcessStatistics::ConcreteProcessStatistics(const Process* core, const int& instant): ConcreteProcessStatistics::ConcreteProcessStatistics (const Process *core, const int &instant) : _core (core)
_core(core)
{ {
//retrieve threads statistics necessary to calculate "core"'s statistics //retrieve threads statistics necessary to calculate "core"'s statistics
vector<const Thread *> threads = core->get_threads (); vector<const Thread *> threads = core->get_threads ();
@ -108,7 +107,6 @@ ConcreteProcessStatistics::ConcreteProcessStatistics(const Process* core, const
} }
//set other variables //set other variables
if (core->get_total_cpu_time () != 0) if (core->get_total_cpu_time () != 0)
_execution_progress = (_execution_time * 100) / core->get_total_cpu_time (); _execution_progress = (_execution_time * 100) / core->get_total_cpu_time ();

View File

@ -22,10 +22,9 @@
#define CONCRETE_PROCESS_STATISTICS_HH 1 #define CONCRETE_PROCESS_STATISTICS_HH 1
#include "concrete_thread_statistics.hh"
#include <sgpemv2/process_statistics.hh> #include <sgpemv2/process_statistics.hh>
#include <sgpemv2/thread_statistics.hh> #include <sgpemv2/thread_statistics.hh>
#include "concrete_thread_statistics.hh"
namespace sgpem namespace sgpem
@ -56,6 +55,7 @@ namespace sgpem
const Process *get_core () const; const Process *get_core () const;
std::vector<const ThreadStatistics *> get_threads_statistics () const; std::vector<const ThreadStatistics *> get_threads_statistics () const;
private: private:
ConcreteProcessStatistics (const Process *core, const int &instant); ConcreteProcessStatistics (const Process *core, const int &instant);
@ -63,6 +63,6 @@ namespace sgpem
float _average_response_time; float _average_response_time;
std::vector<ConcreteThreadStatistics> _threads_stats; std::vector<ConcreteThreadStatistics> _threads_stats;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -20,24 +20,23 @@
#include "concrete_simulation.hh" #include "concrete_simulation.hh"
#include <sgpemv2/simulation_observer.hh>
#include <sgpemv2/scheduler.hh>
#include <sgpemv2/cpu_policies_gatekeeper.hh> #include <sgpemv2/cpu_policies_gatekeeper.hh>
#include <sgpemv2/resource_policies_gatekeeper.hh> #include <sgpemv2/resource_policies_gatekeeper.hh>
#include <sgpemv2/scheduler.hh>
#include <sgpemv2/simulation_observer.hh>
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <functional> #include <functional>
#include <string>
#include <iostream> #include <iostream>
#include <string>
using namespace sgpem; using namespace sgpem;
ConcreteSimulation::ConcreteSimulation() : ConcreteSimulation::ConcreteSimulation ()
Simulation(), _state(state_stopped), : Simulation (), _state (state_stopped), _mode (mode_continuous), _policy (NULL), _resource_policy (NULL)
_mode(mode_continuous), _policy(NULL), _resource_policy(NULL)
{ {
} }
@ -127,7 +126,6 @@ ConcreteSimulation::run()
_history.set_front (_history.get_front () + 1); _history.set_front (_history.get_front () + 1);
if (yet_to_finish) if (yet_to_finish)
{ {
if (_mode == mode_step_by_step) if (_mode == mode_step_by_step)
pause (); pause ();
else else
@ -171,7 +169,8 @@ ConcreteSimulation::step()
yet_to_finish = false; yet_to_finish = false;
} }
if (!yet_to_finish) _history.seal(); if (!yet_to_finish)
_history.seal ();
// since the simulation expects to be notified // since the simulation expects to be notified
// of simulation termination when reaching the last environment // of simulation termination when reaching the last environment

View File

@ -22,8 +22,8 @@
#define CONCRETE_SIMULATION_HH 1 #define CONCRETE_SIMULATION_HH 1
#include <sgpemv2/simulation.hh>
#include "concrete_history.hh" #include "concrete_history.hh"
#include <sgpemv2/simulation.hh>
#include <map> #include <map>
#include <stdexcept> #include <stdexcept>
@ -136,7 +136,6 @@ namespace sgpem
bool step (); bool step ();
}; };
} } // namespace sgpem
#endif #endif

View File

@ -19,10 +19,10 @@
#include "concrete_simulation_statistics.hh" #include "concrete_simulation_statistics.hh"
#include <sgpemv2/statistics.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh> #include <sgpemv2/environment.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/statistics.hh>
#include <iostream> #include <iostream>
#include <math.h> #include <math.h>
@ -73,7 +73,6 @@ ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<Con
vector<ConcreteProcessStatistics>::const_iterator p; vector<ConcreteProcessStatistics>::const_iterator p;
for (p = proc_stats.begin (); p != proc_stats.end (); p++) for (p = proc_stats.begin (); p != proc_stats.end (); p++)
{ {
if (p->get_response_time () != -1) if (p->get_response_time () != -1)
{ {
started_schedulables_count++; started_schedulables_count++;
@ -97,7 +96,6 @@ ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<Con
_average_turn_around += (*t)->get_turn_around (); _average_turn_around += (*t)->get_turn_around ();
_average_execution_progress += (*t)->get_execution_progress (); _average_execution_progress += (*t)->get_execution_progress ();
} }
} }
//make the AVERAGE and ROUND the values //make the AVERAGE and ROUND the values
@ -117,8 +115,6 @@ ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<Con
} }
float float
ConcreteSimulationStatistics::get_average_inactivity_time () const ConcreteSimulationStatistics::get_average_inactivity_time () const
{ {
@ -172,5 +168,3 @@ ConcreteSimulationStatistics::get_average_threads_throughput() const
{ {
return _average_threads_throughput; return _average_threads_throughput;
} }

View File

@ -22,9 +22,8 @@
#define CONCRETE_SIMULATION_STATISTICS_HH 1 #define CONCRETE_SIMULATION_STATISTICS_HH 1
#include <sgpemv2/simulation_statistics.hh>
#include "concrete_process_statistics.hh" #include "concrete_process_statistics.hh"
#include <sgpemv2/simulation_statistics.hh>
namespace sgpem namespace sgpem
@ -66,10 +65,7 @@ namespace sgpem
float _average_processes_throughput; float _average_processes_throughput;
float _average_threads_throughput; float _average_threads_throughput;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -19,14 +19,14 @@
#include "concrete_statistics.hh" #include "concrete_statistics.hh"
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/process.hh>
#include <sgpemv2/thread.hh>
#include "concrete_thread_statistics.hh"
#include "concrete_process_statistics.hh" #include "concrete_process_statistics.hh"
#include "concrete_thread_statistics.hh"
#include <sgpemv2/environment.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/process.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/thread.hh>
#include <iostream> #include <iostream>
@ -34,7 +34,6 @@ using namespace sgpem;
using namespace std; using namespace std;
ConcreteStatistics::ConcreteStatistics () : _sim_stats (0) ConcreteStatistics::ConcreteStatistics () : _sim_stats (0)
{ {
calculateStatisticsAt (-1); calculateStatisticsAt (-1);
@ -75,5 +74,3 @@ ConcreteStatistics::get_process_statistics() const
rit.push_back (&_proc_stats[i]); rit.push_back (&_proc_stats[i]);
return rit; return rit;
} }

View File

@ -22,17 +22,15 @@
#define CONCRETE_STATISTICS_HH 1 #define CONCRETE_STATISTICS_HH 1
#include <sgpemv2/statistics.hh>
#include "concrete_process_statistics.hh" #include "concrete_process_statistics.hh"
#include "concrete_simulation_statistics.hh" #include "concrete_simulation_statistics.hh"
#include <sgpemv2/statistics.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include <vector> #include <vector>
namespace sgpem namespace sgpem
{ {
/** \brief Implements the abstract class Statistics /** \brief Implements the abstract class Statistics
This class is a direct subclass of the abstract class Statistics. This class is a direct subclass of the abstract class Statistics.
@ -49,12 +47,9 @@ namespace sgpem
std::vector<const ProcessStatistics *> get_process_statistics () const; std::vector<const ProcessStatistics *> get_process_statistics () const;
private: private:
ConcreteSimulationStatistics *_sim_stats; ConcreteSimulationStatistics *_sim_stats;
std::vector<ConcreteProcessStatistics> _proc_stats; std::vector<ConcreteProcessStatistics> _proc_stats;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -19,15 +19,15 @@
#include "concrete_thread_statistics.hh" #include "concrete_thread_statistics.hh"
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/process.hh>
#include <sgpemv2/thread.hh>
#include <sgpemv2/resource.hh>
#include <sgpemv2/request.hh>
#include <iostream> #include <iostream>
#include <sgpemv2/environment.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/process.hh>
#include <sgpemv2/request.hh>
#include <sgpemv2/resource.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/thread.hh>
using namespace std; using namespace std;
using namespace sgpem; using namespace sgpem;
@ -78,8 +78,7 @@ ConcreteThreadStatistics::ConcreteThreadStatistics(const Thread* core, const int
} }
_execution_time++; _execution_time++;
} }
if (threads[i_t]->get_state() != Schedulable::state_future && if (threads[i_t]->get_state () != Schedulable::state_future && threads[i_t]->get_state () != Schedulable::state_terminated)
threads[i_t]->get_state() != Schedulable::state_terminated)
{ {
_turn_around++; _turn_around++;
if (!iniziato && _response_time == -1) //arrives and doesn't run if (!iniziato && _response_time == -1) //arrives and doesn't run
@ -88,8 +87,7 @@ ConcreteThreadStatistics::ConcreteThreadStatistics(const Thread* core, const int
_real_arrival_time = time - procs[i_p]->get_arrival_time () - 1; _real_arrival_time = time - procs[i_p]->get_arrival_time () - 1;
} }
} }
if (threads[i_t]->get_state() == Schedulable::state_blocked if (threads[i_t]->get_state () == Schedulable::state_blocked || threads[i_t]->get_state () == Schedulable::state_ready)
|| threads[i_t]->get_state() == Schedulable::state_ready)
{ {
_total_inactivity++; _total_inactivity++;
if (!iniziato && _response_time != -1) if (!iniziato && _response_time != -1)

View File

@ -22,7 +22,6 @@
#define CONCRETE_THREAD_STATISTICS_HH 1 #define CONCRETE_THREAD_STATISTICS_HH 1
#include <sgpemv2/thread_statistics.hh> #include <sgpemv2/thread_statistics.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
@ -62,6 +61,6 @@ namespace sgpem
const Thread *_core; const Thread *_core;
int _real_arrival_time; int _real_arrival_time;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -18,10 +18,9 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include "cpp_resource_policy_manager.hh" #include "cpp_resource_policy_manager.hh"
#include "resource_policy_lifo.hh"
#include "resource_policy_fifo.hh" #include "resource_policy_fifo.hh"
#include "resource_policy_lifo.hh"
#include "resource_policy_priority.hh" #include "resource_policy_priority.hh"
#include "resource_policy_priority_inheritance.hh" #include "resource_policy_priority_inheritance.hh"

View File

@ -58,7 +58,6 @@ namespace sgpem
static CppResourcePolicyManager _default_instance; static CppResourcePolicyManager _default_instance;
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -18,12 +18,10 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/cpu_policies_gatekeeper.hh>
#include <sgpemv2/cpu_policy_manager.hh>
#include <sgpemv2/cpu_policy.hh>
#include "concrete_history.hh" #include "concrete_history.hh"
#include <sgpemv2/cpu_policies_gatekeeper.hh>
#include <sgpemv2/cpu_policy.hh>
#include <sgpemv2/cpu_policy_manager.hh>
// Include full template definition only in implementation files: // Include full template definition only in implementation files:
#include <sgpemv2/templates/singleton.tcc> #include <sgpemv2/templates/singleton.tcc>
@ -34,10 +32,10 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
using std::vector;
using std::map;
using std::find; using std::find;
using std::map;
using std::runtime_error; using std::runtime_error;
using std::vector;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
@ -86,7 +84,8 @@ CPUPoliciesGatekeeper::get_current_policy(History* history)
ActiveIterator policy = _active_policies.find (history); ActiveIterator policy = _active_policies.find (history);
if (policy == _active_policies.end ()) if (policy == _active_policies.end ())
throw runtime_error("No active policy associated with this " throw runtime_error (
"No active policy associated with this "
"history is available."); "history is available.");
return policy->second; return policy->second;
@ -131,11 +130,11 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
// the caller need to know if it failed // the caller need to know if it failed
throw; throw;
} }
} }
CPUPoliciesGatekeeper::CPUPoliciesGatekeeper () CPUPoliciesGatekeeper::CPUPoliciesGatekeeper ()
{} {
}
void void
CPUPoliciesGatekeeper::deactivate_policies (CPUPolicyManager *manager) CPUPoliciesGatekeeper::deactivate_policies (CPUPolicyManager *manager)
@ -166,4 +165,3 @@ CPUPoliciesGatekeeper::deactivate_policies(CPUPolicyManager* manager)
} }
} //~ for(avail_it) } //~ for(avail_it)
} }

View File

@ -28,7 +28,8 @@ CPUPolicy* CPUPolicy::_callback_policy = nullptr;
CPUPolicy::~CPUPolicy () CPUPolicy::~CPUPolicy ()
{} {
}
PolicyParameters & PolicyParameters &
@ -38,12 +39,12 @@ CPUPolicy::get_parameters()
} }
CPUPolicy * CPUPolicy *
CPUPolicy::callback_get_policy () CPUPolicy::callback_get_policy ()
{ {
if (_callback_policy == nullptr) if (_callback_policy == nullptr)
throw std::runtime_error("CPUPolicy::callback_get_policy() not used as a callback method. nullptr ptr returned."); throw std::runtime_error (
"CPUPolicy::callback_get_policy() not used as a callback method. nullptr ptr returned.");
return _callback_policy; return _callback_policy;
} }

View File

@ -25,7 +25,6 @@
#include <sgpemv2/malformed_policy_exception.hh> #include <sgpemv2/malformed_policy_exception.hh>
using namespace sgpem; using namespace sgpem;
CPUPolicyException::CPUPolicyException(const std::string& msg) CPUPolicyException::CPUPolicyException (const std::string &msg) : std::runtime_error (msg)
: std::runtime_error(msg) {
{} }

View File

@ -18,9 +18,8 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/cpu_policy_manager.hh>
#include <sgpemv2/cpu_policies_gatekeeper.hh> #include <sgpemv2/cpu_policies_gatekeeper.hh>
#include <sgpemv2/cpu_policy_manager.hh>
using namespace sgpem; using namespace sgpem;
@ -34,4 +33,3 @@ CPUPolicyManager::~CPUPolicyManager()
{ {
CPUPoliciesGatekeeper::get_instance ().unregister_manager (this); CPUPoliciesGatekeeper::get_instance ().unregister_manager (this);
} }

View File

@ -19,16 +19,16 @@
#include "dynamic_process.hh" #include "dynamic_process.hh"
#include "static_process.hh"
#include "dynamic_thread.hh" #include "dynamic_thread.hh"
#include "static_process.hh"
#include <sgpemv2/serialize_visitor.hh> #include <sgpemv2/serialize_visitor.hh>
#include <sgpemv2/templates/sequences.tcc> #include <sgpemv2/templates/sequences.tcc>
#include <algorithm> #include <algorithm>
#include <cassert>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <cassert>
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
@ -37,15 +37,13 @@ typedef std::vector<DynamicThread*>::const_iterator ConstThreadIt;
typedef std::vector<DynamicThread *>::iterator ThreadIt; typedef std::vector<DynamicThread *>::iterator ThreadIt;
DynamicProcess::DynamicProcess(StaticProcess* core) : DynamicProcess::DynamicProcess (StaticProcess *core) : DynamicSchedulable (), _core (core)
DynamicSchedulable(), _core(core)
{ {
assert (core != nullptr); assert (core != nullptr);
} }
DynamicProcess::DynamicProcess(const DynamicProcess &other) : DynamicProcess::DynamicProcess (const DynamicProcess &other)
Schedulable(), DynamicSchedulable(other), Process(), : Schedulable (), DynamicSchedulable (other), Process (), _core (other._core)
_core(other._core)
{ {
for (Iseq<ConstThreadIt> seq = iseq (other._dynamic_threads); seq; ++seq) for (Iseq<ConstThreadIt> seq = iseq (other._dynamic_threads); seq; ++seq)
new DynamicThread (*(*seq), this); new DynamicThread (*(*seq), this);
@ -53,9 +51,7 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
DynamicProcess::~DynamicProcess () DynamicProcess::~DynamicProcess ()
{ {
for_each(_dynamic_threads.begin(), for_each (_dynamic_threads.begin (), _dynamic_threads.end (), [](auto *p) { delete p; });
_dynamic_threads.end(),
[] (auto *p) { delete p; });
} }
std::vector<Thread *> std::vector<Thread *>
@ -133,8 +129,7 @@ DynamicProcess::get_state() const
// the next thread to start, e.g. the one with the least arrival_time, // the next thread to start, e.g. the one with the least arrival_time,
// has start time greater than the current process elapsed time, then // has start time greater than the current process elapsed time, then
// pass from state_future to state_terminated: // pass from state_future to state_terminated:
if (result == state_future && if (result == state_future && next_thread_starts_at > static_cast<int> (get_elapsed_time ()))
next_thread_starts_at > static_cast<int>(get_elapsed_time()))
return state_terminated; return state_terminated;
return result; return result;
@ -203,4 +198,3 @@ DynamicProcess::get_last_release() const
} }
return result; return result;
} }

View File

@ -24,9 +24,9 @@
#include "gettext.h" #include "gettext.h"
#include <sgpemv2/process.hh>
#include "dynamic_schedulable.hh" #include "dynamic_schedulable.hh"
#include "static_process.hh" #include "static_process.hh"
#include <sgpemv2/process.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
@ -69,6 +69,6 @@ namespace sgpem
std::vector<DynamicThread *> _dynamic_threads; std::vector<DynamicThread *> _dynamic_threads;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -19,23 +19,22 @@
#include "dynamic_request.hh" #include "dynamic_request.hh"
#include "static_request.hh"
#include "dynamic_sub_request.hh" #include "dynamic_sub_request.hh"
#include "dynamic_thread.hh" #include "dynamic_thread.hh"
#include "static_request.hh"
#include <sgpemv2/serialize_visitor.hh> #include <sgpemv2/serialize_visitor.hh>
#include <sgpemv2/templates/down_cast.tcc> #include <sgpemv2/templates/down_cast.tcc>
#include <algorithm> #include <algorithm>
#include <functional>
#include <cassert> #include <cassert>
#include <functional>
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
DynamicRequest::DynamicRequest(StaticRequest *core, DynamicRequest::DynamicRequest (StaticRequest *core, DynamicThread *owner)
DynamicThread* owner) : : _static_request (core), _dynamic_thread (owner)
_static_request(core), _dynamic_thread(owner)
{ {
assert (core != nullptr); assert (core != nullptr);
assert (owner != nullptr); assert (owner != nullptr);
@ -45,8 +44,8 @@ DynamicRequest::DynamicRequest(StaticRequest *core,
siblings.push_back (this); siblings.push_back (this);
} }
DynamicRequest::DynamicRequest(const DynamicRequest& other, DynamicThread* owner) : DynamicRequest::DynamicRequest (const DynamicRequest &other, DynamicThread *owner)
_static_request(other._static_request), _dynamic_thread(owner) : _static_request (other._static_request), _dynamic_thread (owner)
{ {
typedef vector<DynamicSubRequest *> SubReqVec; typedef vector<DynamicSubRequest *> SubReqVec;
@ -69,8 +68,7 @@ DynamicRequest::DynamicRequest(const DynamicRequest& other, DynamicThread* owner
DynamicRequest::~DynamicRequest () DynamicRequest::~DynamicRequest ()
{ {
for_each(_dynamic_subrequests.begin(), _dynamic_subrequests.end(), for_each (_dynamic_subrequests.begin (), _dynamic_subrequests.end (), [](auto *p) { delete p; });
[] (auto *p) { delete p; });
} }

View File

@ -27,10 +27,10 @@ namespace sgpem
class SerializeVisitor; class SerializeVisitor;
class SubRequest; class SubRequest;
class DynamicSubRequest; class DynamicSubRequest;
} } // namespace sgpem
#include "static_request.hh"
#include "dynamic_thread.hh" #include "dynamic_thread.hh"
#include "static_request.hh"
#include <sgpemv2/request.hh> #include <sgpemv2/request.hh>
@ -78,7 +78,6 @@ namespace sgpem
std::vector<DynamicSubRequest *> _dynamic_subrequests; std::vector<DynamicSubRequest *> _dynamic_subrequests;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -29,9 +29,9 @@
using namespace sgpem; using namespace sgpem;
DynamicResource::DynamicResource(StaticResource *core) : DynamicResource::DynamicResource (StaticResource *core) : _static_resource (core)
_static_resource(core) {
{} }
bool bool

View File

@ -23,15 +23,13 @@
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include <sgpemv2/resource.hh>
#include "static_resource.hh" #include "static_resource.hh"
#include <sgpemv2/resource.hh>
#include <memory> #include <memory>
namespace sgpem namespace sgpem
{ {
/// \brief Desribes the state of a resource entity in a particular moment /// \brief Desribes the state of a resource entity in a particular moment
/// of the simulation. /// of the simulation.
/// ///
@ -92,7 +90,6 @@ namespace sgpem
std::shared_ptr<StaticResource> _static_resource; std::shared_ptr<StaticResource> _static_resource;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -27,9 +27,9 @@
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
DynamicSchedulable::DynamicSchedulable() DynamicSchedulable::DynamicSchedulable () : _priority_push (0)
: _priority_push(0) {
{} }
bool bool
DynamicSchedulable::operator== (const Schedulable &op2) const DynamicSchedulable::operator== (const Schedulable &op2) const

View File

@ -22,12 +22,11 @@
#define DYNAMIC_SCHEDULABLE_HH 1 #define DYNAMIC_SCHEDULABLE_HH 1
#include <sgpemv2/schedulable.hh>
#include "static_schedulable.hh" #include "static_schedulable.hh"
#include <sgpemv2/schedulable.hh>
namespace sgpem namespace sgpem
{ {
/// \brief Desribes the state of a schedulable entity in a particular moment /// \brief Desribes the state of a schedulable entity in a particular moment
/// of the simulation. /// of the simulation.
/// ///
@ -174,6 +173,6 @@ namespace sgpem
private: private:
int _priority_push; int _priority_push;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -30,10 +30,8 @@
using namespace sgpem; using namespace sgpem;
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core, DynamicSubRequest::DynamicSubRequest (StaticSubRequest *core, DynamicRequest *owner)
DynamicRequest* owner) : : _static_subrequest (core), _owner (owner), _queue_position (-1), _ran_for (0), _state (Request::state_future)
_static_subrequest(core), _owner(owner),
_queue_position(-1), _ran_for(0), _state(Request::state_future)
{ {
assert (core != nullptr); assert (core != nullptr);
assert (owner != nullptr); assert (owner != nullptr);
@ -44,10 +42,11 @@ DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
siblings.push_back (this); siblings.push_back (this);
} }
DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other, DynamicSubRequest::DynamicSubRequest (const DynamicSubRequest &other, DynamicRequest *owner)
DynamicRequest* owner) : : _static_subrequest (other._static_subrequest),
_static_subrequest(other._static_subrequest), _owner(owner), _owner (owner),
_queue_position(other._queue_position), _ran_for(other._ran_for), _queue_position (other._queue_position),
_ran_for (other._ran_for),
_state (other._state) _state (other._state)
{ {
assert (owner != nullptr); assert (owner != nullptr);
@ -59,13 +58,13 @@ DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
} }
DynamicSubRequest::~DynamicSubRequest () DynamicSubRequest::~DynamicSubRequest ()
{} {
}
bool bool
DynamicSubRequest::operator== (const SubRequest &op2) const DynamicSubRequest::operator== (const SubRequest &op2) const
{ {
return _static_subrequest == return _static_subrequest == down_cast<const DynamicSubRequest &> (op2)._static_subrequest;
down_cast<const DynamicSubRequest&>(op2)._static_subrequest;
} }

View File

@ -27,7 +27,7 @@ namespace sgpem
class SerializeVisitor; class SerializeVisitor;
class Resource; class Resource;
class StaticSubRequest; class StaticSubRequest;
} } // namespace sgpem
#include "dynamic_request.hh" #include "dynamic_request.hh"
#include "dynamic_resource.hh" #include "dynamic_resource.hh"
@ -108,6 +108,6 @@ namespace sgpem
state _state; state _state;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -19,19 +19,18 @@
#include "dynamic_thread.hh" #include "dynamic_thread.hh"
#include "static_thread.hh"
#include "dynamic_request.hh" #include "dynamic_request.hh"
#include "static_thread.hh"
#include <sgpemv2/serialize_visitor.hh> #include <sgpemv2/serialize_visitor.hh>
#include <algorithm> #include <algorithm>
#include <functional>
#include <cassert> #include <cassert>
#include <functional>
using namespace sgpem; using namespace sgpem;
DynamicThread::DynamicThread (StaticThread *core, DynamicProcess *parent) DynamicThread::DynamicThread (StaticThread *core, DynamicProcess *parent)
: DynamicSchedulable(), _core(core), _state(state_future), _parent(parent), : DynamicSchedulable (), _core (core), _state (state_future), _parent (parent), _ran_for (0), _last_acquisition (-1), _last_release (-1)
_ran_for(0), _last_acquisition(-1), _last_release(-1)
{ {
assert (core != nullptr); assert (core != nullptr);
assert (parent != nullptr); assert (parent != nullptr);
@ -42,10 +41,15 @@ DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent)
siblings.push_back (this); siblings.push_back (this);
} }
DynamicThread::DynamicThread(const DynamicThread &other, DynamicProcess* parent) : DynamicThread::DynamicThread (const DynamicThread &other, DynamicProcess *parent)
Schedulable(), DynamicSchedulable(other), Thread(), : Schedulable (),
_core(other._core), _state(other._state), _parent(parent), DynamicSchedulable (other),
_ran_for(other._ran_for), _last_acquisition(other._last_acquisition), Thread (),
_core (other._core),
_state (other._state),
_parent (parent),
_ran_for (other._ran_for),
_last_acquisition (other._last_acquisition),
_last_release (other._last_release) _last_release (other._last_release)
{ {
typedef std::vector<DynamicRequest *>::const_iterator ReqIt; typedef std::vector<DynamicRequest *>::const_iterator ReqIt;
@ -65,8 +69,7 @@ DynamicThread::DynamicThread(const DynamicThread &other, DynamicProcess* parent)
DynamicThread::~DynamicThread () DynamicThread::~DynamicThread ()
{ {
for_each(_dynamic_requests.begin(), _dynamic_requests.end(), for_each (_dynamic_requests.begin (), _dynamic_requests.end (), [](auto *p) { delete p; });
[] (auto *p) { delete p; });
} }
@ -161,4 +164,3 @@ DynamicThread::set_last_release(int instant)
{ {
_last_release = instant; _last_release = instant;
} }

View File

@ -26,9 +26,9 @@
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include <vector> #include <vector>
#include <sgpemv2/thread.hh>
#include "dynamic_process.hh" #include "dynamic_process.hh"
#include "dynamic_schedulable.hh" #include "dynamic_schedulable.hh"
#include <sgpemv2/thread.hh>
#include <memory> #include <memory>
@ -146,7 +146,6 @@ namespace sgpem
virtual const StaticThread &get_core () const; virtual const StaticThread &get_core () const;
/** /**
\brief Returns ::Requests pointers this ::Thread did to some ::Resource. \brief Returns ::Requests pointers this ::Thread did to some ::Resource.
Since C++ (unfortunately) doesn't support covariance for return Since C++ (unfortunately) doesn't support covariance for return
@ -213,7 +212,6 @@ namespace sgpem
int _last_release; int _last_release;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -24,5 +24,5 @@ using namespace sgpem;
Environment::~Environment () Environment::~Environment ()
{} {
}

View File

@ -55,10 +55,8 @@
#define gettext(Msgid) ((const char *) (Msgid)) #define gettext(Msgid) ((const char *) (Msgid))
#define dgettext(Domainname, Msgid) ((const char *) (Msgid)) #define dgettext(Domainname, Msgid) ((const char *) (Msgid))
#define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) #define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(Msgid1, Msgid2, N) \ #define ngettext(Msgid1, Msgid2, N) ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) #define dngettext(Domainname, Msgid1, Msgid2, N) ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
#define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ #define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
#define textdomain(Domainname) ((const char *) (Domainname)) #define textdomain(Domainname) ((const char *) (Domainname))

View File

@ -42,9 +42,9 @@ using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class sgpem::Singleton<GlobalPreferences>; template class sgpem::Singleton<GlobalPreferences>;
GlobalPreferences::GlobalPreferences() GlobalPreferences::GlobalPreferences () : _mod_dirs (1, PLUGDIR), _pol_dirs (1, POLDIR), _speed (1000)
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000) {
{} }
Glib::ustring Glib::ustring
@ -56,11 +56,7 @@ GlobalPreferences::get_preferences_dir() const
#ifdef _MSC_VER #ifdef _MSC_VER
TCHAR raw_path[MAX_PATH]; TCHAR raw_path[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL, if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, raw_path)))
CSIDL_APPDATA,
nullptr,
SHGFP_TYPE_CURRENT,
raw_path)))
{ {
// if UNICODE, characters are 16bit, otherwise plain bytes // if UNICODE, characters are 16bit, otherwise plain bytes
#ifdef UNICODE #ifdef UNICODE
@ -201,7 +197,6 @@ GlobalPreferences::load_configrc()
void void
GlobalPreferences::key_file_read (KeyFile &kf) GlobalPreferences::key_file_read (KeyFile &kf)
{ {
_mod_dirs.clear (); _mod_dirs.clear ();
_pol_dirs.clear (); _pol_dirs.clear ();
std::vector<Glib::ustring> old_mod_dirs (1, PLUGDIR); std::vector<Glib::ustring> old_mod_dirs (1, PLUGDIR);
@ -265,8 +260,6 @@ GlobalPreferences::key_file_read(KeyFile& kf)
} }
} }
} }
} }
void void
@ -327,5 +320,3 @@ GlobalPreferences::key_file_write(KeyFile& kf)
kf.insert_key_value (key, value); kf.insert_key_value (key, value);
} }
} }

View File

@ -29,7 +29,6 @@ namespace sgpem
class GlobalPreferencesSerializer; class GlobalPreferencesSerializer;
/** \brief Save and retrieve global preferences formatted as key=value rows. /** \brief Save and retrieve global preferences formatted as key=value rows.
* *
* This class handles files to store and retrieve global preferences * This class handles files to store and retrieve global preferences
@ -38,7 +37,6 @@ namespace sgpem
*/ */
class SG_DLLLOCAL GlobalPreferencesSerializer : public KeyFile class SG_DLLLOCAL GlobalPreferencesSerializer : public KeyFile
{ {
public: public:
/** \brief Object constructor */ /** \brief Object constructor */
GlobalPreferencesSerializer (GlobalPreferences &gp); GlobalPreferencesSerializer (GlobalPreferences &gp);
@ -54,9 +52,10 @@ namespace sgpem
* \param filename The file to write to. * \param filename The file to write to.
*/ */
void file_write (const Glib::ustring &filename); void file_write (const Glib::ustring &filename);
private: private:
GlobalPreferences &_globalPreferences; GlobalPreferences &_globalPreferences;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -18,8 +18,6 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/history.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/history_observer.hh> #include <sgpemv2/history_observer.hh>
@ -29,8 +27,7 @@
using namespace sgpem; using namespace sgpem;
History::History() History::History () : _front (0), _notify (true)
: _front(0), _notify(true)
{ {
} }
@ -50,24 +47,23 @@ History::attach(HistoryObserver& observer)
void void
History::detach (const HistoryObserver &observer) History::detach (const HistoryObserver &observer)
{ {
_observers.erase(std::find(_observers.begin(), _observers.erase (std::find (_observers.begin (), _observers.end (), &observer));
_observers.end(),
&observer));
} }
void void
History::notify_change () History::notify_change ()
{ {
if (!_notify) return; if (!_notify)
return;
for (RegisteredObservers::iterator it = _observers.begin(); for (RegisteredObservers::iterator it = _observers.begin (); it != _observers.end (); it++)
it != _observers.end(); it++)
(*it)->update (*this); (*it)->update (*this);
} }
unsigned int History::get_front() const unsigned int
History::get_front () const
{ {
return _front; return _front;
} }
@ -88,8 +84,7 @@ History::set_notify_enabled(bool enabled)
// --------- History::LockNotify --------------- // --------- History::LockNotify ---------------
History::LockNotify::LockNotify(History& history) History::LockNotify::LockNotify (History &history) : _h (history), _was_enabled (_h.set_notify_enabled (false))
: _h(history), _was_enabled(_h.set_notify_enabled(false))
{ {
} }

View File

@ -20,6 +20,8 @@
#include <sgpemv2/history_observer.hh> #include <sgpemv2/history_observer.hh>
sgpem::HistoryObserver::~HistoryObserver() {} sgpem::HistoryObserver::~HistoryObserver ()
{
}
// Pure abstract class. Nothing else to put here. // Pure abstract class. Nothing else to put here.

View File

@ -18,12 +18,10 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/invalid_plugin_exception.hh> #include <sgpemv2/invalid_plugin_exception.hh>
using namespace sgpem; using namespace sgpem;
InvalidPluginException::InvalidPluginException(const std::string& what) : InvalidPluginException::InvalidPluginException (const std::string &what) : std::runtime_error (what)
std::runtime_error(what) {
{} }

View File

@ -18,9 +18,8 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/key_file.hh>
#include <fstream> #include <fstream>
#include <sgpemv2/key_file.hh>
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
@ -29,9 +28,9 @@ using namespace std;
namespace sgpem namespace sgpem
{ {
KeyFile::KeyFile () KeyFile::KeyFile ()
{} {
}
KeyFile::elements_iterator KeyFile::elements_iterator
@ -131,4 +130,4 @@ namespace sgpem
} // end - if(ofs) } // end - if(ofs)
} }
} } // namespace sgpem

View File

@ -25,7 +25,6 @@
#include <sgpemv2/malformed_policy_exception.hh> #include <sgpemv2/malformed_policy_exception.hh>
using namespace sgpem; using namespace sgpem;
MalformedPolicyException::MalformedPolicyException(const std::string& msg) MalformedPolicyException::MalformedPolicyException (const std::string &msg) : CPUPolicyException (msg)
: CPUPolicyException(msg) {
{} }

View File

@ -21,8 +21,8 @@
using namespace sgpem; using namespace sgpem;
Module::Module(const Glib::ustring& identifier) : Module::Module (const Glib::ustring &identifier)
Glib::Module(identifier), : Glib::Module (identifier),
_enabled (false), _enabled (false),
_id (identifier), _id (identifier),
on_init_ptr (NULL), on_init_ptr (NULL),
@ -32,7 +32,8 @@ Module::Module(const Glib::ustring& identifier) :
get_author_ptr (NULL), get_author_ptr (NULL),
get_version_ptr (NULL) get_version_ptr (NULL)
{ {
if (!*this) throw InvalidPluginException(Module::get_last_error()); if (!*this)
throw InvalidPluginException (Module::get_last_error ());
// Type-safeness here is an optional, as always. :-) // Type-safeness here is an optional, as always. :-)
std::string prefix = "sgpem__Plugin__"; std::string prefix = "sgpem__Plugin__";
@ -89,4 +90,3 @@ Module::get_enabled() const
{ {
return _enabled; return _enabled;
} }

View File

@ -26,8 +26,6 @@
using namespace sgpem; using namespace sgpem;
NullPolicyException::NullPolicyException(const char* msg) NullPolicyException::NullPolicyException (const char *msg) : std::runtime_error (msg)
: std::runtime_error(msg)
{ {
} }

View File

@ -18,19 +18,17 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/plugin_manager.hh>
#include <sgpemv2/module.hh>
#include <sgpemv2/global_preferences.hh> #include <sgpemv2/global_preferences.hh>
#include <sgpemv2/module.hh>
#include <sgpemv2/plugin_manager.hh>
#include <sgpemv2/templates/singleton.tcc> #include <sgpemv2/templates/singleton.tcc>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/pattern.h> #include <glibmm/pattern.h>
#include <iostream>
#include <algorithm> #include <algorithm>
#include <iostream>
using namespace sgpem; using namespace sgpem;
@ -48,8 +46,7 @@ PluginManager::rescan_dirs()
{ {
Module *module = nullptr; Module *module = nullptr;
for_each(_modules.begin(), _modules.end(), for_each (_modules.begin (), _modules.end (), [](auto *p) { delete p; });
[] (auto *p) { delete p; });
_modules.clear (); _modules.clear ();
GlobalPreferences &prefs = GlobalPreferences::get_instance (); GlobalPreferences &prefs = GlobalPreferences::get_instance ();
@ -93,4 +90,3 @@ PluginManager::PluginManager()
{ {
rescan_dirs (); rescan_dirs ();
} }

View File

@ -32,7 +32,7 @@ namespace sgpem
template class SG_DLLEXPORT PolicyParameters::Parameter<int>; template class SG_DLLEXPORT PolicyParameters::Parameter<int>;
template class SG_DLLEXPORT PolicyParameters::Parameter<float>; template class SG_DLLEXPORT PolicyParameters::Parameter<float>;
template class SG_DLLEXPORT PolicyParameters::Parameter<Glib::ustring>; template class SG_DLLEXPORT PolicyParameters::Parameter<Glib::ustring>;
} } // namespace sgpem
/** /**
@ -40,25 +40,17 @@ namespace sgpem
If there is a parameter with the same name and type it will be overwritten. If there is a parameter with the same name and type it will be overwritten.
*/ */
void void
PolicyParameters::register_int(Glib::ustring name, PolicyParameters::register_int (Glib::ustring name, const int &lower_bound, const int &upper_bound,
const int& lower_bound, const bool &required, const int &default_value)
const int& upper_bound,
const bool& required,
const int& default_value)
{ {
//there is a parameter with the same name!! //there is a parameter with the same name!!
map<ustring, Parameter<int>>::iterator i = int_map.find (name); map<ustring, Parameter<int>>::iterator i = int_map.find (name);
if (i != int_map.end ()) if (i != int_map.end ())
int_map.erase (i); int_map.erase (i);
map<ustring, Parameter<int> >::value_type v(name, Parameter<int>(name, map<ustring, Parameter<int>>::value_type v (
default_value, name, Parameter<int> (name, default_value, lower_bound, upper_bound, required, default_value));
lower_bound,
upper_bound,
required,
default_value));
int_map.insert (v); int_map.insert (v);
} }
/** /**
@ -66,23 +58,16 @@ PolicyParameters::register_int(Glib::ustring name,
If there is a parameter with the same name and type it will be overwritten. If there is a parameter with the same name and type it will be overwritten.
*/ */
void void
PolicyParameters::register_float(Glib::ustring name, PolicyParameters::register_float (Glib::ustring name, const float &lower_bound, const float &upper_bound,
const float& lower_bound, const bool &required, const float &default_value)
const float& upper_bound,
const bool& required,
const float& default_value)
{ {
//there is a parameter with the same name!! //there is a parameter with the same name!!
map<ustring, Parameter<float>>::iterator i = float_map.find (name); map<ustring, Parameter<float>>::iterator i = float_map.find (name);
if (i != float_map.end ()) if (i != float_map.end ())
float_map.erase (i); float_map.erase (i);
map<ustring, Parameter<float> >::value_type v(name, Parameter<float>(name, map<ustring, Parameter<float>>::value_type v (
default_value, name, Parameter<float> (name, default_value, lower_bound, upper_bound, required, default_value));
lower_bound,
upper_bound,
required,
default_value));
float_map.insert (v); float_map.insert (v);
} }
@ -99,12 +84,8 @@ PolicyParameters::register_string(Glib::ustring name, const bool& required, cons
if (i != string_map.end ()) if (i != string_map.end ())
string_map.erase (i); string_map.erase (i);
map<ustring, Parameter<Glib::ustring> >::value_type v(name, Parameter<Glib::ustring>(name, map<ustring, Parameter<Glib::ustring>>::value_type v (
default_value, name, Parameter<Glib::ustring> (name, default_value, "", "", required, default_value));
"",
"",
required,
default_value));
string_map.insert (v); string_map.insert (v);
} }
@ -254,4 +235,3 @@ PolicyParameters::get_string(ustring name) const
else else
return i->second.get_value (); return i->second.get_value ();
} }

View File

@ -23,5 +23,5 @@
using namespace sgpem; using namespace sgpem;
Process::~Process () Process::~Process ()
{} {
}

View File

@ -29,5 +29,3 @@ ProcessStatistics::~ProcessStatistics()
ProcessStatistics::ProcessStatistics () ProcessStatistics::ProcessStatistics ()
{ {
} }

View File

@ -27,7 +27,8 @@ void
ReadyQueue::swap (position a, position b) ReadyQueue::swap (position a, position b)
{ {
if (a == b) return; if (a == b)
return;
// Usage of "at()" isn't casual: // Usage of "at()" isn't casual:
// at() checks indexes, "[]" doesn't. // at() checks indexes, "[]" doesn't.
@ -86,4 +87,3 @@ ReadyQueue::erase_first()
{ {
_scheds.erase (_scheds.begin ()); _scheds.erase (_scheds.begin ());
} }

View File

@ -23,5 +23,5 @@
using namespace sgpem; using namespace sgpem;
Request::~Request () Request::~Request ()
{} {
}

View File

@ -25,4 +25,3 @@ using namespace sgpem;
Resource::~Resource () Resource::~Resource ()
{ {
} }

View File

@ -18,12 +18,10 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/resource_policies_gatekeeper.hh>
#include <sgpemv2/resource_policy_manager.hh>
#include <sgpemv2/resource_policy.hh>
#include "concrete_history.hh" #include "concrete_history.hh"
#include <sgpemv2/resource_policies_gatekeeper.hh>
#include <sgpemv2/resource_policy.hh>
#include <sgpemv2/resource_policy_manager.hh>
// Include full template definition only in implementation files: // Include full template definition only in implementation files:
#include <sgpemv2/templates/singleton.tcc> #include <sgpemv2/templates/singleton.tcc>
@ -33,10 +31,10 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
using std::vector;
using std::map;
using std::find; using std::find;
using std::map;
using std::runtime_error; using std::runtime_error;
using std::vector;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
@ -85,7 +83,8 @@ ResourcePoliciesGatekeeper::get_current_policy(History* history)
PolicyIterator policy = _active_policies.find (history); PolicyIterator policy = _active_policies.find (history);
if (policy == _active_policies.end ()) if (policy == _active_policies.end ())
throw runtime_error(_("No active policy associated with this " throw runtime_error (
_ ("No active policy associated with this "
"history is available.")); "history is available."));
return *policy->second; return *policy->second;
@ -102,7 +101,8 @@ ResourcePoliciesGatekeeper::activate_policy(History *history, ResourcePolicy* po
} }
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper () ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper ()
{} {
}
void void
ResourcePoliciesGatekeeper::deactivate_policies (const ResourcePolicyManager &manager) ResourcePoliciesGatekeeper::deactivate_policies (const ResourcePolicyManager &manager)
@ -122,4 +122,3 @@ ResourcePoliciesGatekeeper::deactivate_policies(const ResourcePolicyManager& man
++it; ++it;
} //~ for(avail_it) } //~ for(avail_it)
} }

View File

@ -23,7 +23,8 @@
using namespace sgpem; using namespace sgpem;
ResourcePolicy::~ResourcePolicy () ResourcePolicy::~ResourcePolicy ()
{} {
}
PolicyParameters & PolicyParameters &
@ -31,4 +32,3 @@ ResourcePolicy::get_parameters()
{ {
return _parameters; return _parameters;
} }

View File

@ -25,7 +25,8 @@ using namespace std;
using namespace sgpem; using namespace sgpem;
ResourcePolicyFiFo::~ResourcePolicyFiFo () ResourcePolicyFiFo::~ResourcePolicyFiFo ()
{} {
}
void void
@ -53,7 +54,6 @@ ResourcePolicyFiFo::enforce(Environment& /*environment*/, Environment::SubReques
} }
typedef SubRequestQueue::iterator It; typedef SubRequestQueue::iterator It;
for (It i = old_queue.begin (); i != old_queue.end (); i++) for (It i = old_queue.begin (); i != old_queue.end (); i++)
if ((**i).get_state () != Request::state_allocated && *i != &sr) if ((**i).get_state () != Request::state_allocated && *i != &sr)

View File

@ -73,7 +73,7 @@ namespace sgpem
virtual void deactivate (); virtual void deactivate ();
}; };
}//~ namespace sgpem } // namespace sgpem
#endif //~ RESOURCE_POLICY_FIFO_HH #endif //~ RESOURCE_POLICY_FIFO_HH

View File

@ -24,7 +24,8 @@ using namespace std;
using namespace sgpem; using namespace sgpem;
ResourcePolicyLiFo::~ResourcePolicyLiFo () ResourcePolicyLiFo::~ResourcePolicyLiFo ()
{} {
}
void void
@ -52,7 +53,6 @@ ResourcePolicyLiFo::enforce(Environment& /*environment*/, Environment::SubReques
} }
bool inserted = false; bool inserted = false;
typedef SubRequestQueue::iterator It; typedef SubRequestQueue::iterator It;
for (It i = old_queue.begin (); i != old_queue.end (); i++) for (It i = old_queue.begin (); i != old_queue.end (); i++)

View File

@ -81,7 +81,7 @@ namespace sgpem
virtual void deactivate (); virtual void deactivate ();
}; };
}//~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -18,9 +18,8 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/resource_policy_manager.hh>
#include <sgpemv2/resource_policies_gatekeeper.hh> #include <sgpemv2/resource_policies_gatekeeper.hh>
#include <sgpemv2/resource_policy_manager.hh>
using namespace sgpem; using namespace sgpem;
@ -34,4 +33,3 @@ ResourcePolicyManager::~ResourcePolicyManager()
{ {
ResourcePoliciesGatekeeper::get_instance ().unregister_manager (this); ResourcePoliciesGatekeeper::get_instance ().unregister_manager (this);
} }

View File

@ -53,7 +53,6 @@ ResourcePolicyPriority::enforce(Environment& /*environment*/, Environment::SubRe
} }
int pthis = sr.get_request ().get_thread ().get_current_priority (); int pthis = sr.get_request ().get_thread ().get_current_priority ();
// assume they are ordered by priority. // assume they are ordered by priority.
bool inserted = false; bool inserted = false;

View File

@ -23,15 +23,14 @@
#include "gettext.h" #include "gettext.h"
#include <sgpemv2/resource_policy.hh>
#include <sgpemv2/policy_parameters.hh> #include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/resource_policy.hh>
#include <sgpemv2/user_interrupt_exception.hh> #include <sgpemv2/user_interrupt_exception.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
namespace sgpem namespace sgpem
{ {
/// \brief A resource allocation policy which provides a better service /// \brief A resource allocation policy which provides a better service
/// to higer priority threads. /// to higer priority threads.
/// ///
@ -43,7 +42,6 @@ namespace sgpem
class SG_DLLLOCAL ResourcePolicyPriority : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyPriority : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor. /// \brief Standard virtual destructor.
/// ///
/// Standard virtual destructor. /// Standard virtual destructor.
@ -89,7 +87,7 @@ namespace sgpem
virtual void deactivate (); virtual void deactivate ();
}; };
}//~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -26,7 +26,8 @@ using namespace std;
using namespace sgpem; using namespace sgpem;
ResourcePolicyPriorityInheritance::~ResourcePolicyPriorityInheritance () ResourcePolicyPriorityInheritance::~ResourcePolicyPriorityInheritance ()
{} {
}
void void
ResourcePolicyPriorityInheritance::configure () ResourcePolicyPriorityInheritance::configure ()
@ -91,7 +92,9 @@ ResourcePolicyPriorityInheritance::enforce(Environment& /*environment*/, Environ
Glib::ustring Glib::ustring
ResourcePolicyPriorityInheritance::get_description () const ResourcePolicyPriorityInheritance::get_description () const
{ {
return _("A resource policy which solves the priority inversion problem by raising the priority of a thread to the maximum relative to the queue."); return _ (
"A resource policy which solves the priority inversion problem by raising the priority of a thread to the "
"maximum relative to the queue.");
} }
Glib::ustring Glib::ustring

View File

@ -37,7 +37,6 @@ namespace sgpem
class SG_DLLLOCAL ResourcePolicyPriorityInheritance : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyPriorityInheritance : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor. /// \brief Standard virtual destructor.
/// ///
/// Standard virtual destructor. /// Standard virtual destructor.
@ -57,9 +56,7 @@ namespace sgpem
Because it's a pure virtual method, must be re-implemented Because it's a pure virtual method, must be re-implemented
in concrete derived classes. in concrete derived classes.
*/ */
virtual void enforce(Environment& environment, virtual void enforce (Environment &environment, Environment::SubRequestQueue &queue, SubRequest &sr);
Environment::SubRequestQueue& queue,
SubRequest& sr);
/** /**
\brief Gets a string description of the policy. \brief Gets a string description of the policy.
@ -77,7 +74,7 @@ namespace sgpem
virtual void deactivate (); virtual void deactivate ();
}; };
}//~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -25,15 +25,18 @@
using namespace sgpem; using namespace sgpem;
Schedulable::~Schedulable () Schedulable::~Schedulable ()
{} {
}
unsigned int Schedulable::get_remaining_time() const unsigned int
Schedulable::get_remaining_time () const
{ {
assert (get_total_cpu_time () >= get_elapsed_time ()); assert (get_total_cpu_time () >= get_elapsed_time ());
return get_total_cpu_time () - get_elapsed_time (); return get_total_cpu_time () - get_elapsed_time ();
} }
int Schedulable::get_priority_push() const int
Schedulable::get_priority_push () const
{ {
return get_current_priority () - get_base_priority (); return get_current_priority () - get_base_priority ();
} }

View File

@ -29,4 +29,3 @@ SchedulableStatistics::SchedulableStatistics()
SchedulableStatistics::~SchedulableStatistics () SchedulableStatistics::~SchedulableStatistics ()
{ {
} }

View File

@ -18,7 +18,6 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
/* /*
// DISCLAIMER FOR THE RAMPANT CODER: \\ // DISCLAIMER FOR THE RAMPANT CODER: \\
// ----------------------------------------------------\\ // ----------------------------------------------------\\
@ -36,8 +35,8 @@
#include <sgpemv2/scheduler.hh> #include <sgpemv2/scheduler.hh>
// Do not include full template definition in the header file // Do not include full template definition in the header file
#include <sgpemv2/templates/singleton.tcc>
#include <sgpemv2/templates/sequences.tcc> #include <sgpemv2/templates/sequences.tcc>
#include <sgpemv2/templates/singleton.tcc>
#include <glibmm/thread.h> #include <glibmm/thread.h>
@ -84,8 +83,7 @@ is_running(const Thread* running_thread)
// Collects all threads of an environment into a single vector // Collects all threads of an environment into a single vector
void void
collect_threads(const std::vector<Process*>& procs, collect_threads (const std::vector<Process *> &procs, Threads &collected_threads)
Threads& collected_threads)
{ {
collected_threads.clear (); collected_threads.clear ();
for (Iseq<vector<Process *>::const_iterator> seq = iseq (procs); seq; ++seq) for (Iseq<vector<Process *>::const_iterator> seq = iseq (procs); seq; ++seq)
@ -97,8 +95,7 @@ collect_threads(const std::vector<Process*>& procs,
void void
prepare_ready_queue(ConcreteEnvironment& snapshot, prepare_ready_queue (ConcreteEnvironment &snapshot, const Threads &all_threads)
const Threads& all_threads)
{ {
ReadyQueue &queue = snapshot.get_sorted_queue (); ReadyQueue &queue = snapshot.get_sorted_queue ();
assert (queue.size () == 0); assert (queue.size () == 0);
@ -110,11 +107,9 @@ prepare_ready_queue(ConcreteEnvironment& snapshot,
} }
// When a thread terminates, unconditionally kill all its requests // When a thread terminates, unconditionally kill all its requests
void void
terminate_all_requests_of(DynamicThread& thread, terminate_all_requests_of (DynamicThread &thread, ConcreteEnvironment &environment)
ConcreteEnvironment& environment)
{ {
Requests &reqs = thread.get_dynamic_requests (); Requests &reqs = thread.get_dynamic_requests ();
for (Iseq<Requests::iterator> r_it = iseq (reqs); r_it; ++r_it) for (Iseq<Requests::iterator> r_it = iseq (reqs); r_it; ++r_it)
@ -126,7 +121,8 @@ terminate_all_requests_of(DynamicThread& thread,
Environment::resource_key_t rkey = (*s_it)->get_resource_key (); Environment::resource_key_t rkey = (*s_it)->get_resource_key ();
SubRequestQueue &queue = environment.get_request_queue (rkey); SubRequestQueue &queue = environment.get_request_queue (rkey);
SubRequestQueue::iterator removable = find (queue.begin (), queue.end (), *s_it); SubRequestQueue::iterator removable = find (queue.begin (), queue.end (), *s_it);
if(removable != queue.end()) queue.erase(removable); if (removable != queue.end ())
queue.erase (removable);
} }
} }
} }
@ -134,8 +130,7 @@ terminate_all_requests_of(DynamicThread& thread,
// For the current thread, see if there are requests that are exhausted // For the current thread, see if there are requests that are exhausted
void void
update_allocated_requests(DynamicThread& running_thread, update_allocated_requests (DynamicThread &running_thread, ConcreteEnvironment &environment)
ConcreteEnvironment& environment)
{ {
// Go for all dynamic requests of this thread // Go for all dynamic requests of this thread
Requests &reqs = running_thread.get_dynamic_requests (); Requests &reqs = running_thread.get_dynamic_requests ();
@ -154,7 +149,8 @@ update_allocated_requests(DynamicThread& running_thread,
Environment::resource_key_t rkey = cur_subr.get_resource_key (); Environment::resource_key_t rkey = cur_subr.get_resource_key ();
SubRequestQueue &queue = environment.get_request_queue (rkey); SubRequestQueue &queue = environment.get_request_queue (rkey);
SubRequestQueue::iterator removable = find (queue.begin (), queue.end (), &cur_subr); SubRequestQueue::iterator removable = find (queue.begin (), queue.end (), &cur_subr);
if(removable != queue.end()) queue.erase(removable); if (removable != queue.end ())
queue.erase (removable);
} }
} }
} //~ for(over subrequests) } //~ for(over subrequests)
@ -179,8 +175,7 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
SubRequests &subreqs = (*req_it)->get_dynamic_subrequests (); SubRequests &subreqs = (*req_it)->get_dynamic_subrequests ();
// Add to the queue only requests passing from future to another state: // Add to the queue only requests passing from future to another state:
if(cur_req.get_state() == Request::state_future && if (cur_req.get_state () == Request::state_future && cur_req.get_instant () == running_thread.get_elapsed_time ())
cur_req.get_instant() == running_thread.get_elapsed_time())
{ {
for (Iseq<SubRequests::iterator> subr_it = iseq (subreqs); subr_it; ++subr_it) for (Iseq<SubRequests::iterator> subr_it = iseq (subreqs); subr_it; ++subr_it)
{ {
@ -231,7 +226,6 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
const SubRequests &const_subreqs = subreqs; const SubRequests &const_subreqs = subreqs;
for (Iseq<SubRequests::const_iterator> it_dsrs = iseq (const_subreqs); it_dsrs; ++it_dsrs) for (Iseq<SubRequests::const_iterator> it_dsrs = iseq (const_subreqs); it_dsrs; ++it_dsrs)
{ {
DynamicSubRequest &subreq = **it_dsrs; DynamicSubRequest &subreq = **it_dsrs;
assert (subreq.get_state () == Request::state_allocable); assert (subreq.get_state () == Request::state_allocable);
/* /*
@ -273,8 +267,7 @@ determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queu
{ {
unsigned int total_places = res.get_places (); unsigned int total_places = res.get_places ();
unsigned int position_in_queue = 0; unsigned int position_in_queue = 0;
for(Iseq<SubRequestQueue::const_iterator> queue_it = iseq(queue); for (Iseq<SubRequestQueue::const_iterator> queue_it = iseq (queue); queue_it; queue_it++, position_in_queue++)
queue_it; queue_it++, position_in_queue++)
{ {
DynamicSubRequest &sr = (DynamicSubRequest &) **queue_it; DynamicSubRequest &sr = (DynamicSubRequest &) **queue_it;
if (sr.get_state () == Request::state_allocated) if (sr.get_state () == Request::state_allocated)
@ -295,8 +288,7 @@ determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queu
// step of the simulation. It also put previously blocked threads // step of the simulation. It also put previously blocked threads
// back into ready state if need arises. // back into ready state if need arises.
void void
look_for_mutant_request_states(ConcreteEnvironment& environment, look_for_mutant_request_states (ConcreteEnvironment &environment, unsigned int &alive_threads)
unsigned int& alive_threads)
{ {
// Now listening to: Testament's ``First Strike Is Still Deadly'' // Now listening to: Testament's ``First Strike Is Still Deadly''
// The name of this function evokes mighty monsters from the abyss. In // The name of this function evokes mighty monsters from the abyss. In
@ -332,15 +324,13 @@ look_for_mutant_request_states(ConcreteEnvironment& environment,
// If a request changes state from allocable to unallocable, // If a request changes state from allocable to unallocable,
// the corresponding thread should be blocked, and vice-versa // the corresponding thread should be blocked, and vice-versa
DynamicThread &thread = req.get_thread (); DynamicThread &thread = req.get_thread ();
if(prev_req_state == Request::state_allocable && if (prev_req_state == Request::state_allocable && req.get_state () == Request::state_unallocable)
req.get_state() == Request::state_unallocable)
{ {
if (thread.get_state () != Schedulable::state_blocked) if (thread.get_state () != Schedulable::state_blocked)
alive_threads--; alive_threads--;
thread.set_state (Schedulable::state_blocked); thread.set_state (Schedulable::state_blocked);
} }
else if(prev_req_state == Request::state_unallocable && else if (prev_req_state == Request::state_unallocable && req.get_state () == Request::state_allocable)
req.get_state() == Request::state_allocable)
{ {
if (thread.get_state () == Schedulable::state_blocked) if (thread.get_state () == Schedulable::state_blocked)
alive_threads++; alive_threads++;
@ -349,18 +339,16 @@ look_for_mutant_request_states(ConcreteEnvironment& environment,
} //~ for(over subrequests in the queue) } //~ for(over subrequests in the queue)
} //~ for(over resources) } //~ for(over resources)
} }
// --------------------------------------------------------- // ---------------------------------------------------------
//private constructor. //private constructor.
Scheduler::Scheduler() Scheduler::Scheduler () : _ready_queue (NULL), _policy (NULL), _step_mutex ()
: _ready_queue(NULL), _policy(NULL), _step_mutex() {
{} }
ReadyQueue * ReadyQueue *
@ -377,7 +365,6 @@ Scheduler::get_policy()
} }
bool bool
Scheduler::step_forward (History &history, CPUPolicy &cpu_policy, ResourcePolicy &resource_policy) Scheduler::step_forward (History &history, CPUPolicy &cpu_policy, ResourcePolicy &resource_policy)
@ -452,8 +439,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy&
if (current.get_state () == Schedulable::state_future) if (current.get_state () == Schedulable::state_future)
{ {
Process &parent = current.get_process (); Process &parent = current.get_process ();
if ((long) parent.get_arrival_time() <= current_instant && if ((long) parent.get_arrival_time () <= current_instant && parent.get_elapsed_time () == current.get_arrival_time ())
parent.get_elapsed_time() == current.get_arrival_time())
current.set_state (Schedulable::state_ready); current.set_state (Schedulable::state_ready);
} }
@ -475,7 +461,8 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy&
// Now if the simulation ended we append the newly // Now if the simulation ended we append the newly
// created environment and return false // created environment and return false
if (alive_threads == 0) goto final_cleanup; if (alive_threads == 0)
goto final_cleanup;
// Use the CPU Policy to sort the ready queue, and manage // Use the CPU Policy to sort the ready queue, and manage
// requests for the newly selected running thread // requests for the newly selected running thread
@ -513,7 +500,8 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy&
// a new thread and it can't run for some reason (it goes blocked, or // a new thread and it can't run for some reason (it goes blocked, or
// terminates), then we remove it from the built ReadyQueue and // terminates), then we remove it from the built ReadyQueue and
// check if the next one can run (see while loop further below). // check if the next one can run (see while loop further below).
if(_ready_queue->size() > 0) cpu_policy.sort_queue(); if (_ready_queue->size () > 0)
cpu_policy.sort_queue ();
// If we don't have to select a new running thread, because the old one didn't // If we don't have to select a new running thread, because the old one didn't
// have to release the CPU, our work may end here: // have to release the CPU, our work may end here:
@ -595,7 +583,6 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy&
new_running.set_last_acquisition (current_instant); new_running.set_last_acquisition (current_instant);
} }
} }
} }
catch (const CPUPolicyException &e) catch (const CPUPolicyException &e)
{ {

View File

@ -23,5 +23,5 @@
using namespace sgpem; using namespace sgpem;
SerializeVisitor::~SerializeVisitor () SerializeVisitor::~SerializeVisitor ()
{} {
}

View File

@ -34,4 +34,3 @@ Serializer::~Serializer()
{ {
// INSPECTOR NOTE: no unregister here? // INSPECTOR NOTE: no unregister here?
} }

View File

@ -18,12 +18,10 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/serializer_error.hh> #include <sgpemv2/serializer_error.hh>
using namespace sgpem; using namespace sgpem;
SerializerError::SerializerError(const std::string& what) : SerializerError::SerializerError (const std::string &what) : std::runtime_error (what)
std::runtime_error(what) {
{} }

View File

@ -18,10 +18,8 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/. // along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include <sgpemv2/serializers_gatekeeper.hh>
#include <sgpemv2/serializer.hh> #include <sgpemv2/serializer.hh>
#include <sgpemv2/serializers_gatekeeper.hh>
// Include full template definition only in implementation files: // Include full template definition only in implementation files:
#include <sgpemv2/templates/singleton.tcc> #include <sgpemv2/templates/singleton.tcc>
@ -29,9 +27,9 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
using std::vector;
using std::find; using std::find;
using std::runtime_error; using std::runtime_error;
using std::vector;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
@ -71,8 +69,6 @@ SerializersGatekeeper::unregister_serializer(Serializer* serializer)
} }
SerializersGatekeeper::SerializersGatekeeper () SerializersGatekeeper::SerializersGatekeeper ()
{ {
} }

View File

@ -5,4 +5,3 @@
#define POLDIR "@policiesdir@" #define POLDIR "@policiesdir@"
#define PLUGDIR "@plugindir@" #define PLUGDIR "@plugindir@"
#define EXAMPLESDIR "@examplesdir@" #define EXAMPLESDIR "@examplesdir@"

View File

@ -26,16 +26,16 @@ namespace sgpem
class CPUPolicyManager; class CPUPolicyManager;
class CPUPolicy; class CPUPolicy;
class History; class History;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <vector>
#include <map> #include <map>
#include <stdexcept> #include <stdexcept>
#include <vector>
#include <sgpemv2/templates/singleton.hh>
#include <sgpemv2/malformed_policy_exception.hh> #include <sgpemv2/malformed_policy_exception.hh>
#include <sgpemv2/templates/singleton.hh>
#include <sgpemv2/user_interrupt_exception.hh> #include <sgpemv2/user_interrupt_exception.hh>
namespace sgpem namespace sgpem
@ -89,7 +89,6 @@ namespace sgpem
void activate_policy (History *history, CPUPolicy *policy); void activate_policy (History *history, CPUPolicy *policy);
private: private:
CPUPoliciesGatekeeper (); //private constructor. CPUPoliciesGatekeeper (); //private constructor.
CPUPoliciesGatekeeper (const CPUPoliciesGatekeeper &); CPUPoliciesGatekeeper (const CPUPoliciesGatekeeper &);
CPUPoliciesGatekeeper &operator= (const CPUPoliciesGatekeeper &); CPUPoliciesGatekeeper &operator= (const CPUPoliciesGatekeeper &);
@ -101,7 +100,6 @@ namespace sgpem
std::map<History *, CPUPolicy *> _active_policies; std::map<History *, CPUPolicy *> _active_policies;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif //~ CPU_POLICIES_GATEKEEPER_HH #endif //~ CPU_POLICIES_GATEKEEPER_HH

View File

@ -21,14 +21,14 @@
#ifndef CPU_POLICY_HH #ifndef CPU_POLICY_HH
#define CPU_POLICY_HH 1 #define CPU_POLICY_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "gettext.h" #include "gettext.h"
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include <sgpemv2/malformed_policy_exception.hh>
#include <sgpemv2/policy_parameters.hh> #include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh> #include <sgpemv2/user_interrupt_exception.hh>
#include <sgpemv2/malformed_policy_exception.hh>
#include <stdexcept> #include <stdexcept>
@ -115,9 +115,8 @@ namespace sgpem
private: private:
// Used by callback_get_policy: // Used by callback_get_policy:
static CPUPolicy *_callback_policy; static CPUPolicy *_callback_policy;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif //~ CPU_POLICY_HH #endif //~ CPU_POLICY_HH

View File

@ -38,6 +38,6 @@ namespace sgpem
public: public:
explicit CPUPolicyException (const std::string &msg = ""); explicit CPUPolicyException (const std::string &msg = "");
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -73,7 +73,6 @@ namespace sgpem
std::vector<CPUPolicy *> _policies; std::vector<CPUPolicy *> _policies;
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -61,7 +61,6 @@ namespace sgpem
static CppResourcePolicyManager _default_instance; static CppResourcePolicyManager _default_instance;
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -71,8 +71,7 @@ namespace sgpem
/// ///
/// \return a constant set of snapshots of processes /// \return a constant set of snapshots of processes
virtual const Processes& virtual const Processes &get_processes () const = 0;
get_processes() const = 0;
/// \brief Returns an indexed set of snapshots of the resources /// \brief Returns an indexed set of snapshots of the resources
@ -89,8 +88,7 @@ namespace sgpem
/// ///
/// \return an indexed constant set of snapshot of resources. /// \return an indexed constant set of snapshot of resources.
virtual const Resources& virtual const Resources &get_resources () const = 0;
get_resources() const = 0;
/// \brief Returns a snapshot of the current request queue for a resource. /// \brief Returns a snapshot of the current request queue for a resource.
@ -100,8 +98,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 SubRequestQueue& virtual const SubRequestQueue &get_request_queue (resource_key_t resource_key) const = 0;
get_request_queue(resource_key_t resource_key) const = 0;
/// \brief Returns a snapshot of the current scheduler's ready queue. /// \brief Returns a snapshot of the current scheduler's ready queue.
@ -111,18 +108,15 @@ 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 = 0;
get_sorted_queue() const = 0;
/// \brief The standard virtual destructor. /// \brief The standard virtual destructor.
/// The standard virtual destructor. /// The standard virtual destructor.
virtual virtual ~Environment () = 0;
~Environment() = 0;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -30,15 +30,15 @@
#include <vector> #include <vector>
// Do not include complete template definition here: // Do not include complete template definition here:
#include <sgpemv2/templates/singleton.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/request.hh> #include <sgpemv2/request.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/templates/singleton.hh>
namespace sgpem namespace sgpem
{ {
class GlobalPreferences; class GlobalPreferences;
class KeyFile; class KeyFile;
} } // namespace sgpem
namespace sgpem namespace sgpem
{ {
@ -49,6 +49,7 @@ namespace sgpem
class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences> class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences>
{ {
friend class Singleton<GlobalPreferences>; friend class Singleton<GlobalPreferences>;
public: public:
typedef std::vector<Glib::ustring> DirVector; typedef std::vector<Glib::ustring> DirVector;
typedef DirVector::iterator DirVectorIt; typedef DirVector::iterator DirVectorIt;
@ -157,6 +158,6 @@ namespace sgpem
*/ */
int _speed; int _speed;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -137,10 +137,8 @@ namespace sgpem
\param availability The instant from wich the resource is available. \param availability The instant from wich the resource is available.
\return a pair with unique key and pointer to the resource created. \return a pair with unique key and pointer to the resource created.
*/ */
virtual ResourcePair add_resource(const Glib::ustring& name, virtual ResourcePair
bool preemptable = false, add_resource (const Glib::ustring &name, bool preemptable = false, size_t places = 1, size_t availability = 0) = 0;
size_t places = 1,
size_t availability = 0) = 0;
/** /**
\brief Change data of an existing resource. \brief Change data of an existing resource.
@ -151,11 +149,8 @@ namespace sgpem
\param places Number of places of the resource. \param places Number of places of the resource.
\param availability The instant from wich the resource is available. \param availability The instant from wich the resource is available.
*/ */
virtual void edit_resource(Resource& resource, virtual void edit_resource (Resource &resource, const Glib::ustring &name, bool preemptable = false,
const Glib::ustring& name, size_t places = 1, size_t availability = 0) = 0;
bool preemptable = false,
size_t places = 1,
size_t availability = 0) = 0;
/** /**
\brief Add a Process to the simulation. \brief Add a Process to the simulation.
@ -166,9 +161,7 @@ namespace sgpem
(scheduler can change it during execution). (scheduler can change it during execution).
\return The newly created process. \return The newly created process.
*/ */
virtual Process& add_process(const Glib::ustring& name, virtual Process &add_process (const Glib::ustring &name, time_t arrival_time, prio_t base_priority = 0) = 0;
time_t arrival_time,
prio_t base_priority = 0) = 0;
/** /**
\brief Edit an exixting Process in the simulation. \brief Edit an exixting Process in the simulation.
@ -179,10 +172,7 @@ namespace sgpem
\param base_priority Process priority at start up time \param base_priority Process priority at start up time
(scheduler can change it during execution). (scheduler can change it during execution).
*/ */
virtual void edit_process(Process& process, virtual void edit_process (Process &process, const Glib::ustring &name, time_t arrival_time, prio_t base_priority = 0) = 0;
const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority = 0) = 0;
/** /**
@ -196,10 +186,7 @@ namespace sgpem
(scheduler can change it during execution). (scheduler can change it during execution).
\return The newly created thread. \return The newly created thread.
*/ */
virtual Thread& add_thread(const Glib::ustring& name, virtual Thread &add_thread (const Glib::ustring &name, Process &parent, time_t cpu_time, time_t arrival_time = 0,
Process& parent,
time_t cpu_time,
time_t arrival_time = 0,
prio_t base_priority = 0) = 0; prio_t base_priority = 0) = 0;
/** /**
@ -212,10 +199,7 @@ namespace sgpem
\param base_priority Thread priority at start up time \param base_priority Thread priority at start up time
(scheduler can change it during execution). (scheduler can change it during execution).
*/ */
virtual void edit_thread(Thread& thread, virtual void edit_thread (Thread &thread, const Glib::ustring &name, time_t cpu_time, time_t arrival_time = 0,
const Glib::ustring& name,
time_t cpu_time,
time_t arrival_time = 0,
prio_t base_priority = 0) = 0; prio_t base_priority = 0) = 0;
/** /**
@ -225,8 +209,7 @@ namespace sgpem
\param instant When the request arrives. \param instant When the request arrives.
\return The newly created request. \return The newly created request.
*/ */
virtual Request& add_request(Thread& owner, virtual Request &add_request (Thread &owner, time_t instant) = 0;
time_t instant) = 0;
/** /**
\brief Edit a Request. \brief Edit a Request.
@ -234,8 +217,7 @@ namespace sgpem
\param request Reference to editing request. \param request Reference to editing request.
\param instant When the request arrives. \param instant When the request arrives.
*/ */
virtual void edit_request(Request& request, virtual void edit_request (Request &request, time_t instant) = 0;
time_t instant) = 0;
/** /**
@ -246,9 +228,7 @@ namespace sgpem
\param duration Total time of request usage. \param duration Total time of request usage.
\return The newly created subrequest. \return The newly created subrequest.
*/ */
virtual SubRequest& add_subrequest(Request& request, virtual SubRequest &add_subrequest (Request &request, resource_key_t resource_key, time_t duration) = 0;
resource_key_t resource_key,
time_t duration) = 0;
/** /**
\brief Edit an existing SubRequest. \brief Edit an existing SubRequest.
@ -257,9 +237,7 @@ namespace sgpem
\param resource_key Key of the requested resource. \param resource_key Key of the requested resource.
\param duration Total time of request usage. \param duration Total time of request usage.
*/ */
virtual void edit_subrequest(SubRequest& subrequest, virtual void edit_subrequest (SubRequest &subrequest, resource_key_t resource_key, time_t duration) = 0;
resource_key_t resource_key,
time_t duration) = 0;
/** /**
\return actual instant (current time in simulation) \return actual instant (current time in simulation)
*/ */
@ -343,6 +321,6 @@ namespace sgpem
}; //~ class History::LockNotify }; //~ class History::LockNotify
}//~ namespace sgpem } // namespace sgpem
#endif //~ HISTORY_HH #endif //~ HISTORY_HH

View File

@ -25,7 +25,7 @@ namespace sgpem
{ {
class History; class History;
class HistoryObserver; class HistoryObserver;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
@ -46,11 +46,8 @@ namespace sgpem
virtual void update (const History &changed_history) = 0; virtual void update (const History &changed_history) = 0;
virtual ~HistoryObserver (); virtual ~HistoryObserver ();
} }; // class HistoryObserver
; // class HistoryObserver
}//~ namespace sgpem } // namespace sgpem
#endif //HISTORY_OBSERVER_H #endif //HISTORY_OBSERVER_H

View File

@ -40,9 +40,8 @@ namespace sgpem
* \param what A constant string msg indicating the failure reason. * \param what A constant string msg indicating the failure reason.
*/ */
InvalidPluginException (const std::string &what); InvalidPluginException (const std::string &what);
} }; //~ class InvalidPluginException
; //~ class InvalidPluginException
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -50,7 +50,6 @@ namespace sgpem
*/ */
class SG_DLLEXPORT KeyFile class SG_DLLEXPORT KeyFile
{ {
public: public:
/** \brief Elements iterator type definition. */ /** \brief Elements iterator type definition. */
typedef std::map<Glib::ustring, Glib::ustring>::const_iterator elements_iterator; typedef std::map<Glib::ustring, Glib::ustring>::const_iterator elements_iterator;
@ -103,10 +102,10 @@ namespace sgpem
* \param os the stream to write to. * \param os the stream to write to.
*/ */
void file_write (std::ostream &os); void file_write (std::ostream &os);
private:
private:
std::map<Glib::ustring, Glib::ustring> _elements; std::map<Glib::ustring, Glib::ustring> _elements;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -31,7 +31,6 @@
namespace sgpem namespace sgpem
{ {
/// \brief An exception signaling a non well-formed script. /// \brief An exception signaling a non well-formed script.
/// Represents an exception which may be raised to signal that a script which /// Represents an exception which may be raised to signal that a script which
/// was supposed to represent a policy is not well-formed. /// was supposed to represent a policy is not well-formed.
@ -46,6 +45,6 @@ namespace sgpem
/// \param msg a message carrying detailed information. /// \param msg a message carrying detailed information.
explicit MalformedPolicyException (const std::string &msg = ""); explicit MalformedPolicyException (const std::string &msg = "");
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -30,7 +30,6 @@
namespace sgpem namespace sgpem
{ {
/// \brief A link to a loaded DSO object /// \brief A link to a loaded DSO object
/// ///
/// When a plugin is found, PluginManager::rescan_dirs() tries to load it by /// When a plugin is found, PluginManager::rescan_dirs() tries to load it by
@ -43,7 +42,6 @@ namespace sgpem
class SG_DLLEXPORT Module : public Glib::Module class SG_DLLEXPORT Module : public Glib::Module
{ {
public: public:
/// \brief Constructor taking an identifier. /// \brief Constructor taking an identifier.
/// ///
/// Constructor taking an identifier. /// Constructor taking an identifier.
@ -111,10 +109,8 @@ namespace sgpem
f_ustring get_author_ptr; f_ustring get_author_ptr;
f_float get_version_ptr; f_float get_version_ptr;
} }; //~ class Module
; //~ class Module
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -41,6 +41,6 @@ namespace sgpem
public: public:
explicit NullPolicyException (const char *msg = ""); explicit NullPolicyException (const char *msg = "");
}; };
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -39,6 +39,7 @@ namespace sgpem
class SG_DLLEXPORT PluginManager : public Singleton<PluginManager> class SG_DLLEXPORT PluginManager : public Singleton<PluginManager>
{ {
friend class Singleton<PluginManager>; friend class Singleton<PluginManager>;
public: public:
std::vector<Module *> get_module_list () const; std::vector<Module *> get_module_list () const;
@ -49,10 +50,8 @@ namespace sgpem
std::vector<Module *> _modules; std::vector<Module *> _modules;
} }; //~ class PluginManager
; //~ class PluginManager
} //~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -24,22 +24,22 @@
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <map> #include <map>
#include <string>
#include <stdexcept> #include <stdexcept>
#include <string>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
namespace sgpem namespace sgpem
{ {
class SG_DLLEXPORT PolicyParametersException : public std::runtime_error class SG_DLLEXPORT PolicyParametersException : public std::runtime_error
{ {
public: public:
PolicyParametersException(std::string msg): std::runtime_error(msg) {} PolicyParametersException (std::string msg) : std::runtime_error (msg)
{
}
}; };
/** \brief Represents all configurable parameters of a single scheduling policy. /** \brief Represents all configurable parameters of a single scheduling policy.
Represents all configurable parameters of a single scheduling policy. Is is used by the user Represents all configurable parameters of a single scheduling policy. Is is used by the user
@ -49,7 +49,6 @@ namespace sgpem
class SG_DLLEXPORT PolicyParameters class SG_DLLEXPORT PolicyParameters
{ {
public: public:
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** \brief This class represents a sigle parameter of type \c T /** \brief This class represents a sigle parameter of type \c T
@ -61,7 +60,6 @@ namespace sgpem
class SG_DLLEXPORT Parameter class SG_DLLEXPORT Parameter
{ {
public: public:
/** \brief Constructs the parameter /** \brief Constructs the parameter
\param name The name of the parameter. This string will be used to refer to this parameter, thus it MUST \param name The name of the parameter. This string will be used to refer to this parameter, thus it MUST
be uniqe (one string identifies \b only ONE parameter) be uniqe (one string identifies \b only ONE parameter)
@ -71,9 +69,8 @@ namespace sgpem
\param required Denotes if this parameter is required by the policy. \param required Denotes if this parameter is required by the policy.
\param default_value The initial value of this parameter. (If not specified it's set to 0). \param default_value The initial value of this parameter. (If not specified it's set to 0).
*/ */
Parameter(Glib::ustring name, const T& value, Parameter (Glib::ustring name, const T &value, const T &lower_bound, const T &upper_bound, const bool &required,
const T& lower_bound, const T& upper_bound, const T &default_value = 0);
const bool& required, const T& default_value = 0);
/** \returns The name of the parameter (its UNIQUE key) /** \returns The name of the parameter (its UNIQUE key)
*/ */
@ -132,7 +129,8 @@ namespace sgpem
\param required Denotes if this parameter is required by the policy. \param required Denotes if this parameter is required by the policy.
\param default_value The initial value of this parameter. (If not specified it's set to 0). \param default_value The initial value of this parameter. (If not specified it's set to 0).
*/ */
void register_int(Glib::ustring name, const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value = 0); void register_int (Glib::ustring name, const int &lower_bound, const int &upper_bound, const bool &required,
const int &default_value = 0);
/**\brief Registers a FLOAT parameter. /**\brief Registers a FLOAT parameter.
@ -146,7 +144,8 @@ namespace sgpem
\param required Denotes if this parameter is required by the policy. \param required Denotes if this parameter is required by the policy.
\param default_value The initial value of this parameter. (If not specified it's set to 0.0f). \param default_value The initial value of this parameter. (If not specified it's set to 0.0f).
*/ */
void register_float(Glib::ustring name, const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value = 0.0f); void register_float (Glib::ustring name, const float &lower_bound, const float &upper_bound, const bool &required,
const float &default_value = 0.0f);
/**\brief Registers a STRING parameter. /**\brief Registers a STRING parameter.
@ -245,13 +244,12 @@ namespace sgpem
Glib::ustring get_string (Glib::ustring name) const; Glib::ustring get_string (Glib::ustring name) const;
private: private:
std::map<Glib::ustring, Parameter<int>> int_map; std::map<Glib::ustring, Parameter<int>> int_map;
std::map<Glib::ustring, Parameter<float>> float_map; std::map<Glib::ustring, Parameter<float>> float_map;
std::map<Glib::ustring, Parameter<Glib::ustring>> string_map; std::map<Glib::ustring, Parameter<Glib::ustring>> string_map;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -21,8 +21,8 @@
#ifndef PROCESS_HH #ifndef PROCESS_HH
#define PROCESS_HH 1 #define PROCESS_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include <sgpemv2/sgpemv2-visibility.hh>
#include <vector> #include <vector>
#include <sgpemv2/schedulable.hh> #include <sgpemv2/schedulable.hh>
@ -43,7 +43,6 @@ namespace sgpem
virtual void serialize (SerializeVisitor &translator) const = 0; virtual void serialize (SerializeVisitor &translator) const = 0;
}; };
}//~namespace sgpem } // namespace sgpem
#endif //~ PROCESS_HH #endif //~ PROCESS_HH

View File

@ -23,10 +23,10 @@
#include "thread_statistics.hh" #include "thread_statistics.hh"
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/schedulable_statistics.hh>
#include <sgpemv2/thread_statistics.hh>
#include <sgpemv2/process.hh> #include <sgpemv2/process.hh>
#include <sgpemv2/schedulable_statistics.hh>
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/thread_statistics.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
@ -47,6 +47,6 @@ namespace sgpem
protected: protected:
ProcessStatistics (); ProcessStatistics ();
}; };
} } // namespace sgpem
#endif #endif

View File

@ -102,7 +102,6 @@ namespace sgpem
Threads _scheds; Threads _scheds;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -27,7 +27,7 @@ namespace sgpem
class SerializeVisitor; class SerializeVisitor;
class SubRequest; class SubRequest;
class Thread; class Thread;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <vector> #include <vector>
@ -60,7 +60,6 @@ namespace sgpem
virtual void serialize (SerializeVisitor &translator) const = 0; virtual void serialize (SerializeVisitor &translator) const = 0;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -21,8 +21,8 @@
#ifndef RESOURCE_HH #ifndef RESOURCE_HH
#define RESOURCE_HH 1 #define RESOURCE_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include <sgpemv2/sgpemv2-visibility.hh>
namespace sgpem namespace sgpem
{ {
@ -57,7 +57,6 @@ namespace sgpem
virtual void serialize (SerializeVisitor &translator) const = 0; virtual void serialize (SerializeVisitor &translator) const = 0;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -26,13 +26,13 @@ namespace sgpem
class ResourcePolicyManager; class ResourcePolicyManager;
class ResourcePolicy; class ResourcePolicy;
class History; class History;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <vector>
#include <map> #include <map>
#include <stdexcept> #include <stdexcept>
#include <vector>
#include <sgpemv2/templates/singleton.hh> #include <sgpemv2/templates/singleton.hh>
@ -116,7 +116,6 @@ namespace sgpem
std::map<History *, ResourcePolicy *> _active_policies; std::map<History *, ResourcePolicy *> _active_policies;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif //RESOURCE_POLICIES_GATEKEEPER_HH #endif //RESOURCE_POLICIES_GATEKEEPER_HH

View File

@ -28,17 +28,16 @@ namespace sgpem
#include "gettext.h" #include "gettext.h"
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
#include <sgpemv2/environment.hh> #include <sgpemv2/environment.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/sub_request.hh> #include <sgpemv2/sub_request.hh>
#include <sgpemv2/user_interrupt_exception.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
namespace sgpem namespace sgpem
{ {
/// \brief A resource allocation policy. /// \brief A resource allocation policy.
/// ///
/// A resource allocation policy manages the queues of requests. /// A resource allocation policy manages the queues of requests.
@ -47,7 +46,6 @@ namespace sgpem
class SG_DLLEXPORT ResourcePolicy class SG_DLLEXPORT ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor. /// \brief Standard virtual destructor.
/// ///
/// Standard virtual destructor. /// Standard virtual destructor.
@ -108,7 +106,7 @@ namespace sgpem
PolicyParameters _parameters; PolicyParameters _parameters;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif #endif

View File

@ -54,7 +54,6 @@ namespace sgpem
virtual const Policies &get_avail_policies () const = 0; virtual const Policies &get_avail_policies () const = 0;
}; };
} //~ namespace sgpem } // namespace sgpem
#endif // ~ RESOURCE_POLICY_MANAGER_HH #endif // ~ RESOURCE_POLICY_MANAGER_HH

View File

@ -42,7 +42,6 @@ namespace sgpem
class SG_DLLEXPORT Schedulable class SG_DLLEXPORT Schedulable
{ {
public: public:
/// \brief This flag describes the actual state of the schedulable. /// \brief This flag describes the actual state of the schedulable.
/// ///
/// You can think of this flag as the particular stack in the OS where the /// You can think of this flag as the particular stack in the OS where the
@ -228,6 +227,6 @@ namespace sgpem
/// \param translator the visitor used to serialize this entity. /// \param translator the visitor used to serialize this entity.
virtual void serialize (SerializeVisitor &translator) const = 0; virtual void serialize (SerializeVisitor &translator) const = 0;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -91,7 +91,6 @@ namespace sgpem
virtual const Schedulable *get_core () const = 0; virtual const Schedulable *get_core () const = 0;
protected: protected:
SchedulableStatistics (); SchedulableStatistics ();
int _execution_time; int _execution_time;
@ -103,6 +102,6 @@ namespace sgpem
int _resource_usage_time; int _resource_usage_time;
int _resource_waitings_time; int _resource_waitings_time;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -24,16 +24,16 @@ namespace sgpem
{ {
class Scheduler; class Scheduler;
class CPUPolicy; class CPUPolicy;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/cpu_policy.hh> #include <sgpemv2/cpu_policy.hh>
#include <sgpemv2/resource_policy.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/ready_queue.hh>
#include <sgpemv2/user_interrupt_exception.hh>
#include <sgpemv2/malformed_policy_exception.hh> #include <sgpemv2/malformed_policy_exception.hh>
#include <sgpemv2/ready_queue.hh>
#include <sgpemv2/resource_policy.hh>
#include <sgpemv2/user_interrupt_exception.hh>
// Do not include full template definition here // Do not include full template definition here
#include <sgpemv2/templates/singleton.hh> #include <sgpemv2/templates/singleton.hh>
@ -59,6 +59,7 @@ namespace sgpem
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler> class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
{ {
friend class Singleton<Scheduler>; friend class Singleton<Scheduler>;
public: public:
/** /**
Generates a new ReadyQueue representing the status of the processes Generates a new ReadyQueue representing the status of the processes
@ -98,6 +99,6 @@ namespace sgpem
Glib::Mutex _step_mutex; Glib::Mutex _step_mutex;
}; };
}//~ namespace sgpem } // namespace sgpem
#endif //SCHEDULER_HH #endif //SCHEDULER_HH

View File

@ -30,7 +30,7 @@ namespace sgpem
class Thread; class Thread;
class Request; class Request;
class SubRequest; class SubRequest;
} } // namespace sgpem
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
@ -96,7 +96,6 @@ namespace sgpem
*/ */
virtual void from_subrequest (const SubRequest &obj) = 0; virtual void from_subrequest (const SubRequest &obj) = 0;
}; };
} } // namespace sgpem
#endif #endif

View File

@ -21,9 +21,9 @@
#ifndef SERIALIZER_HH #ifndef SERIALIZER_HH
#define SERIALIZER_HH 1 #define SERIALIZER_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/history.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/serializer_error.hh> #include <sgpemv2/serializer_error.hh>
#include <sgpemv2/sgpemv2-visibility.hh>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
@ -41,10 +41,10 @@ namespace sgpem
virtual void restore_snapshot (const Glib::ustring &filename, History &hist) = 0; virtual void restore_snapshot (const Glib::ustring &filename, History &hist) = 0;
virtual const Glib::ustring get_filename_extension () = 0; virtual const Glib::ustring get_filename_extension () = 0;
virtual const Glib::ustring get_filename_description () = 0; virtual const Glib::ustring get_filename_description () = 0;
protected: protected:
private: private:
}; };
} } // namespace sgpem
#endif #endif

Some files were not shown because too many files have changed in this diff Show More