1/*************************************************************************/
2/* */
3/* Language Technologies Institute */
4/* Carnegie Mellon University */
5/* Copyright (c) 1999 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author: Alan W Black (awb@cs.cmu.edu) */
34/* Date: December 1999 */
35/*************************************************************************/
36/* */
37/* Item */
38/* */
39/*************************************************************************/
40#ifndef _CST_ITEM_H__
41#define _CST_ITEM_H__
42
43#include "cst_file.h"
44#include "cst_features.h"
45
46/* Everyone needs these so forward define these */
47typedef struct cst_relation_struct cst_relation;
48typedef struct cst_utterance_struct cst_utterance;
49typedef struct cst_item_struct cst_item;
50
51/* So items, relations and utterances can be used as vals */
52CST_VAL_USER_TYPE_DCLS(relation,cst_relation)
53CST_VAL_USER_TYPE_DCLS(item,cst_item)
54CST_VAL_USER_TYPE_DCLS(utterance,cst_utterance)
55
56typedef struct cst_item_contents_struct {
57 cst_features *features;
58 cst_features *relations;
59} cst_item_contents;
60
61struct cst_item_struct {
62 cst_item_contents *contents; /* the shared part of an item */
63 cst_relation *relation;
64 cst_item *n;
65 cst_item *p;
66 cst_item *u;
67 cst_item *d;
68};
69
70/* Constructor functions */
71cst_item *new_item_relation(cst_relation *r,cst_item *i);
72cst_item_contents *new_item_contents(cst_item *i);
73
74/* Remove this item from this references */
75void delete_item(cst_item *item);
76
77void item_contents_set(cst_item *current, cst_item *i);
78void item_unref_contents(cst_item *i);
79
80cst_item *item_as(const cst_item *i,const char *rname);
81
82cst_utterance *item_utt(const cst_item *i);
83
84/* List accessor/manipulator function */
85cst_item *item_next(const cst_item *i);
86cst_item *item_prev(const cst_item *i);
87
88cst_item *item_append(cst_item *i,cst_item *new_item);
89cst_item *item_prepend(cst_item *i,cst_item *new_item);
90
91/* Tree accessor/manipulator function */
92cst_item *item_parent(const cst_item *i);
93cst_item *item_nth_daughter(const cst_item *i,int n);
94cst_item *item_daughter(const cst_item *i);
95cst_item *item_last_daughter(const cst_item *i);
96cst_item *item_first(const cst_item *i);
97cst_item *item_last(const cst_item *i);
98
99cst_item *item_add_daughter(cst_item *i,cst_item *new_item);
100cst_item *item_append_sibling(cst_item *i,cst_item *new_item);
101cst_item *item_prepend_sibling(cst_item *i,cst_item *new_item);
102
103/* Feature accessor/manipulator functions */
104int item_feat_present(const cst_item *i,const char *name);
105int item_feat_remove(const cst_item *i,const char *name);
106cst_features *item_feats(const cst_item *i);
107const cst_val *item_feat(const cst_item *i,const char *name);
108int item_feat_int(const cst_item *i,const char *name);
109float item_feat_float(const cst_item *i,const char *name);
110const char *item_feat_string(const cst_item *i,const char *name);
111void item_set(const cst_item *i,const char *name,const cst_val *val);
112void item_set_int(const cst_item *i,const char *name,int val);
113void item_set_float(const cst_item *i,const char *name,float val);
114void item_set_string(const cst_item *i,const char *name,const char *val);
115
116#define item_name(I) item_feat_string(I,"name")
117
118int item_equal(const cst_item *a, const cst_item *b);
119
120const char *ffeature_string(const cst_item *item,const char *featpath);
121int ffeature_int(const cst_item *item,const char *featpath);
122float ffeature_float(const cst_item *item,const char *featpath);
123const cst_val *ffeature(const cst_item *item,const char *featpath);
124cst_item* path_to_item(const cst_item *item,const char *featpath);
125
126/* Feature function, for features that are derived algorithmically from others. */
127typedef const cst_val *(*cst_ffunction)(const cst_item *i);
128CST_VAL_USER_FUNCPTR_DCLS(ffunc,cst_ffunction)
129void ff_register(cst_features *ffeatures, const char *name,
130 cst_ffunction f);
131void ff_unregister(cst_features *ffeatures, const char *name);
132
133/* Generalized item hook function, like cst_uttfunc. */
134typedef cst_val *(*cst_itemfunc)(cst_item *i);
135CST_VAL_USER_FUNCPTR_DCLS(itemfunc,cst_itemfunc)
136
137#endif
138

source code of include/flite/cst_item.h