Edinburgh Speech Tools
2.4-release
EST_Item_Content.cc
1
/*************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
5
/* Copyright (c) 1995,1996 */
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 : May 1998 */
35
/*-----------------------------------------------------------------------*/
36
/* Content part of a linguistic item, normally only referenced from */
37
/* EST_Item */
38
/* */
39
/*=======================================================================*/
40
41
#include <cstdlib>
42
#include <cstdio>
43
#include <fstream>
44
#include "ling_class/EST_Item_Content.h"
45
#include "ling_class/EST_Item.h"
46
#include "EST_error.h"
47
48
void
EST_Item_Content::copy(
const
EST_Item_Content
&x)
49
{
50
f
= x.
f
;
51
// don't copy the relations as they have relation dependencies
52
}
53
54
EST_Item_Content::~EST_Item_Content
()
55
{
56
if
(relations.
length
() != 0)
57
{
// Shouldn't get here, but just in case.
58
cerr <<
"EST_Contents: contents still referenced by Relations"
<< endl;
59
}
60
}
61
62
int
EST_Item_Content::unref_relation(
const
EST_String
&relname)
63
{
64
// Unreference this item from this relation. Returns TRUE
65
// if no one else is referencing it, FALSE otherwise
66
if
((relname ==
""
) && (relations.
length
() == 1))
67
{
// sigh, something to with isolated EST_Items and
68
// SunCC causes a problems in exit(), so hit it with
69
// a bigger stick
70
relations.
clear
();
71
return
TRUE;
72
}
73
if
(relations.
present
(relname))
74
relations.
remove_item
(relname);
75
else
76
printf(
"failed to find %s in %s at %g\n"
,
77
(
const
char
*)relname,
78
(
const
char
*)
name
(),
79
f
.
F
(
"end"
,0.0));
80
if
(relations.
length
() == 0)
81
return
TRUE;
82
return
FALSE;
83
}
84
85
int
EST_Item_Content::unref_and_delete()
86
{
87
// Unreference from all relations and delete
88
EST_Item
*np;
89
EST_Litem
*p;
90
91
for
(p=relations.
list
.head(); p;)
92
{
93
np = ::item(relations.
list
(p).v);
94
p=p->next();
95
delete
np;
96
}
97
// When the last relation is deleted this contents itself will be
98
// delete too, from underneath us.
99
return
0;
100
}
101
102
EST_Item_Content
&EST_Item_Content::operator=(
const
EST_Item_Content
&x)
103
{
104
copy(x);
105
return
*
this
;
106
}
107
108
ostream& operator << (ostream &s,
const
EST_Item_Content
&a)
109
{
110
EST_Litem
*p;
111
s << a.
name
() <<
" ; "
;
112
s << a.
f
;
113
s <<
"Relations"
;
114
for
(p=a.relations.
list
.head(); p; p = p->next())
115
s <<
" "
<< a.relations.
list
(p).k;
116
s << endl;
117
return
s;
118
}
119
120
VAL_REGISTER_CLASS_NODEL(icontent,
EST_Item_Content
)
EST_Features::F
const float F(const EST_String &path) const
Definition:
EST_Features.h:135
EST_TKVL::list
EST_TList< EST_TKVI< K, V > > list
Linked list of key-val pairs. Don't use this as it will be made private in the future.
Definition:
EST_TKVL.h:93
EST_Item_Content
Definition:
EST_Item_Content.h:67
EST_TKVL::remove_item
int remove_item(const K &rkey, int quiet=0)
remove key and val pair from list
Definition:
EST_TKVL.cc:263
EST_TKVL::clear
void clear()
Empty list.
Definition:
EST_TKVL.cc:50
EST_TKVL::present
const int present(const K &rkey) const
Returns true if key is present.
Definition:
EST_TKVL.cc:222
EST_UItem
Definition:
EST_UList.h:51
EST_String
Definition:
EST_String.h:70
EST_Item_Content::~EST_Item_Content
~EST_Item_Content()
destructor
Definition:
EST_Item_Content.cc:54
EST_Item_Content::name
const EST_String name() const
Definition:
EST_Item_Content.h:90
EST_TKVL::length
const int length() const
number of key value pairs in list
Definition:
EST_TKVL.h:96
EST_Item_Content::f
EST_Features f
General features for this item.
Definition:
EST_Item_Content.h:83
EST_Item
Definition:
EST_Item.h:82
ling_class
EST_Item_Content.cc
Generated on Wed May 20 2020 08:40:31 for Edinburgh Speech Tools by
1.8.17