/*
 * --- GSMP-COPYRIGHT-NOTE-BEGIN ---
 * 
 * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
 * Please add additional copyright information _after_ the line containing
 * the GSMP-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
 * the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
 * 
 * GSMP: dam/include/Watcher.hh
 * General Sound Manipulation Program is Copyright (C) 2000 - 2004
 *   Valentin Ziegler and René Rebe
 * 
 * This program 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; version 2. A copy of the GNU General
 * Public License can be found in the file LICENSE.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
 * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * 
 * --- GSMP-COPYRIGHT-NOTE-END ---
 */

#ifndef DAM__WATCHER_HH__
#define DAM__WATCHER_HH__

#include "State.hh"

namespace DAM
{

  template <typename STATES, typename REACTOR, typename WL_TRAITS=DefaultLogging_Watcher>
  class AutomatonWatcher : public sigc::trackable
  {
  public:
    typedef typename STATES::state_id state_id;
    typedef typename STATES::notif_id notif_id;
    typedef typename STATES::query_id query_id;

    typedef typename STATES::NotificationData NotificationData;
    typedef typename STATES::QueryData QueryData;
    typedef typename STATES::Master Automaton;

    typedef void (REACTOR::*StateSlot)(Automaton*, state_id);
    typedef void (REACTOR::*NotifSlot)(Automaton*, notif_id, const NotificationData&);
    typedef bool (REACTOR::*QuerySlot)(Automaton*, query_id, const QueryData&);
    typedef void (REACTOR::*TermSlot)(Automaton*);

    state_id CurrentState ();
    Automaton* CurrentAutomaton ();

    AutomatonWatcher (REACTOR* reactor, Automaton* automaton, StateSlot state_slot,
		      NotifSlot notif_slot, QuerySlot query_slot, TermSlot term_slot);
    void SwitchAutomaton (Automaton* automaton);

  protected:
    ObjectLogger <WL_TRAITS, AutomatonWatcher> m_logger;
  private:
    REACTOR* reactor;
    Automaton* automaton;

    StateSlot state_slot;
    NotifSlot notif_slot;
    QuerySlot query_slot;
    TermSlot term_slot;

    sigc::connection conn_state_slot;
    sigc::connection conn_notif_slot;
    sigc::connection conn_query_slot;
    sigc::connection conn_term_slot;
  };


} // end namespace DAM


/* include template implementation */
#define DAM__WATCHER_TMPL__
#include "template/Watcher.tcc"
#undef DAM__WATCHER_TMPL__

#endif // DAM__WATCHER_HH__
