// src/simulation_controller.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 2 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, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef SIMULATION_CONTROLLER_HH
#define SIMULATION_CONTROLLER_HH 1

#include "config.h"

#include <sgpemv2/simulation_observer.hh>

#include <gtkmm/toolbutton.h>
#include <gtkmm/menuitem.h>
#include <libglademm/xml.h>

namespace sgpem
{

  class SimulationController;


  /** \brief Helper class for controlling the simulation via callback
   */
  class SimulationController : public SimulationObserver
  {
  public:
    SimulationController(Simulation& simulation, Glib::RefPtr<Gnome::Glade::Xml> main_window);
    virtual ~SimulationController();
    
    void update(const Simulation& simulation);
    
  private:
    void on_simulation_run();
    void on_simulation_pause();
    void on_simulation_stop();

    bool run_simulation_adaptor();

    Simulation&      _sim;
    bool             _break_requested;

    Gtk::ToolButton* _toolbt_start;
    Gtk::ToolButton* _toolbt_pause;
    Gtk::ToolButton* _toolbt_stop;

    Gtk::MenuItem*  _menuit_start;
    Gtk::MenuItem*  _menuit_pause;
    Gtk::MenuItem*  _menuit_stop;
  };

} //~ namespace sgpem

#endif //~ SIMULATION_CONTROLLER_HH

