/*
 * 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_CLASS_SIGMA_STAR_CURSOR
#define ASTL_CLASS_SIGMA_STAR_CURSOR

#include <cursor.h>
#include <tag.h>

/*
template <unsigned int alphabet_size = 256>
class sigma_star_cursor : public forward_cursor_concept
{
protected:
  static int tag;
  unsigned int l;

public:
  typedef sigma_star_cursor self;
  typedef unsigned int      State;
  typedef int               Tag;
  typedef int               Alphabet; 

  sigma_star_cursor()
    : l(0) 
    { }

  bool operator== (const self &x) const {
    return l == x.l;
  }

  State src() const {
    return 1;
  }

  State aim() const {
    return 1;
  }    

  const Tag& src_tag() const {
    return tag;
  }
  
  const Tag& aim_tag() const {
    return tag;
  }    
  
  bool src_final() const {
    return true;
  }
  
  bool aim_final() const {
    return true;
  }

  bool sink() const {
    return l == alphabet_size;
  }

  void forward() 
  { }
  
  bool forward(int a) {
    return true;
  }
  
  int letter() const {
    return l;
  }
  
  bool first_transition() {
    l = 0;
    return true;
  }
  
  bool next_transition() {
    return ++l < alphabet_size;
  }

  bool find(int a) {
    l = a;
    return true;
  }

  bool exists(int a) const {
    return true;
  }
};
    
template <unsigned int alphabet_size>
int sigma_star_cursor<alphabet_size>::tag = 0;
*/

template <class Sigma = plain>
class sigma_star_cursor : public forward_cursor_concept
{
protected:
  typename Sigma::iterator i;

public:
  typedef sigma_star_cursor         self;
  typedef char                      State;
  typedef empty_tag                 Tag;
  typedef typename Sigma::char_type Alphabet; 

  bool operator== (const self &x) const {
    return i == x.i;
  }

  self& operator= (State) {
    return *this;
  }

  State src() const {
    return (char) 1;
  }

  State aim() const {
    return (char) 1;
  }    

  const Tag& src_tag() const {
    return empty_tag();
  }
  
  const Tag& aim_tag() const {
    return empty_tag();
  }    
  
  bool src_final() const {
    return true;
  }
  
  bool aim_final() const {
    return true;
  }

  bool sink() const {
    return false;
  }

  void forward() 
  { }
  
  bool forward(const Alphabet&) {
    return true;
  }
  
  Alphabet letter() const {
    return *i;
  }
  
  bool first_transition() {
    i = Sigma::begin();
    return true;
  }
  
  bool next_transition() {
    return ++i != Sigma::end();
  }

  bool find(const Alphabet &a) {
    i = find(Sigma::begin(), Sigma::end(), a);
    return true;
  }

  bool exists(const Alphabet &) const {
    return true;
  }
};
  

// Helper function:
// sigma_star_cursor<> sigma_starc() {
//  return sigma_star_cursor<>();
// }

template <class Sigma>
sigma_star_cursor<Sigma> sigma_starc() {
  return sigma_star_cursor<Sigma>();
}
#endif // ASTL_CLASS_SIGMA_STAR_CURSOR
    



