// src/schedulable_statistics_widget.hh - Copyright 2005, 2006, University
//               of Padova, dept. of Pure and Applied
//               Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/.


#ifndef SCHEDULABLE_STATISTICS_WIDGET_HH
#define SCHEDULABLE_STATISTICS_WIDGET_HH 1

#include "cairo_widget.hh"
#include "sgpemv2/history_observer.hh"

#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>

namespace sgpem
{
  /// \brief A widget showing a table with simulation statistics
  /// 
  /// This class represents a widget which displays a table
  /// containing all sorts of simulation statistics.
  /// Values are either strings, booleans or integers.
  /// The widget may be customized using setter and getters for
  /// specific columns.
  class TabularSchedulableStatisticsWidget : public HistoryObserver, public Gtk::TreeView
  {	
  public:
    /// \brief Standard constructor.
    ///
    TabularSchedulableStatisticsWidget();

    /// \brief Standard virtual destructor.
    ///
    virtual ~TabularSchedulableStatisticsWidget();

    /// \brief Updates the table with values adherent with the changed history.
    /// \param changed_history the history which notified a change.
    void update(const History& changed_history);

    /// \brief Sets the column visibile.
    ///
    void set_show_runs(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_runs() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_perc(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_perc() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_inactive(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_inactive() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_turn_around(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_turn_around() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_response(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_response() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_efficiency(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_efficiency() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_resource_usage(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_resource_usage() const;

    /// \brief Sets the column visibile.
    ///
    void set_show_resource_block(bool);

    /// \brief Gets whether the column is visibile.
    ///
    bool get_show_resource_block() const;

  protected:
    /// \brief Main helper method which updates the columns of the widget
    /// on the basis of the underlying model.
    void update_columns();
	
    bool _show_runs;
    bool _show_perc;
    bool _show_inactive;
    bool _show_turn;
    bool _show_resp;
    bool _show_effic;
    bool _show_ris_usage;
    bool _show_ris_block;

    // treeview stuffs
    Glib::RefPtr<Gtk::TreeStore> _model;
    Gtk::TreeModelColumnRecord _columns;

    // all columns
    Gtk::TreeModelColumn<Glib::ustring>  _col_name;
    Gtk::TreeModelColumn<int>            _col_runs;
    Gtk::TreeModelColumn<Glib::ustring>  _col_perc;
    Gtk::TreeModelColumn<int>            _col_inactive;
    Gtk::TreeModelColumn<int>            _col_turn;
    Gtk::TreeModelColumn<Glib::ustring>  _col_resp;
    Gtk::TreeModelColumn<Glib::ustring>  _col_effic;
    Gtk::TreeModelColumn<int>            _col_ris_usage;
    Gtk::TreeModelColumn<int>            _col_ris_block;

  }
  ;

} //~ namespace sgpem


#endif
