Edinburgh Speech Tools  2.1-release
EST_TKVLI.h
Go to the documentation of this file.
1 
2  /************************************************************************/
3  /* */
4  /* Centre for Speech Technology Research */
5  /* University of Edinburgh, UK */
6  /* Copyright (c) 1996,1997 */
7  /* All Rights Reserved. */
8  /* */
9  /* Permission is hereby granted, free of charge, to use and distribute */
10  /* this software and its documentation without restriction, including */
11  /* without limitation the rights to use, copy, modify, merge, publish, */
12  /* distribute, sublicense, and/or sell copies of this work, and to */
13  /* permit persons to whom this work is furnished to do so, subject to */
14  /* the following conditions: */
15  /* 1. The code must retain the above copyright notice, this list of */
16  /* conditions and the following disclaimer. */
17  /* 2. Any modifications must be clearly marked as such. */
18  /* 3. Original authors' names are not deleted. */
19  /* 4. The authors' names are not used to endorse or promote products */
20  /* derived from this software without specific prior written */
21  /* permission. */
22  /* */
23  /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
24  /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
25  /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
26  /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
27  /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
28  /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
29  /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
30  /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
31  /* THIS SOFTWARE. */
32  /* */
33  /*************************************************************************/
34 
35 
36 #ifndef __EST_KVL_I_H__
37 #define __EST_KVL_I_H__
38 
39 /** Instantiate rules for list template.
40  *
41  * @author Richard Caley <rjc@cstr.ed.ac.uk>
42  * @version $Id: EST_TKVLI.h,v 1.4 2006/07/19 21:52:12 awb Exp $
43  */
44 
45 #include "instantiate/EST_TListI.h"
47 
48 // Instantiation Macros
49 
50 // the typedef is purely to get the type name through the following macro.
51 
52 #define Instantiate_KVL_T(KEY, VAL, TAG) \
53  template class EST_TKVL<KEY, VAL>; \
54  template class EST_TKVI<KEY, VAL>; \
55  Instantiate_TIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer_k, KEY, KVL_ ## TAG ##_kitt) \
56  Instantiate_TStructIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer, KVI_ ## TAG ## _t, KVL_ ## TAG ##_itt) \
57  Instantiate_TIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer, KVI_ ## TAG ## _t, KVL_ ## TAG ##_itt) \
58  Instantiate_TList(KVI_ ## TAG ## _t)
59 
60 // template ostream & operator<<(ostream &s, EST_TKVI<KEY, VAL> const &i);
61 
62 #define Instantiate_KVL(KEY, VAL) \
63  Instantiate_KVL_T(KEY, VAL, KEY ## VAL)
64 
65 #define Declare_KVL_TN(KEY, VAL, MaxFree, TAG) \
66  typedef EST_TKVI<KEY, VAL> KVI_ ## TAG ## _t; \
67  typedef EST_TKVL<KEY, VAL> KVL_ ## TAG ## _t; \
68  \
69  static VAL TAG##_kv_def_val_s; \
70  static KEY TAG##_kv_def_key_s; \
71  \
72  template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
73  template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
74  \
75  Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
76 #define Declare_KVL_T(KEY, VAL, TAG) \
77  Declare_KVL_TN(KEY, VAL, 0, TAG)
78 
79 #define Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, MaxFree, TAG) \
80  typedef EST_TKVI<KEY, VAL> KVI_ ## TAG ## _t; \
81  typedef EST_TKVL<KEY, VAL> KVL_ ## TAG ## _t; \
82  \
83  static VAL TAG##_kv_def_val_s=DEFV; \
84  static KEY TAG##_kv_def_key_s=DEFK; \
85  \
86  template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
87  template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
88  \
89  Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
90 #define Declare_KVL_Base_T(KEY, VAL, DEFV, DEFK, TAG) \
91  Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, 0, TAG)
92 
93 #define Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, MaxFree, TAG) \
94  typedef EST_TKVI<KEY, VAL> KVI_ ## TAG ## _t; \
95  typedef EST_TKVL<KEY, VAL> KVL_ ## TAG ## _t; \
96  \
97  static VAL TAG##_kv_def_val_s(DEFV); \
98  static KEY TAG##_kv_def_key_s(DEFK); \
99  \
100  template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
101  template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
102  \
103  Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
104 #define Declare_KVL_Class_T(KEY, VAL, DEFV, DEFK,TAG) \
105  Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, 0, TAG)
106 
107 #define Declare_KVL_N(KEY, VAL, MaxFree) \
108  Declare_KVL_TN(KEY, VAL, MaxFree, KEY ## VAL)
109 #define Declare_KVL(KEY, VAL) \
110  Declare_KVL_N(KEY, VAL, 0)
111 
112 #define Declare_KVL_Base_N(KEY, VAL, DEFV, DEFK, MaxFree) \
113  Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, , MaxFree, KEY ## VAL)
114 #define Declare_KVL_Base(KEY, VAL, DEFV, DEFK) \
115  Declare_KVL_Base_N(KEY, VAL, DEFV, DEFK, 0)
116 
117 #define Declare_KVL_Class_N(KEY, VAL, DEFV, DEFK, MaxFree) \
118  Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, MaxFree, KEY ## VAL)
119 #define Declare_KVL_Class(KEY, VAL, DEFV, DEFK) \
120  Declare_KVL_Class_N(KEY, VAL, DEFV, DEFK, 0)
121 
122 #endif
123