/*
 * ASTL - the Automaton Standard Template Library.
 * C++ generic components for Finite State Machine handling.
 * Copyright (C) 2000 Vincent Le Maout (vlemaout@lexiquest.fr).
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef ASTL_STATS_ALGORITHM
#define ASTL_STATS_ALGORITHM

#include <ccopy.h>

struct DFA_stats
{
  typedef unsigned long State;
  unsigned long _state_count, _trans_count, _final_states;
  State null_state;

  DFA_stats()
    : _state_count(0), _trans_count(0), _final_states(0), null_state(0)
  { }

  State new_state() {
    return ++_state_count;
  }

  template <class Alphabet>
  void set_trans(State from, const Alphabet &, State to) {
    ++_trans_count;
  }

  struct bool_reference
  {
    State q;
    DFA_stats &dfa;

    bool_reference(State p, DFA_stats &a)
      : q(p), dfa(a)
    { }

    bool_reference& operator= (bool b) {
      if (b == true)
	++dfa._final_states;
      return *this;
    }
  };

  bool_reference final(State q) {
    return bool_reference(q, *this);
  }

  unsigned long state_count() const {
    return _state_count;
  }

  unsigned long trans_count() const {
    return _trans_count;
  }

  unsigned long final_count() const {
    return _final_states;
  }

};

#endif // ASTL_STATS_ALGORITHM








