1*1c78a5d6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c78a5d6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c78a5d6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c78a5d6SAndrew Rist  * distributed with this work for additional information
6*1c78a5d6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c78a5d6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c78a5d6SAndrew Rist  * "License"); you may not use this file except in compliance
9*1c78a5d6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1c78a5d6SAndrew Rist  *
11*1c78a5d6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1c78a5d6SAndrew Rist  *
13*1c78a5d6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c78a5d6SAndrew Rist  * software distributed under the License is distributed on an
15*1c78a5d6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c78a5d6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c78a5d6SAndrew Rist  * specific language governing permissions and limitations
18*1c78a5d6SAndrew Rist  * under the License.
19*1c78a5d6SAndrew Rist  *
20*1c78a5d6SAndrew Rist  *************************************************************/
21*1c78a5d6SAndrew Rist 
22*1c78a5d6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef ADC_TKPSTAM2_HXX
25cdf0e10cSrcweir #define ADC_TKPSTAM2_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // USED SERVICES
28cdf0e10cSrcweir 	// BASE CLASSES
29cdf0e10cSrcweir #include <tokens/tkpcont2.hxx>
30cdf0e10cSrcweir 	// COMPONENTS
31cdf0e10cSrcweir #include <tokens/stmstar2.hxx>
32cdf0e10cSrcweir #include <tokens/stmstfi2.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /**	@descr
35cdf0e10cSrcweir 	This state-machine models state transitions from one state to another
36cdf0e10cSrcweir 	per indices of branches. If the indices represent ascii-char-values,
37cdf0e10cSrcweir 	the state-machine can be used for recognising tokens of text.
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 	The state-machine can be a status itself.
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	StateMachin2 needs the array-size of all stati as a guess, how many stati
42cdf0e10cSrcweir 	the state machine will contain, when at work.
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir **/
46cdf0e10cSrcweir class StateMachin2
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	public:
49cdf0e10cSrcweir 		// Types
50cdf0e10cSrcweir 		typedef StmStatu2::Branch	Branch;
51cdf0e10cSrcweir 		typedef StmStatu2 * *		StatusList;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	//# Interface self
54cdf0e10cSrcweir 		// LIFECYCLE
55cdf0e10cSrcweir 						StateMachin2(
56cdf0e10cSrcweir 							intt			in_nStatusSize,
57cdf0e10cSrcweir 							intt			in_nInitial_StatusListSize );	/// The user of the constructor should guess
58cdf0e10cSrcweir 																			///   the approximate number of stati here to
59cdf0e10cSrcweir 																			///	  avoid multiple reallocations.
60cdf0e10cSrcweir 		/// @#AddStatus
61cdf0e10cSrcweir 		intt			AddStatus(  	/// @return the new #Status' ID
62cdf0e10cSrcweir 							DYN StmStatu2 *	let_dpStatus);
63cdf0e10cSrcweir 		/// @#AddToken
64cdf0e10cSrcweir 		void			AddToken(
65cdf0e10cSrcweir 							const char *		in_sToken,
66cdf0e10cSrcweir 							UINT16				in_nTokenId,
67cdf0e10cSrcweir 							const INT16 *		in_aBranches,
68cdf0e10cSrcweir 							INT16				in_nBoundsStatus );
69cdf0e10cSrcweir 						~StateMachin2();
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 		// OPERATIONS
72cdf0e10cSrcweir 		StmBoundsStatu2 &
73cdf0e10cSrcweir 						GetCharChain(
74cdf0e10cSrcweir 							UINT16 &  		   	o_nTokenId,
75cdf0e10cSrcweir 							CharacterSource &	io_rText );
76cdf0e10cSrcweir 	private:
77cdf0e10cSrcweir 		// SERVICE FUNCTIONS
78cdf0e10cSrcweir 		StmStatu2 &		Status(
79cdf0e10cSrcweir 							intt			in_nStatusNr) const;
80cdf0e10cSrcweir 		StmArrayStatu2 &
81cdf0e10cSrcweir 						CurrentStatus() const;
82cdf0e10cSrcweir 		StmBoundsStatu2 *
83cdf0e10cSrcweir 						BoundsStatus() const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 		/// Sets the PeekedStatus.
86cdf0e10cSrcweir 		void			Peek(
87cdf0e10cSrcweir 							intt			in_nBranch);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 		void			ResizeStati();		// Adds space for 32 stati.
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 		// DATA
92cdf0e10cSrcweir 		StatusList      pStati;				///	List of Status, implemented as simple C-array of length #nStatiSpace
93cdf0e10cSrcweir 											/// with nStatiLength valid members (beginning from zero).
94cdf0e10cSrcweir 		intt			nCurrentStatus;
95cdf0e10cSrcweir 		intt			nPeekedStatus;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		intt			nStatusSize;		/// Size of the branch array of a single status.
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 		intt			nNrofStati;			/// Nr of Stati so far.
100cdf0e10cSrcweir 		intt			nStatiSpace;        /// Size of allocated array for #pStati (size in items).
101cdf0e10cSrcweir };
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /**	@#AddToken
106cdf0e10cSrcweir 	@descr
107cdf0e10cSrcweir 	Adds a token, which will be recogniszeds by the
108cdf0e10cSrcweir 	statemachine.
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir **/
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir #endif
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118