gfsmPaths.h
Go to the documentation of this file.
1 /*=============================================================================*\
2  * File: gfsmPaths.h
3  * Author: Bryan Jurish <moocow.bovine@gmail.com>
4  * Description: finite state machine library
5  *
6  * Copyright (c) 2005-2011 Bryan Jurish.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 3 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *=============================================================================*/
22 
27 #ifndef _GFSM_PATHS_H
28 #define _GFSM_PATHS_H
29 
30 #include <gfsmAutomaton.h>
31 
32 /*======================================================================
33  * Types: paths
34  */
35 
37 typedef struct {
41 } gfsmPath;
42 
44 /* The pointer data in the \a data field are (gfsmArc*)s
45  * (usually pointing into an existing gfsmAutomaton) for all but the final
46  * pointer element of the gfsmArcPath, and the
47  * final element is a gpointer-encoded gfsmWeight representing
48  * the final weight associated with the arc path; extract it
49  * e.g. with gfsm_ptr2weight(arcpath->data[arcpath->len-1]).
50  */
51 typedef GPtrArray gfsmArcPath;
52 
53 
54 /*======================================================================
55  * Methods: Path Utilities
56  */
57 
58 //------------------------------
60 
61 
63 
65 #define gfsm_label_vector_dup(src) \
66  gfsm_label_vector_copy(g_ptr_array_sized_new(src->len), src)
67 
71 
72 //------------------------------
74 
75 
80 
82 #define gfsm_path_new(sr) \
83  gfsm_path_new_full(NULL,NULL,gfsm_sr_one(sr))
84 
87 
90 
93 
97 
101 
103 gint gfsm_path_compare_data(const gfsmPath *p1, const gfsmPath *p2, gfsmSemiring *sr);
104 
108 
111 void gfsm_path_free(gfsmPath *p);
113 
114 //======================================================================
116 
117 
127 
142 
143 
146  gfsmSet *paths,
147  gfsmLabelSide which,
148  gfsmStateId q,
149  gfsmPath *path);
150 
151 
152 //------------------------------
156 GSList *gfsm_paths_to_strings(gfsmSet *paths,
157  gfsmAlphabet *abet_lo,
158  gfsmAlphabet *abet_hi,
159  gfsmSemiring *sr,
160  gboolean warn_on_undefined,
161  gboolean att_style,
162  GSList *strings);
163 
169  gboolean warn_on_undefined;
170  gboolean att_style;
171  GSList *strings;
173 
175 #define _gfsm_paths_to_strings_options gfsmPathsToStringsOptions_
176 
179  gpointer value_dummy,
181 
187 GString *gfsm_path_to_gstring(gfsmPath *path,
188  GString *gs,
189  gfsmAlphabet *abet_lo,
190  gfsmAlphabet *abet_hi,
191  gfsmSemiring *sr,
192  gboolean warn_on_undefined,
193  gboolean att_style);
194 
199 char *gfsm_path_to_string(gfsmPath *path,
200  gfsmAlphabet *abet_lo,
201  gfsmAlphabet *abet_hi,
202  gfsmSemiring *sr,
203  gboolean warn_on_undefined,
204  gboolean att_style);
206 
207 //------------------------------
208 // \name gfsmArcPath Utilities
210 
213 
217 
220 
224 
228 
230 void gfsm_arcpath_list_free(GSList *arcpaths);
232 
233 //======================================================================
235 
236 
253 
254 
264  gfsmStateId qid,
265  GSList *path,
266  guint path_len,
267  GSList **paths,
268  GSList **nodes
269  );
270 
278  gboolean warn_on_undefined;
279  gboolean att_style;
280  gboolean compress_id;
281  gboolean show_states;
283 
284 
290 GString *gfsm_arcpath_to_gstring(gfsmArcPath *path, GString *gs, gfsmArcPathToStringOptions *opts);
291 
297 
299 GSList *gfsm_arcpaths_to_strings(GSList *paths, gfsmArcPathToStringOptions *opts);
300 
302 
303 //======================================================================
305 
306 
315 #define gfsm_viterbi_trellis_paths(trellis,paths) \
316  gfsm_viterbi_trellis_paths_full((trellis),(paths),gfsmLSUpper)
317 
318 
328 
329 
333 #define gfsm_viterbi_trellis_bestpath(trellis,path) \
334  gfsm_viterbi_trellis_bestpath_full((trellis),(path),gfsmLSUpper)
335 
340 
343  gfsmPath *path,
344  gfsmLabelSide which,
345  gfsmStateId qid);
346 
348 
349 //-- inline definitions
350 #ifdef GFSM_INLINE_ENABLED
351 # include <gfsmPaths.hi>
352 #endif
353 
354 #endif /* _GFSM_PATHS_H */