Few more things
[apertium.git] / lttoolbox / lttoolbox / MatchState.H
blobd4fd6188982193c33ba0266cda93bf965d7d05d6
1 /*
2  * Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _MATCHSTATE_
20 #define _MATCHSTATE_
22 #include <map>
23 #include <set>
24 #include <string>
25 #include <vector>
27 #include <lttoolbox/MatchNode.H>
29 using namespace std;
31 /**
32  * Class to represent the current state of transducer processing 
33  */
34 class MatchState
36 private:
37   static int const BUF_LIMIT;
38   MatchNode **state;
39   int first;
40   int last;
42   /**
43    * The current state of transducer processing
44    */
45 //  slist<MatchNode *> state;
47   /**
48    * Copy function
49    * @param s the state to be copied
50    */
51   void copy(MatchState const &s);
53   /**
54    * Destroy function
55    */
56   void destroy();
58   
59   void applySymbol(MatchNode *pnode, int const symbol);
60 public:
61   /**
62    * Constructor
63    */
64   MatchState();
66   /**
67    * Destructor
68    */
69   ~MatchState();
71   /**
72    * Copy constructor
73    * @param s the state to be copied
74    */
75   MatchState(MatchState const &s);
77   /**
78    * Assignment operator
79    * @param s the state to be assigned
80    * @return the object that results from the assignation
81    */
82   MatchState & operator =(MatchState const &s);
83   
84   /**
85    * Number of alive transductions
86    * @return the size
87    */
88   int size() const;
90   /**
91    * step = apply + epsilonClosure
92    * @param input the input symbol
93    */
94   void step(int const input);
95   
96   /**
97    * step = apply + epsilonClosure
98    * @param input the input symbol
99    * @param alt the alternative input symbol
100    */
101   void step(int const input, int const alt);
103   /**
104    * Init the state with the initial node and empty output
105    * @param initial the initial node of the transducer
106    */
107   void init(MatchNode *initial);
109   int classifyFinals(map<MatchNode *, int> const &final_class) const;
111   void debug();
112   
113   void clear();
114   
117 #endif