Edinburgh Speech Tools
2.1-release
EST_Val_defs.h
Go to the documentation of this file.
1
/*************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
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
/* THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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 */
34
/* Date : March 1999 */
35
/*-----------------------------------------------------------------------*/
36
/* */
37
/* Macros definitions for defining anything as vals */
38
/* */
39
/*=======================================================================*/
40
#ifndef __EST_VAL_DEFS_H__
41
#define __EST_VAL_DEFS_H__
42
43
/* Macro for defining new class as values public functions */
44
#define VAL_REGISTER_CLASS_DCLS(NAME,CLASS) \
45
extern val_type val_type_##NAME; \
46
class CLASS *NAME(const EST_Val &v); \
47
EST_Val est_val(const class CLASS *v);
48
49
/* For things that aren't classes (typed def something else) */
50
#define VAL_REGISTER_TYPE_DCLS(NAME,CLASS) \
51
extern val_type val_type_##NAME; \
52
CLASS *NAME(const EST_Val &v); \
53
EST_Val est_val(const CLASS *v);
54
55
#define VAL_REGISTER_FUNCPTR_DCLS(NAME,TYPE) \
56
extern val_type val_type_##NAME; \
57
TYPE NAME(const EST_Val &v); \
58
EST_Val est_val(const TYPE v);
59
60
61
/* Macro for defining new class as values */
62
#define VAL_REGISTER_CLASS(NAME,CLASS) \
63
val_type val_type_##NAME=#NAME; \
64
class CLASS *NAME(const EST_Val &v) \
65
{ \
66
if (v.type() == val_type_##NAME) \
67
return (class CLASS *)v.internal_ptr(); \
68
else \
69
EST_error("val not of type val_type_"#NAME); \
70
return NULL; \
71
} \
72
\
73
static void val_delete_##NAME(void *v) \
74
{ \
75
delete (class CLASS *)v; \
76
} \
77
\
78
EST_Val est_val(const class CLASS *v) \
79
{ \
80
return EST_Val(val_type_##NAME, \
81
(void *)v,val_delete_##NAME); \
82
} \
83
84
/* Macro for defining new typedef'd things as vals */
85
/* You don't need CLASS and TYPE but it often convenient */
86
#define VAL_REGISTER_TYPE(NAME,CLASS) \
87
val_type val_type_##NAME=#NAME; \
88
CLASS *NAME(const EST_Val &v) \
89
{ \
90
if (v.type() == val_type_##NAME) \
91
return (CLASS *)v.internal_ptr(); \
92
else \
93
EST_error("val not of type val_type_"#NAME); \
94
return NULL; \
95
} \
96
\
97
static void val_delete_##NAME(void *v) \
98
{ \
99
delete (CLASS *)v; \
100
} \
101
\
102
EST_Val est_val(const CLASS *v) \
103
{ \
104
return EST_Val(val_type_##NAME, \
105
(void *)v,val_delete_##NAME); \
106
} \
107
108
/* Macro for defining new typedef'd things as vals that don't get deleted */
109
/* You don't need CLASS and TYPE but it often convenient */
110
#define VAL_REGISTER_TYPE_NODEL(NAME,CLASS) \
111
val_type val_type_##NAME=#NAME; \
112
CLASS *NAME(const EST_Val &v) \
113
{ \
114
if (v.type() == val_type_##NAME) \
115
return (CLASS *)v.internal_ptr(); \
116
else \
117
EST_error("val not of type val_type_"#NAME); \
118
return NULL; \
119
} \
120
\
121
static void val_delete_##NAME(void *v) \
122
{ \
123
(void)v; \
124
} \
125
\
126
EST_Val est_val(const CLASS *v) \
127
{ \
128
return EST_Val(val_type_##NAME, \
129
(void *)v,val_delete_##NAME); \
130
} \
131
132
/* Macro for defining new class as values */
133
#define VAL_REGISTER_CLASS_NODEL(NAME,CLASS) \
134
val_type val_type_##NAME=#NAME; \
135
class CLASS *NAME(const EST_Val &v) \
136
{ \
137
if (v.type() == val_type_##NAME) \
138
return (class CLASS *)v.internal_ptr(); \
139
else \
140
EST_error("val not of type val_type_"#NAME); \
141
return NULL; \
142
} \
143
\
144
static void val_delete_##NAME(void *v) \
145
{ \
146
(void)v; \
147
} \
148
\
149
EST_Val est_val(const class CLASS *v) \
150
{ \
151
return EST_Val(val_type_##NAME, \
152
(void *)v,val_delete_##NAME); \
153
} \
154
155
/* Macro for defining function pointers as values */
156
#define VAL_REGISTER_FUNCPTR(NAME,CLASS) \
157
val_type val_type_##NAME=#NAME; \
158
CLASS NAME(const EST_Val &v) \
159
{ \
160
if (v.type() == val_type_##NAME) \
161
return (CLASS)v.internal_ptr(); \
162
else \
163
EST_error("val not of type val_type_"#NAME); \
164
return NULL; \
165
} \
166
\
167
static void val_delete_##NAME(void *v) \
168
{ \
169
(void)v; \
170
} \
171
\
172
EST_Val est_val(const CLASS v) \
173
{ \
174
return EST_Val(val_type_##NAME, \
175
(void *)v,val_delete_##NAME); \
176
} \
177
178
179
180
#endif
include
EST_Val_defs.h
Generated on Fri Oct 6 2017 18:25:28 for Edinburgh Speech Tools by
1.8.11