Fix some more warnings, install headers

This commit is contained in:
Matteo Settenvini 2018-09-25 10:17:29 +02:00
parent 616aef27a8
commit c1ac6f279b
12 changed files with 377 additions and 288 deletions

72
.clang-format Normal file
View File

@ -0,0 +1,72 @@
---
AccessModifierOffset: 0
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine : false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: TopLevelDefinitions
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: true
BreakAfterJavaFieldAnnotations: true
BreakBeforeBraces: Allman
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: "<pre>.*?</pre>"
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
PointerAlignment: Right
ForEachMacros: [ 'BOOST_FOREACH' ]
IncludeCategories:
- Regex: '^<(gtest|gmock)'
Priority: 8
- Regex: '^(<boost/)'
Priority: 7
- Regex: '^<'
Priority: 9
- Regex: '^<sgpemv2/'
Priority: 2
- Regex: '^"'
Priority: 1
IncludeIsMainRegex: "(_test)?$"
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Double
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 8
PenaltyBreakFirstLessLess: 8
PenaltyBreakString: 8
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 16
PointerAlignment: Right
ReflowComments: false
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp17
UseTab: Never

View File

@ -163,6 +163,7 @@ set(localedir ${CMAKE_INSTALL_FULL_LOCALEDIR})
set(uidir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/ui) set(uidir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/ui)
set(policiesdir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/policies) set(policiesdir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/policies)
set(plugindir ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/plugins) set(plugindir ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/plugins)
set(examplesdir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/examples)
configure_file(src/backend/sgpemv2/config.h.in configure_file(src/backend/sgpemv2/config.h.in
src/backend/sgpemv2/config.h src/backend/sgpemv2/config.h
@ -176,7 +177,6 @@ set_target_properties(sgpemv2-backend PROPERTIES
target_include_directories(sgpemv2-backend target_include_directories(sgpemv2-backend
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/backend> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/backend>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/backend> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/backend>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/backend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/backend
${Intl_INCLUDE_DIRS}) ${Intl_INCLUDE_DIRS})
target_link_libraries(sgpemv2-backend target_link_libraries(sgpemv2-backend
@ -609,6 +609,16 @@ target_sources(sgpemv2
# ------------------------------------------- # -------------------------------------------
install(TARGETS sgpemv2 sgpemv2-backend
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/sgpemv2
${CMAKE_CURRENT_BINARY_DIR}/src/backend/sgpemv2
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN "*.in" EXCLUDE)
install(FILES data/logo.png install(FILES data/logo.png
ui/add-process-dialog.ui ui/add-process-dialog.ui
ui/add-request-dialog.ui ui/add-request-dialog.ui

View File

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

View File

@ -163,8 +163,8 @@ CairoWidget::on_draw (const Cairo::RefPtr<Cairo::Context>& ctx)
if (!_ref_gdk_window) return true; if (!_ref_gdk_window) return true;
// save actual size // save actual size
size_t actual_w = get_width(); auto actual_w = get_width();
size_t actual_h = get_height(); auto actual_h = get_height();
// the widget must be redrawn if // the widget must be redrawn if
// - there's an explicit request(_need_redraw) // - there's an explicit request(_need_redraw)
@ -183,12 +183,12 @@ CairoWidget::on_draw (const Cairo::RefPtr<Cairo::Context>& ctx)
// allocate only if growing, keep if shrinking. // allocate only if growing, keep if shrinking.
// Taking a bigger pixmap saves operations when // Taking a bigger pixmap saves operations when
// many window resizing occours (i.e. mouse resizing). // many window resizing occours (i.e. mouse resizing).
if(_client_w>_pixbuf_w || _client_h>_pixbuf_h) if(_client_w > _pixbuf_w || _client_h > _pixbuf_h)
{ {
// previdence in the code: // previdence in the code:
// allocate more than actually needed // allocate more than actually needed
_pixbuf_w = (size_t) (_client_w*1.2); _pixbuf_w = static_cast<int>(_client_w * 1.2);
_pixbuf_h = (size_t) (_client_h*1.2); _pixbuf_h = static_cast<int>(_client_h * 1.2);
// allocate the pixmap // allocate the pixmap
_buf = Gdk::Pixbuf::create (_ref_gdk_window, 0, 0, _pixbuf_w, _pixbuf_h); _buf = Gdk::Pixbuf::create (_ref_gdk_window, 0, 0, _pixbuf_w, _pixbuf_h);

View File

@ -206,7 +206,7 @@ namespace sgpem
* The user can implement this method to give default dimensions. * The user can implement this method to give default dimensions.
* It isn't necessary because scaling (and resizing) take care of calc_drawing_size() results. * It isn't necessary because scaling (and resizing) take care of calc_drawing_size() results.
*/ */
virtual void calc_widget_size(size_t& width, size_t& height); virtual void calc_widget_size(int& width, int& height);
/** /**
* \brief Calculate scaling factors to apply during widget's redrawing. * \brief Calculate scaling factors to apply during widget's redrawing.
@ -230,22 +230,22 @@ namespace sgpem
/** /**
* \brief Client area width of widget. * \brief Client area width of widget.
*/ */
size_t _client_w; int _client_w;
/** /**
* \brief Client area height of widget. * \brief Client area height of widget.
*/ */
size_t _client_h; int _client_h;
/** /**
* \brief Client area width of pixmap. * \brief Client area width of pixmap.
*/ */
size_t _pixbuf_w; int _pixbuf_w;
/** /**
* \brief Client area width of pixmap. * \brief Client area width of pixmap.
*/ */
size_t _pixbuf_h; int _pixbuf_h;
/** /**
* \brief Cairo x scale factor. * \brief Cairo x scale factor.

View File

@ -21,6 +21,7 @@
#ifndef GRAPHICAL_PREFERENCES_EDITOR_HH #ifndef GRAPHICAL_PREFERENCES_EDITOR_HH
#define GRAPHICAL_PREFERENCES_EDITOR_HH 1 #define GRAPHICAL_PREFERENCES_EDITOR_HH 1
#include "sgpemv2/config.h"
#include "sgpemv2/global_preferences.hh" #include "sgpemv2/global_preferences.hh"
#include <gtkmm/builder.h> #include <gtkmm/builder.h>
@ -34,61 +35,61 @@
namespace sgpem namespace sgpem
{ {
class PreferencesEditor class PreferencesEditor
{ {
public: public:
explicit PreferencesEditor(const std::string& uifile = UIDIR "/configure-dialog.ui"); explicit PreferencesEditor(const std::string& uifile = UIDIR "/configure-dialog.ui");
void void
on_close(); on_close();
void void
on_add_plugins_dir(); on_add_plugins_dir();
void void
on_remove_plugins_dir(); on_remove_plugins_dir();
void void
on_add_policies_dir(); on_add_policies_dir();
void void
on_remove_policies_dir(); on_remove_policies_dir();
void void
on_set_speed(); on_set_speed();
~PreferencesEditor(); ~PreferencesEditor();
private: private:
void void
update_policies(); update_policies();
void void
update_plugins(); update_plugins();
Glib::RefPtr<Gtk::Builder> _refXml; Glib::RefPtr<Gtk::Builder> _refXml;
Gtk::Dialog* preferences_dialog; Gtk::Dialog* preferences_dialog;
Gtk::TreeView* plugins_dirs_treeview; Gtk::TreeView* plugins_dirs_treeview;
Glib::RefPtr<Gtk::ListStore> plugins_dirs_model; Glib::RefPtr<Gtk::ListStore> plugins_dirs_model;
Gtk::TreeView* plugins_treeview; Gtk::TreeView* plugins_treeview;
Glib::RefPtr<Gtk::ListStore> plugins_model; Glib::RefPtr<Gtk::ListStore> plugins_model;
Gtk::TreeView* policies_dirs_treeview; Gtk::TreeView* policies_dirs_treeview;
Glib::RefPtr<Gtk::ListStore> policies_dirs_model; Glib::RefPtr<Gtk::ListStore> policies_dirs_model;
Gtk::TreeView* policies_treeview; Gtk::TreeView* policies_treeview;
Glib::RefPtr<Gtk::ListStore> policies_model; Glib::RefPtr<Gtk::ListStore> policies_model;
Gtk::SpinButton* speed_spin; Gtk::SpinButton* speed_spin;
}; };
} // ~ namespace } // ~ namespace

View File

@ -76,7 +76,7 @@ using namespace sgpem;
void void
GuiBuilder::on_edit_preferences_activate() GuiBuilder::on_edit_preferences_activate()
{ {
PreferencesEditor(); // Will run the dialog inside the constructor. PreferencesEditor(); // Will run the dialog inside the constructor.
} }
void void
@ -140,11 +140,11 @@ void
GuiBuilder::on_file_new_activate() GuiBuilder::on_file_new_activate()
{ {
Simulation& sim = Simulation::get_instance(); Simulation& sim = Simulation::get_instance();
History& history = sim.get_history(); History& history = sim.get_history();
ask_save(); ask_save();
sim.stop(); sim.stop();
history.clear(); history.clear();
set_filename(); set_filename();
} }
@ -221,7 +221,7 @@ GuiBuilder::open_file(const std::string& basedir)
} // end - if(result==Gtk::RESPONSE_OK) } // end - if(result==Gtk::RESPONSE_OK)
} }
catch (std::out_of_range e) catch (std::out_of_range& e)
{ {
Gtk::MessageDialog error(get_initial_window(), Gtk::MessageDialog error(get_initial_window(),
_("<b>No serializer available.</b>\nThere's no " _("<b>No serializer available.</b>\nThere's no "
@ -230,7 +230,7 @@ GuiBuilder::open_file(const std::string& basedir)
error.run(); error.run();
msg = _("ERROR: No registered serializer available"); msg = _("ERROR: No registered serializer available");
} }
catch (SerializerError e) catch (SerializerError& e)
{ {
Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
error.run(); error.run();
@ -272,7 +272,7 @@ GuiBuilder::on_file_save_activate()
serializer.save_snapshot(_filename, history); serializer.save_snapshot(_filename, history);
msg = _("File: ") + _filename + _(" saved."); msg = _("File: ") + _filename + _(" saved.");
} }
catch (std::out_of_range e) catch (std::out_of_range& e)
{ {
Gtk::MessageDialog error(get_initial_window(), Gtk::MessageDialog error(get_initial_window(),
_("<b>No serializer available.</b>\nThere's no registered serializer. Please check the loaded plugins."), _("<b>No serializer available.</b>\nThere's no registered serializer. Please check the loaded plugins."),
@ -280,7 +280,7 @@ GuiBuilder::on_file_save_activate()
error.run(); error.run();
msg = _("ERROR: No registered serializer available"); msg = _("ERROR: No registered serializer available");
} }
catch (SerializerError e) catch (SerializerError& e)
{ {
Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
error.run(); error.run();
@ -349,7 +349,7 @@ GuiBuilder::on_file_saveas_activate()
} // end - if(result==Gtk::RESPONSE_OK) } // end - if(result==Gtk::RESPONSE_OK)
} }
catch (std::out_of_range e) catch (std::out_of_range& e)
{ {
Gtk::MessageDialog error(get_initial_window(), Gtk::MessageDialog error(get_initial_window(),
_("<b>No serializer available.</b>\nThere's no registered serializer. Please check the loaded plugins."), _("<b>No serializer available.</b>\nThere's no registered serializer. Please check the loaded plugins."),
@ -357,7 +357,7 @@ GuiBuilder::on_file_saveas_activate()
error.run(); error.run();
msg = _("ERROR: No registered serializer available"); msg = _("ERROR: No registered serializer available");
} }
catch (SerializerError e) catch (SerializerError& e)
{ {
Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); Gtk::MessageDialog error(get_initial_window(), e.what(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
error.run(); error.run();
@ -637,7 +637,7 @@ GuiBuilder::GuiBuilder(const std::string& uifile)
file_quit->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::ask_save)); file_quit->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::ask_save));
file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit)); file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit));
// preferences dialog // preferences dialog
RefPtr<Action>::cast_dynamic (_refXml->get_object("Action.Edit.Preferences")) RefPtr<Action>::cast_dynamic (_refXml->get_object("Action.Edit.Preferences"))
->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_edit_preferences_activate)); ->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_edit_preferences_activate));

View File

@ -26,6 +26,7 @@
#include "statistics_container_window.hh" #include "statistics_container_window.hh"
#include "simulation_widget.hh" #include "simulation_widget.hh"
#include "sgpemv2/config.h"
#include "sgpemv2/cpu_policy.hh" #include "sgpemv2/cpu_policy.hh"
#include "sgpemv2/resource_policy.hh" #include "sgpemv2/resource_policy.hh"
@ -63,7 +64,7 @@ namespace sgpem
void on_view_show_threads_activate(); void on_view_show_threads_activate();
void on_view_show_holt_graph_activate(); void on_view_show_holt_graph_activate();
void on_view_show_statistics_activate(); void on_view_show_statistics_activate();
void on_configure_cpu_policy(); void on_configure_cpu_policy();
void on_configure_resource_policy(); void on_configure_resource_policy();

View File

@ -107,7 +107,7 @@ parse_options(int argc, char** argv)
{ {
prefs.load_configrc(); prefs.load_configrc();
} }
catch (std::exception e) catch (std::exception& e)
{ {
std::cout << std::endl std::cout << std::endl
<< _("Error while loading preferences") << std::endl; << _("Error while loading preferences") << std::endl;
@ -163,7 +163,7 @@ parse_options(int argc, char** argv)
} }
} // ~ try } // ~ try
catch (Glib::OptionError e) catch (Glib::OptionError& e)
{ {
std::cout << Glib::ustring::compose (_("Bad invocation: %1\nUse the `-?' " std::cout << Glib::ustring::compose (_("Bad invocation: %1\nUse the `-?' "
"or `--help' option to see the help."), "or `--help' option to see the help."),

View File

@ -20,6 +20,8 @@
#include "resources_widget.hh" #include "resources_widget.hh"
#include "sgpemv2/config.h"
#include <sgpemv2/templates/sequences.tcc> #include <sgpemv2/templates/sequences.tcc>
#include <sgpemv2/history.hh> #include <sgpemv2/history.hh>
@ -118,31 +120,31 @@ ResourcesWidget::on_button_press_event(GdkEventButton* event)
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create(); RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
action_group->add( Gtk::Action::create("AddResource", "Add Resource"), action_group->add( Gtk::Action::create("AddResource", "Add Resource"),
sigc::mem_fun(*this, &ResourcesWidget::_on_add_resource) ); sigc::mem_fun(*this, &ResourcesWidget::_on_add_resource) );
action_group->add( Gtk::Action::create("EditResource", "Edit Resource"), action_group->add( Gtk::Action::create("EditResource", "Edit Resource"),
sigc::mem_fun(*this, &ResourcesWidget::_on_edit_resource) ); sigc::mem_fun(*this, &ResourcesWidget::_on_edit_resource) );
action_group->add( Gtk::Action::create("RemoveResource", "Remove Resource"), action_group->add( Gtk::Action::create("RemoveResource", "Remove Resource"),
sigc::mem_fun(*this, &ResourcesWidget::_on_remove_resource) ); sigc::mem_fun(*this, &ResourcesWidget::_on_remove_resource) );
RefPtr<UIManager> UIManager = Gtk::UIManager::create(); RefPtr<UIManager> UIManager = Gtk::UIManager::create();
UIManager->insert_action_group(action_group); UIManager->insert_action_group(action_group);
Glib::ustring ui_info = Glib::ustring ui_info =
"<ui>" "<ui>"
" <popup name='PopupMenu'>" " <popup name='PopupMenu'>"
" <menuitem action='AddResource'/>"; " <menuitem action='AddResource'/>";
if(get_selected_resource() != nullptr) if(get_selected_resource() != nullptr)
ui_info += ui_info +=
" <separator/>" " <separator/>"
" <menuitem action='EditResource'/>" " <menuitem action='EditResource'/>"
" <separator/>" " <separator/>"
" <menuitem action='RemoveResource'/>"; " <menuitem action='RemoveResource'/>";
ui_info += ui_info +=
" </popup>" " </popup>"
"</ui>"; "</ui>";
UIManager->add_ui_from_string(ui_info); UIManager->add_ui_from_string(ui_info);
Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu")); Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu"));
@ -216,8 +218,8 @@ ResourcesWidget::add_edit_resource(bool adding)
if(adding) if(adding)
{ {
Simulation::get_instance().get_history().add_resource(name_entry->get_text(), Simulation::get_instance().get_history().add_resource(name_entry->get_text(),
false, false,
places_spin->get_value_as_int()); places_spin->get_value_as_int());
} }
else else
{ {
@ -258,8 +260,8 @@ ResourcesWidget::_on_remove_resource()
for(vector<Request*>::iterator rit = requests.begin(); rit != requests.end(); ++rit) for(vector<Request*>::iterator rit = requests.begin(); rit != requests.end(); ++rit)
{ {
if((*rit)->get_subrequests().empty()) if((*rit)->get_subrequests().empty())
to_delete.push(*rit); to_delete.push(*rit);
} }
} }
} }
@ -299,10 +301,10 @@ ResourcesWidget::_on_cell_name_data(Gtk::CellRenderer* cr,
oss << "<b><span foreground=\"" oss << "<b><span foreground=\""
<< GlobalPreferences::get_instance().get_request_color(sr.get_state()) << GlobalPreferences::get_instance().get_request_color(sr.get_state())
<< "\"> " << sr.get_request().get_thread().get_name() << "\"> " << sr.get_request().get_thread().get_name()
<< "</span></b>" << " (" << "</span></b>" << " ("
<< (sr.get_length() - sr.get_remaining_time()) << (sr.get_length() - sr.get_remaining_time())
<< "/" << sr.get_length() << ")"; << "/" << sr.get_length() << ")";
} }
oss << "</span>"; oss << "</span>";

View File

@ -20,6 +20,7 @@
#include "gettext.h" #include "gettext.h"
#include "sgpemv2/config.h"
#include "schedulables_tree_widget.hh" #include "schedulables_tree_widget.hh"
#include <sgpemv2/history.hh> #include <sgpemv2/history.hh>
#include <sgpemv2/simulation.hh> #include <sgpemv2/simulation.hh>
@ -175,16 +176,16 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create(); RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
action_group->add( Gtk::Action::create("AddProcess", _("Add Process")), action_group->add( Gtk::Action::create("AddProcess", _("Add Process")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) );
action_group->add( Gtk::Action::create("AddThread", _("Add Thread")), action_group->add( Gtk::Action::create("AddThread", _("Add Thread")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_thread) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_thread) );
action_group->add( Gtk::Action::create("AddRequest", _("Add Request")), action_group->add( Gtk::Action::create("AddRequest", _("Add Request")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_request) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_request) );
action_group->add( Gtk::Action::create("EditProcess", _("Edit Process")), action_group->add( Gtk::Action::create("EditProcess", _("Edit Process")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_process) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_process) );
action_group->add( Gtk::Action::create("EditThread", _("Edit Thread")), action_group->add( Gtk::Action::create("EditThread", _("Edit Thread")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_thread) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_thread) );
@ -193,13 +194,13 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_request) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_request) );
action_group->add( Gtk::Action::create("RemoveProcess", _("Remove Process")), action_group->add( Gtk::Action::create("RemoveProcess", _("Remove Process")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_process) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_process) );
action_group->add( Gtk::Action::create("RemoveThread", _("Remove Thread")), action_group->add( Gtk::Action::create("RemoveThread", _("Remove Thread")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_thread) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_thread) );
action_group->add( Gtk::Action::create("RemoveRequest", _("Remove Request")), action_group->add( Gtk::Action::create("RemoveRequest", _("Remove Request")),
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_request) ); sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_request) );
// action_group->add( Gtk::Action::create("RemoveSubrequest", _("Remove Subrequest")), // action_group->add( Gtk::Action::create("RemoveSubrequest", _("Remove Subrequest")),
// sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_subrequest) ); // sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_subrequest) );
@ -242,14 +243,14 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
adds += "<menuitem action='AddProcess'/>"; adds += "<menuitem action='AddProcess'/>";
Glib::ustring ui_info = Glib::ustring ui_info =
"<ui>" "<ui>"
" <popup name='PopupMenu'>"; " <popup name='PopupMenu'>";
ui_info += adds + separator + edits + ((edits.size() == 0) ? ustring() : separator) + removes; ui_info += adds + separator + edits + ((edits.size() == 0) ? ustring() : separator) + removes;
ui_info += ui_info +=
" </popup>" " </popup>"
"</ui>"; "</ui>";
UIManager->add_ui_from_string(ui_info); UIManager->add_ui_from_string(ui_info);
Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu")); Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu"));
@ -466,18 +467,18 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
assert(p != nullptr); assert(p != nullptr);
Simulation::get_instance().get_history().add_thread(name_entry->get_text(), Simulation::get_instance().get_history().add_thread(name_entry->get_text(),
*p, *p,
cpu_time_spin->get_value_as_int(), cpu_time_spin->get_value_as_int(),
arrival_time_spin->get_value_as_int(), arrival_time_spin->get_value_as_int(),
base_priority_spin->get_value_as_int()); base_priority_spin->get_value_as_int());
} }
else else
{ {
Simulation::get_instance().get_history().edit_thread(*t, Simulation::get_instance().get_history().edit_thread(*t,
name_entry->get_text(), name_entry->get_text(),
cpu_time_spin->get_value_as_int(), cpu_time_spin->get_value_as_int(),
arrival_time_spin->get_value_as_int(), arrival_time_spin->get_value_as_int(),
base_priority_spin->get_value_as_int()); base_priority_spin->get_value_as_int());
} }
@ -532,8 +533,8 @@ SchedulablesTreeWidget::_on_edit_request()
vector<Request*> requests = (*tit)->get_requests(); vector<Request*> requests = (*tit)->get_requests();
for(Iseq<vector<Request*>::iterator> rit = iseq(requests); rit; ++rit) for(Iseq<vector<Request*>::iterator> rit = iseq(requests); rit; ++rit)
{ {
if(*(*rit) == *r) if(*(*rit) == *r)
r = *rit; r = *rit;
} }
} }
} }
@ -671,9 +672,9 @@ SchedulablesTreeWidget::markup_request(Request& r)
oss << " -&gt; <span foreground=\"" oss << " -&gt; <span foreground=\""
<< GlobalPreferences::get_instance().get_request_color(sr.get_state()) << GlobalPreferences::get_instance().get_request_color(sr.get_state())
<< "\"><b>" << res.get_name() << "</b></span> (" << "\"><b>" << res.get_name() << "</b></span> ("
<< (sr.get_length() - sr.get_remaining_time()) << (sr.get_length() - sr.get_remaining_time())
<< "/" << sr.get_length() << ")"; << "/" << sr.get_length() << ")";
} }
oss << "</span>"; oss << "</span>";

View File

@ -26,6 +26,7 @@
#include "gettext.h" #include "gettext.h"
#include "sgpemv2/config.h"
#include "sgpemv2/simulation.hh" #include "sgpemv2/simulation.hh"
#include <gtkmm/window.h> #include <gtkmm/window.h>