Data Structures | Macros | Typedefs | Enumerations
gfsmArc.h File Reference

Arc (transition) definitions & utilities. More...

#include <gfsmSemiring.h>
#include <stdarg.h>
#include <gfsmArc.hi>
Include dependency graph for gfsmArc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gfsmArc
 "Heavy" arc structure More...
struct  gfsmArcCompData
 Data for new-style generic arc comparison. More...

Macros

#define gfsmACShift   4
#define gfsmACMaxN   6
Arc Accessors
#define gfsm_arc_source(arcptr)   ((arcptr)->source)
#define gfsm_arc_target(arcptr)   ((arcptr)->target)
#define gfsm_arc_lower(arcptr)   ((arcptr)->lower)
#define gfsm_arc_upper(arcptr)   ((arcptr)->upper)
#define gfsm_arc_weight(arcptr)   ((arcptr)->weight)

Typedefs

typedef guint32 gfsmArcCompMask
 Prioritized list of up to 5 elementary arc comparisons packed as a guint32 The primary comparison is encoded as a gfsmArcComp in the least significant 4-bit nybble of the integer, the secondary comparison is left-shifted by 4 bits, and so on.
typedef gfsmArcCompMask gfsmArcSortMode
 Semi-compatible typedef for arc sort mode.

Enumerations

enum  gfsmLabelSide { gfsmLSBoth = 0, gfsmLSLower = 1, gfsmLSUpper = 2 }
 Type for identifying arc-label "sides" in a transducer (lower vs. upper) More...
enum  gfsmArcComp {
  gfsmACNone = 0x0, gfsmACLower = 0x1, gfsmACUpper = 0x2, gfsmACWeight = 0x3,
  gfsmACSource = 0x4, gfsmACTarget = 0x5, gfsmACUser = 0x6, gfsmACUnused1 = 0x7,
  gfsmACReverse = 0x8, gfsmACLowerR = 0x9, gfsmACUpperR = 0xa, gfsmACWeightR = 0xb,
  gfsmACSourceR = 0xc, gfsmACTargetR = 0xd, gfsmACUserR = 0xe, gfsmACAll = 0xf
}
 Enum type for elementary builtin comparisons on gfsmArc. More...
enum  gfsmArcSortModeE {
  gfsmASMNone = 0x0, gfsmASMLower = (gfsmACLower|(gfsmACUpper<< 4 )|(gfsmACTarget<<(2* 4 ))), gfsmASMUpper = (gfsmACUpper|(gfsmACLower<< 4 )|(gfsmACTarget<<(2* 4 ))), gfsmASMWeight = gfsmACWeight,
  gfsmASMLowerWeight = (gfsmACLower|(gfsmACWeight<< 4 )), gfsmASMUpperWeight = (gfsmACUpper|(gfsmACWeight<< 4 )), gfsmASMUser = gfsmACUser
}

Functions

Arc Comparison Utilities
static gint gfsm_arc_compare_bymask_inline (gfsmArc *a1, gfsmArc *a2, gfsmArcCompData *acdata)
gint gfsm_arc_compare_bymask (gfsmArc *a1, gfsmArc *a2, gfsmArcCompData *acdata)
static gint gfsm_arc_compare_bymask_1_ (gfsmArc *a1, gfsmArc *a2, gfsmArcComp cmp, gfsmArcCompData *acdata)
gfsmArcCompMask gfsm_acmask_from_chars (const char *maskchars)
gfsmArcCompMask gfsm_acmask_from_args (gfsmArcComp cmp0,...)
static gfsmArcCompMask gfsm_acmask_new (gfsmArcComp cmp, gint nth)
static gfsmArcComp gfsm_acmask_nth (gfsmArcCompMask m, gint nth)
static gfsmArcComp gfsm_acmask_nth_comp (gfsmArcCompMask m, gint nth)
static gboolean gfsm_acmask_nth_reverse (gfsmArcCompMask m, gint nth)
static gchar gfsm_acmask_nth_char (gfsmArcCompMask m, gint nth)
const gchar * gfsm_acmask_nth_string (gfsmArcCompMask m, gint nth)
gchar * gfsm_acmask_to_chars (gfsmArcCompMask m, gchar *chars)
GString * gfsm_acmask_to_gstring (gfsmArcCompMask m, GString *gstr)
static const gchar * gfsm_arc_sortmode_to_name (gfsmArcCompMask m)

Arcs: Constructors etc.

#define gfsm_arc_copy(src)   gfsm_arc_clone(src)
static gfsmArcgfsm_arc_new (void)
static gfsmArcgfsm_arc_init (gfsmArc *a, gfsmStateId src, gfsmStateId dst, gfsmLabelId lo, gfsmLabelId hi, gfsmWeight wt)
static gfsmArcgfsm_arc_new_full (gfsmStateId src, gfsmStateId dst, gfsmLabelVal lo, gfsmLabelVal hi, gfsmWeight wt)
static gfsmArcgfsm_arc_clone (gfsmArc *src)
static void gfsm_arc_free (gfsmArc *a)

Detailed Description

Macro Definition Documentation

#define gfsmACShift   4

Number of bits to left-shift gfsmArcCompMask for each arc sub-comparison using gfsmArcComp encoding

#define gfsmACMaxN   6

Maximum number of gfsmArcComp fields supported by gfsmArcCompMask (pragmatic definition)

#define gfsm_arc_copy (   src)    gfsm_arc_clone(src)

Backwards-compatible convenience alias for gfsm_arc_clone()

#define gfsm_arc_source (   arcptr)    ((arcptr)->source)

Get source node of an arc – may be gfsmNoState

#define gfsm_arc_target (   arcptr)    ((arcptr)->target)

Get target node of an arc – may be gfsmNoState

#define gfsm_arc_lower (   arcptr)    ((arcptr)->lower)

Get lower label of an arc – may be gfsmNoLabel

#define gfsm_arc_upper (   arcptr)    ((arcptr)->upper)

Get upper label of an arc – may be gfsmNoLabel

#define gfsm_arc_weight (   arcptr)    ((arcptr)->weight)

Get weight of an arc – may be gfsmNoWeight

Typedef Documentation

typedef guint32 gfsmArcCompMask

Enumeration Type Documentation

Enumerator:
gfsmLSBoth 

Both sides (lower and upper)

gfsmLSLower 

Lower side only.

gfsmLSUpper 

Upper side only.

Since
v0.0.10
Enumerator:
gfsmACNone 

'_': no comparison at all

gfsmACLower 

'l': compare lower labels (ascending order)

gfsmACUpper 

'u': compare upper labels (ascending order)

gfsmACWeight 

'w': compare semiring weights (ascending order)

gfsmACSource 

's': compare source states (if supported and meaningful, ascending order)

gfsmACTarget 

't': compare target states (if supported and meaningful, ascending order)

gfsmACUser 

'x': pseudo-field indicating a user-defined comparison

gfsmACUnused1 

unused

gfsmACReverse 

not really a comparison: the bit 0x8 is set for all "reverse" comparisons

gfsmACLowerR 

'L': compare lower labels (descending order)

gfsmACUpperR 

'U': compare upper labels (descending order)

gfsmACWeightR 

'W': compare semiring weights (descending order)

gfsmACSourceR 

'S': compare source states (if supported and meaningful, descending order)

gfsmACTargetR 

'T': compare target states (if supported and meaningful, descending order)

gfsmACUserR 

'X': pseudo-field for reversed user-defined comparisons, for symmetry

gfsmACAll 

'*': pseudo-field for mask of all known elementary comparisons

Useful aliases for builtin arcsort modes, including backwards-compatible gfsmASMLower etc.

Enumerator:
gfsmASMNone 

no sort

gfsmASMLower 

(lower,upper,target)

gfsmASMUpper 

(upper,lower,target)

gfsmASMWeight 

(weight)

gfsmASMLowerWeight 

(lower,weight)

gfsmASMUpperWeight 

(upper,weight)

gfsmASMUser 

user-defined sort

Function Documentation

static gfsmArc* gfsm_arc_new ( void  )
inlinestatic

Create and return a new (empty) gfsmArc

static gfsmArc* gfsm_arc_init ( gfsmArc a,
gfsmStateId  src,
gfsmStateId  dst,
gfsmLabelId  lo,
gfsmLabelId  hi,
gfsmWeight  wt 
)
inlinestatic

Initialize a gfsmArc

Parameters
aarc to initialize
srcID of source state
dstID of target state
loID of lower label
hiID of upper label
warc weight
Returns
initialized arc a
static gfsmArc* gfsm_arc_new_full ( gfsmStateId  src,
gfsmStateId  dst,
gfsmLabelVal  lo,
gfsmLabelVal  hi,
gfsmWeight  wt 
)
inlinestatic

Convenience macro to simultaneously create and initialize a gfsmArc

Parameters
srcID of source state
dstID of target state
loID of lower label
hiID of upper label
warc weight
Returns
newly allocated and initalized gfsmArc
static gfsmArc* gfsm_arc_clone ( gfsmArc src)
inlinestatic

Create an exact copy of the gfsmArc src

static void gfsm_arc_free ( gfsmArc a)
inlinestatic

Destroy a gfsmArc a

static gint gfsm_arc_compare_bymask_inline ( gfsmArc a1,
gfsmArc a2,
gfsmArcCompData acdata 
)
inlinestatic

Generic 3-way comparison on arcs (inline version)

Parameters
a1first arc to compare
a2second arc to compare
acdataspecifies comparison priorities
Returns
negative, zero, or positive integer depending on whether a1 is less-than, equal-to, or greater-than a2 according to acdata.
gint gfsm_arc_compare_bymask ( gfsmArc a1,
gfsmArc a2,
gfsmArcCompData acdata 
)

Generic 3-way comparison on arcs (extern version) Really just a wrapper for gfsm_arc_compare_mask_inline()

static gint gfsm_arc_compare_bymask_1_ ( gfsmArc a1,
gfsmArc a2,
gfsmArcComp  cmp,
gfsmArcCompData acdata 
)
inlinestatic

Guts for gfsm_arc_compare_bymask_inline(): compare arcs w.r.t a single attribute cmp.

Note
gcc deems all but the first call "unlikely" in gfsm_arc_compare_bymask() and refuses to inline...
gfsmArcCompMask gfsm_acmask_from_chars ( const char *  maskchars)

Parse a NUL-terminated string into a gfsmArcCompMask

Parameters
maskcharsA NUL-terminated string representing the precedence among elementary comparisons. Each character represents a single elementary comparison. The primary comparison is the first character of the string. Correspondence of characters to comparisons is:
Returns
a gfsmArcCompMask for maskchars
gfsmArcCompMask gfsm_acmask_from_args ( gfsmArcComp  cmp0,
  ... 
)

Create and return a gfsmArcCompMask from a variable argument list of gfsmArcComp The argument list must be terminated with a zero (e.g. gfsmACNone)

Parameters
cmp0primary comparison
...secondary, tertiary, ... comparisons
Returns
gfsmArcCompMask for specified comparisons
static gfsmArcCompMask gfsm_acmask_new ( gfsmArcComp  cmp,
gint  nth 
)
inlinestatic

Create a partial gfsmArcCompMask for cmp as the nth (sub-)comparison

static gfsmArcComp gfsm_acmask_nth ( gfsmArcCompMask  m,
gint  nth 
)
inlinestatic

Get nth (sub-)comparison from a gfsmArcCompMask

static gfsmArcComp gfsm_acmask_nth_comp ( gfsmArcCompMask  m,
gint  nth 
)
inlinestatic

Get basic nth basic (sub-)comparison from a gfsmArcCompMask, disregarding sort order

static gboolean gfsm_acmask_nth_reverse ( gfsmArcCompMask  m,
gint  nth 
)
inlinestatic

Get sort order for nth (sub-)comparison of a gfsmArcCompMask.

Returns
a true value if nth sub-comparison is reversed (descending order), otherwise FALSE.
static gchar gfsm_acmask_nth_char ( gfsmArcCompMask  m,
gint  nth 
)
inlinestatic

Get single character representing the nth field of arc comparison mask m, as for gfsm_acmask_from_chars()

const gchar* gfsm_acmask_nth_string ( gfsmArcCompMask  m,
gint  nth 
)

Get a static human-readable string representing the nth field of arc comparison mask m

gchar* gfsm_acmask_to_chars ( gfsmArcCompMask  m,
gchar *  chars 
)

Populate a character string representing a gfsmArcCompMask.

Parameters
mask[in]mask to convert to a string
chars[out]character string representing mask, in the format acepted by gfsm_acmask_from_chars(), or NULL to allocate a new string. If specified and non-NULL, chars should be long enough to hold gfsmACMaxN+1 characters, since a terminating NUL is implicitly added as the final character.
Returns
chars if specified, otherwise a newly allocated string.
Note
User is responsible for freeing the returned string with g_free() when it is no longer needed.
GString* gfsm_acmask_to_gstring ( gfsmArcCompMask  m,
GString *  gstr 
)

Populate a GString* with a human-readable representation of a gfsmArcCompMask.

Parameters
mask[in]mask to convert to a string
gstr[out]GString representing mask, in human-readable format, or NULL to allocate a new GString*.
Returns
gstr if specified, otherwise a newly allocated GString*.
Note
User is responsible for freeing the returned GString* with g_string_free() when it is no longer needed.
static const gchar* gfsm_arc_sortmode_to_name ( gfsmArcCompMask  m)
inlinestatic

Backwards-compatible arc sort mode name resolution function

Deprecated:
in favor of gfsm_acmask_nth_string(), gfsm_acmask_to_gstring(), gfsm_acmask_to_chars()