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

View File

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

View File

@ -42,8 +42,8 @@ ConcreteEnvironment::ConcreteEnvironment()
}
ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
Environment(ce), _resources(ce._resources), _processes(), _sched_queue(), _sreq_queues(ce._sreq_queues)
ConcreteEnvironment::ConcreteEnvironment (const ConcreteEnvironment &ce)
: 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 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.
// for each subrequest
@ -117,12 +116,9 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
}
}
}
}
const Environment::Processes &
ConcreteEnvironment::get_processes () const
{
@ -130,7 +126,6 @@ ConcreteEnvironment::get_processes() const
}
ConcreteEnvironment::Processes &
ConcreteEnvironment::get_processes ()
{
@ -138,7 +133,6 @@ ConcreteEnvironment::get_processes()
}
const Environment::Resources &
ConcreteEnvironment::get_resources () const
{
@ -146,7 +140,6 @@ ConcreteEnvironment::get_resources() const
}
ConcreteEnvironment::Resources &
ConcreteEnvironment::get_resources ()
{
@ -154,7 +147,6 @@ ConcreteEnvironment::get_resources()
}
const Environment::SubRequestQueue &
ConcreteEnvironment::get_request_queue (resource_key_t resource_key) const
{
@ -177,7 +169,6 @@ ConcreteEnvironment::get_subrequest_queues()
}
const ReadyQueue &
ConcreteEnvironment::get_sorted_queue () const
{
@ -185,7 +176,6 @@ ConcreteEnvironment::get_sorted_queue() const
}
ReadyQueue &
ConcreteEnvironment::get_sorted_queue ()
{
@ -193,13 +183,11 @@ ConcreteEnvironment::get_sorted_queue()
}
ConcreteEnvironment::~ConcreteEnvironment ()
{
// This call will invoke the DynamicProcess virtual destructor
// Which will delete on cascade all DynamicThreads and so on.
for_each(_processes.begin(), _processes.end(),
[] (auto *p) { delete p; });
for_each (_processes.begin (), _processes.end (), [](auto *p) { delete p; });
// We do the same with Resources.
for (Resources::iterator it = _resources.begin (); it != _resources.end (); it++)
@ -211,7 +199,4 @@ ConcreteEnvironment::~ConcreteEnvironment()
}
// -------------------------------- TO BE FIXED ----------------

View File

@ -25,14 +25,14 @@ namespace sgpem
{
class ConcreteEnvironment;
class SerializeVisitor;
}
} // namespace sgpem
#include "dynamic_process.hh"
#include "dynamic_request.hh"
#include <sgpemv2/environment.hh>
#include <sgpemv2/resource.hh>
#include <sgpemv2/ready_queue.hh>
#include <sgpemv2/resource.hh>
namespace sgpem
{
@ -152,7 +152,6 @@ namespace sgpem
virtual ReadyQueue &get_sorted_queue ();
private:
/// \brief The container of all Resource objecs.
///
/// Actually contains only DynamicResource objects.
@ -174,6 +173,6 @@ namespace sgpem
}; //~ class ConcreteEnvironment
} //~ namespace sgpem
} // namespace sgpem
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,14 +19,14 @@
#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_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>
@ -34,7 +34,6 @@ using namespace sgpem;
using namespace std;
ConcreteStatistics::ConcreteStatistics () : _sim_stats (0)
{
calculateStatisticsAt (-1);
@ -75,5 +74,3 @@ ConcreteStatistics::get_process_statistics() const
rit.push_back (&_proc_stats[i]);
return rit;
}

View File

@ -22,17 +22,15 @@
#define CONCRETE_STATISTICS_HH 1
#include <sgpemv2/statistics.hh>
#include "concrete_process_statistics.hh"
#include "concrete_simulation_statistics.hh"
#include <sgpemv2/statistics.hh>
#include <glibmm/ustring.h>
#include <vector>
namespace sgpem
{
/** \brief Implements 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;
private:
ConcreteSimulationStatistics *_sim_stats;
std::vector<ConcreteProcessStatistics> _proc_stats;
};
}
} // namespace sgpem
#endif

View File

@ -19,15 +19,15 @@
#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 <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 sgpem;
@ -78,8 +78,7 @@ ConcreteThreadStatistics::ConcreteThreadStatistics(const Thread* core, const int
}
_execution_time++;
}
if (threads[i_t]->get_state() != Schedulable::state_future &&
threads[i_t]->get_state() != Schedulable::state_terminated)
if (threads[i_t]->get_state () != Schedulable::state_future && threads[i_t]->get_state () != Schedulable::state_terminated)
{
_turn_around++;
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;
}
}
if (threads[i_t]->get_state() == Schedulable::state_blocked
|| threads[i_t]->get_state() == Schedulable::state_ready)
if (threads[i_t]->get_state () == Schedulable::state_blocked || threads[i_t]->get_state () == Schedulable::state_ready)
{
_total_inactivity++;
if (!iniziato && _response_time != -1)

View File

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

View File

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

View File

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

View File

@ -18,12 +18,10 @@
// 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 <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 <sgpemv2/templates/singleton.tcc>
@ -34,10 +32,10 @@
#include <cassert>
#include <iostream>
using std::vector;
using std::map;
using std::find;
using std::map;
using std::runtime_error;
using std::vector;
using namespace sgpem;
// 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);
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.");
return policy->second;
@ -131,11 +130,11 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
// the caller need to know if it failed
throw;
}
}
CPUPoliciesGatekeeper::CPUPoliciesGatekeeper ()
{}
{
}
void
CPUPoliciesGatekeeper::deactivate_policies (CPUPolicyManager *manager)
@ -166,4 +165,3 @@ CPUPoliciesGatekeeper::deactivate_policies(CPUPolicyManager* manager)
}
} //~ for(avail_it)
}

View File

@ -28,7 +28,8 @@ CPUPolicy* CPUPolicy::_callback_policy = nullptr;
CPUPolicy::~CPUPolicy ()
{}
{
}
PolicyParameters &
@ -38,12 +39,12 @@ CPUPolicy::get_parameters()
}
CPUPolicy *
CPUPolicy::callback_get_policy ()
{
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;
}

View File

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

View File

@ -18,9 +18,8 @@
// 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_policy_manager.hh>
using namespace sgpem;
@ -34,4 +33,3 @@ CPUPolicyManager::~CPUPolicyManager()
{
CPUPoliciesGatekeeper::get_instance ().unregister_manager (this);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -55,10 +55,8 @@
#define gettext(Msgid) ((const char *) (Msgid))
#define dgettext(Domainname, Msgid) ((const char *) (Msgid))
#define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(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 ngettext(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) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
#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.
template class sgpem::Singleton<GlobalPreferences>;
GlobalPreferences::GlobalPreferences()
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000)
{}
GlobalPreferences::GlobalPreferences () : _mod_dirs (1, PLUGDIR), _pol_dirs (1, POLDIR), _speed (1000)
{
}
Glib::ustring
@ -56,11 +56,7 @@ GlobalPreferences::get_preferences_dir() const
#ifdef _MSC_VER
TCHAR raw_path[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_APPDATA,
nullptr,
SHGFP_TYPE_CURRENT,
raw_path)))
if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, raw_path)))
{
// if UNICODE, characters are 16bit, otherwise plain bytes
#ifdef UNICODE
@ -201,7 +197,6 @@ GlobalPreferences::load_configrc()
void
GlobalPreferences::key_file_read (KeyFile &kf)
{
_mod_dirs.clear ();
_pol_dirs.clear ();
std::vector<Glib::ustring> old_mod_dirs (1, PLUGDIR);
@ -265,8 +260,6 @@ GlobalPreferences::key_file_read(KeyFile& kf)
}
}
}
}
void
@ -327,5 +320,3 @@ GlobalPreferences::key_file_write(KeyFile& kf)
kf.insert_key_value (key, value);
}
}

View File

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

View File

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

View File

@ -20,6 +20,8 @@
#include <sgpemv2/history_observer.hh>
sgpem::HistoryObserver::~HistoryObserver() {}
sgpem::HistoryObserver::~HistoryObserver ()
{
}
// 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/.
#include <sgpemv2/invalid_plugin_exception.hh>
using namespace sgpem;
InvalidPluginException::InvalidPluginException(const std::string& what) :
std::runtime_error(what)
{}
InvalidPluginException::InvalidPluginException (const std::string &what) : std::runtime_error (what)
{
}

View File

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

View File

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

View File

@ -21,8 +21,8 @@
using namespace sgpem;
Module::Module(const Glib::ustring& identifier) :
Glib::Module(identifier),
Module::Module (const Glib::ustring &identifier)
: Glib::Module (identifier),
_enabled (false),
_id (identifier),
on_init_ptr (NULL),
@ -32,7 +32,8 @@ Module::Module(const Glib::ustring& identifier) :
get_author_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. :-)
std::string prefix = "sgpem__Plugin__";
@ -89,4 +90,3 @@ Module::get_enabled() const
{
return _enabled;
}

View File

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

View File

@ -18,19 +18,17 @@
// 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/module.hh>
#include <sgpemv2/plugin_manager.hh>
#include <sgpemv2/templates/singleton.tcc>
#include <glibmm/fileutils.h>
#include <glibmm/pattern.h>
#include <iostream>
#include <algorithm>
#include <iostream>
using namespace sgpem;
@ -48,8 +46,7 @@ PluginManager::rescan_dirs()
{
Module *module = nullptr;
for_each(_modules.begin(), _modules.end(),
[] (auto *p) { delete p; });
for_each (_modules.begin (), _modules.end (), [](auto *p) { delete p; });
_modules.clear ();
GlobalPreferences &prefs = GlobalPreferences::get_instance ();
@ -93,4 +90,3 @@ PluginManager::PluginManager()
{
rescan_dirs ();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,12 +18,10 @@
// 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 <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 <sgpemv2/templates/singleton.tcc>
@ -33,10 +31,10 @@
#include <algorithm>
#include <cassert>
using std::vector;
using std::map;
using std::find;
using std::map;
using std::runtime_error;
using std::vector;
using namespace sgpem;
// 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);
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."));
return *policy->second;
@ -102,7 +101,8 @@ ResourcePoliciesGatekeeper::activate_policy(History *history, ResourcePolicy* po
}
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper ()
{}
{
}
void
ResourcePoliciesGatekeeper::deactivate_policies (const ResourcePolicyManager &manager)
@ -122,4 +122,3 @@ ResourcePoliciesGatekeeper::deactivate_policies(const ResourcePolicyManager& man
++it;
} //~ for(avail_it)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,9 +18,8 @@
// 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_policy_manager.hh>
using namespace sgpem;
@ -34,4 +33,3 @@ ResourcePolicyManager::~ResourcePolicyManager()
{
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 ();
// assume they are ordered by priority.
bool inserted = false;

View File

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

View File

@ -26,7 +26,8 @@ using namespace std;
using namespace sgpem;
ResourcePolicyPriorityInheritance::~ResourcePolicyPriorityInheritance ()
{}
{
}
void
ResourcePolicyPriorityInheritance::configure ()
@ -91,7 +92,9 @@ ResourcePolicyPriorityInheritance::enforce(Environment& /*environment*/, Environ
Glib::ustring
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

View File

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

View File

@ -25,15 +25,18 @@
using namespace sgpem;
Schedulable::~Schedulable ()
{}
{
}
unsigned int Schedulable::get_remaining_time() const
unsigned int
Schedulable::get_remaining_time () const
{
assert (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 ();
}

View File

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

View File

@ -18,7 +18,6 @@
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
/*
// DISCLAIMER FOR THE RAMPANT CODER: \\
// ----------------------------------------------------\\
@ -36,8 +35,8 @@
#include <sgpemv2/scheduler.hh>
// Do not include full template definition in the header file
#include <sgpemv2/templates/singleton.tcc>
#include <sgpemv2/templates/sequences.tcc>
#include <sgpemv2/templates/singleton.tcc>
#include <glibmm/thread.h>
@ -84,8 +83,7 @@ is_running(const Thread* running_thread)
// Collects all threads of an environment into a single vector
void
collect_threads(const std::vector<Process*>& procs,
Threads& collected_threads)
collect_threads (const std::vector<Process *> &procs, Threads &collected_threads)
{
collected_threads.clear ();
for (Iseq<vector<Process *>::const_iterator> seq = iseq (procs); seq; ++seq)
@ -97,8 +95,7 @@ collect_threads(const std::vector<Process*>& procs,
void
prepare_ready_queue(ConcreteEnvironment& snapshot,
const Threads& all_threads)
prepare_ready_queue (ConcreteEnvironment &snapshot, const Threads &all_threads)
{
ReadyQueue &queue = snapshot.get_sorted_queue ();
assert (queue.size () == 0);
@ -110,11 +107,9 @@ prepare_ready_queue(ConcreteEnvironment& snapshot,
}
// When a thread terminates, unconditionally kill all its requests
void
terminate_all_requests_of(DynamicThread& thread,
ConcreteEnvironment& environment)
terminate_all_requests_of (DynamicThread &thread, ConcreteEnvironment &environment)
{
Requests &reqs = thread.get_dynamic_requests ();
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 ();
SubRequestQueue &queue = environment.get_request_queue (rkey);
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
void
update_allocated_requests(DynamicThread& running_thread,
ConcreteEnvironment& environment)
update_allocated_requests (DynamicThread &running_thread, ConcreteEnvironment &environment)
{
// Go for all dynamic requests of this thread
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 ();
SubRequestQueue &queue = environment.get_request_queue (rkey);
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)
@ -179,8 +175,7 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
SubRequests &subreqs = (*req_it)->get_dynamic_subrequests ();
// Add to the queue only requests passing from future to another state:
if(cur_req.get_state() == Request::state_future &&
cur_req.get_instant() == running_thread.get_elapsed_time())
if (cur_req.get_state () == Request::state_future && cur_req.get_instant () == running_thread.get_elapsed_time ())
{
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;
for (Iseq<SubRequests::const_iterator> it_dsrs = iseq (const_subreqs); it_dsrs; ++it_dsrs)
{
DynamicSubRequest &subreq = **it_dsrs;
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 position_in_queue = 0;
for(Iseq<SubRequestQueue::const_iterator> queue_it = iseq(queue);
queue_it; queue_it++, position_in_queue++)
for (Iseq<SubRequestQueue::const_iterator> queue_it = iseq (queue); queue_it; queue_it++, position_in_queue++)
{
DynamicSubRequest &sr = (DynamicSubRequest &) **queue_it;
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
// back into ready state if need arises.
void
look_for_mutant_request_states(ConcreteEnvironment& environment,
unsigned int& alive_threads)
look_for_mutant_request_states (ConcreteEnvironment &environment, unsigned int &alive_threads)
{
// Now listening to: Testament's ``First Strike Is Still Deadly''
// 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,
// the corresponding thread should be blocked, and vice-versa
DynamicThread &thread = req.get_thread ();
if(prev_req_state == Request::state_allocable &&
req.get_state() == Request::state_unallocable)
if (prev_req_state == Request::state_allocable && req.get_state () == Request::state_unallocable)
{
if (thread.get_state () != Schedulable::state_blocked)
alive_threads--;
thread.set_state (Schedulable::state_blocked);
}
else if(prev_req_state == Request::state_unallocable &&
req.get_state() == Request::state_allocable)
else if (prev_req_state == Request::state_unallocable && req.get_state () == Request::state_allocable)
{
if (thread.get_state () == Schedulable::state_blocked)
alive_threads++;
@ -349,18 +339,16 @@ look_for_mutant_request_states(ConcreteEnvironment& environment,
} //~ for(over subrequests in the queue)
} //~ for(over resources)
}
// ---------------------------------------------------------
//private constructor.
Scheduler::Scheduler()
: _ready_queue(NULL), _policy(NULL), _step_mutex()
{}
Scheduler::Scheduler () : _ready_queue (NULL), _policy (NULL), _step_mutex ()
{
}
ReadyQueue *
@ -377,7 +365,6 @@ Scheduler::get_policy()
}
bool
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)
{
Process &parent = current.get_process ();
if ((long) parent.get_arrival_time() <= current_instant &&
parent.get_elapsed_time() == current.get_arrival_time())
if ((long) parent.get_arrival_time () <= current_instant && parent.get_elapsed_time () == current.get_arrival_time ())
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
// 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
// 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
// terminates), then we remove it from the built ReadyQueue and
// 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
// 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);
}
}
}
catch (const CPUPolicyException &e)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,6 @@
namespace sgpem
{
/// \brief A link to a loaded DSO object
///
/// 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
{
public:
/// \brief Constructor taking an identifier.
///
/// Constructor taking an identifier.
@ -111,10 +109,8 @@ namespace sgpem
f_ustring get_author_ptr;
f_float get_version_ptr;
}
; //~ class Module
}; //~ class Module
} //~ namespace sgpem
} // namespace sgpem
#endif

View File

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

View File

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

View File

@ -24,22 +24,22 @@
#include <sgpemv2/sgpemv2-visibility.hh>
#include <map>
#include <string>
#include <stdexcept>
#include <string>
#include "glibmm/ustring.h"
namespace sgpem
{
class SG_DLLEXPORT PolicyParametersException : public std::runtime_error
{
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.
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
{
public:
// -------------------------------------------------------------------------
/** \brief This class represents a sigle parameter of type \c T
@ -61,7 +60,6 @@ namespace sgpem
class SG_DLLEXPORT Parameter
{
public:
/** \brief Constructs the parameter
\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)
@ -71,9 +69,8 @@ namespace sgpem
\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).
*/
Parameter(Glib::ustring name, const T& value,
const T& lower_bound, const T& upper_bound,
const bool& required, const T& default_value = 0);
Parameter (Glib::ustring name, const T &value, const T &lower_bound, const T &upper_bound, const bool &required,
const T &default_value = 0);
/** \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 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.
@ -146,7 +144,8 @@ namespace sgpem
\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).
*/
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.
@ -245,13 +244,12 @@ namespace sgpem
Glib::ustring get_string (Glib::ustring name) const;
private:
std::map<Glib::ustring, Parameter<int>> int_map;
std::map<Glib::ustring, Parameter<float>> float_map;
std::map<Glib::ustring, Parameter<Glib::ustring>> string_map;
};
}//~ namespace sgpem
} // namespace sgpem
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,6 @@ namespace sgpem
class SG_DLLEXPORT Schedulable
{
public:
/// \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
@ -228,6 +227,6 @@ namespace sgpem
/// \param translator the visitor used to serialize this entity.
virtual void serialize (SerializeVisitor &translator) const = 0;
};
}
} // namespace sgpem
#endif

View File

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

View File

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

View File

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

View File

@ -21,9 +21,9 @@
#ifndef SERIALIZER_HH
#define SERIALIZER_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/serializer_error.hh>
#include <sgpemv2/sgpemv2-visibility.hh>
#include <glibmm/ustring.h>
@ -41,10 +41,10 @@ namespace sgpem
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_description () = 0;
protected:
private:
};
}
} // namespace sgpem
#endif

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