gfsmArc.h
Go to the documentation of this file.
1 /*=============================================================================*\
2  * File: gfsmArc.h
3  * Author: Bryan Jurish <moocow.bovine@gmail.com>
4  * Description: finite state machine library: arcs
5  *
6  * Copyright (c) 2004-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_ARC_H
28 #define _GFSM_ARC_H
29 
30 #include <gfsmSemiring.h>
31 #include <stdarg.h>
32 
34 typedef struct {
40 } gfsmArc;
41 
43 typedef enum {
44  gfsmLSBoth = 0,
48 
49 //----------------------------------------------------------------------
50 // arc sorting (new)
51 
53 
54 typedef enum {
55  gfsmACNone = 0x0,
56  //
57  //-- Forward (ascending)
58  gfsmACLower = 0x1,
59  gfsmACUpper = 0x2,
60  gfsmACWeight = 0x3,
61  gfsmACSource = 0x4,
62  gfsmACTarget = 0x5,
63  gfsmACUser = 0x6,
64  gfsmACUnused1 = 0x7,
65  //
66  //-- Reverse (descending)
67  gfsmACReverse = 0x8,
68  gfsmACLowerR = 0x9,
69  gfsmACUpperR = 0xa,
70  gfsmACWeightR = 0xb,
71  gfsmACSourceR = 0xc,
72  gfsmACTargetR = 0xd,
73  gfsmACUserR = 0xe,
74  //
75  //-- Pseudo-comparisons
76  gfsmACAll = 0xf
77 } gfsmArcComp;
78 
85 typedef guint32 gfsmArcCompMask;
86 
88 #define gfsmACShift 4
89 
91 #define gfsmACMaxN 6
92 
94 typedef enum {
95  gfsmASMNone = 0x0,
103 
106 
108 typedef struct {
111  GCompareDataFunc user_compare_func;
112  gpointer user_data;
114 
115 /*======================================================================
116  * Methods: Arcs: Constructors etc.
117  */
118 
120 
121 
123 gfsmArc *gfsm_arc_new(void);
124 
136  gfsmStateId src,
137  gfsmStateId dst,
138  gfsmLabelId lo,
139  gfsmLabelId hi,
140  gfsmWeight wt);
141 
152 
156 
158 #define gfsm_arc_copy(src) gfsm_arc_clone(src)
159 
162 void gfsm_arc_free(gfsmArc *a);
164 
165 /*======================================================================
166  * Methods: Arc: Accessors
167  */
169 
170 
172 #define gfsm_arc_source(arcptr) ((arcptr)->source)
173 
175 #define gfsm_arc_target(arcptr) ((arcptr)->target)
176 
178 #define gfsm_arc_lower(arcptr) ((arcptr)->lower)
179 
181 #define gfsm_arc_upper(arcptr) ((arcptr)->upper)
182 
184 #define gfsm_arc_weight(arcptr) ((arcptr)->weight)
185 
187 
188 
189 /*======================================================================
190  * Arc Comparison Utilities
191  */
193 
194 
205 
210 
216 
237 gfsmArcCompMask gfsm_acmask_from_chars(const char *maskchars);
238 
246 
250 
254 
258 
263 gboolean gfsm_acmask_nth_reverse(gfsmArcCompMask m, gint nth);
264 
267 gchar gfsm_acmask_nth_char(gfsmArcCompMask m, gint nth);
268 
270 const gchar *gfsm_acmask_nth_string(gfsmArcCompMask m, gint nth);
271 
281 gchar *gfsm_acmask_to_chars(gfsmArcCompMask m, gchar *chars);
282 
290 GString *gfsm_acmask_to_gstring(gfsmArcCompMask m, GString *gstr);
291 
297 
299 
300 //-- inline definitions
301 #ifdef GFSM_INLINE_ENABLED
302 # include <gfsmArc.hi>
303 #endif
304 
305 #endif /* _GFSM_ARC_H */