54#include "ling_class/EST_Item.h"
55#include "ling_class/EST_Relation.h"
56#include "ling_class/EST_Utterance.h"
59#include "EST_string_aux.h"
61#include "ling_class_init.h"
66void EST_Item::class_init(
void)
69 cerr <<
"Calling EST_Item init\n";
72 ling_class_init::use();
74 EST_register_feature_functions(
standard);
77 cerr <<
"Finished EST_Item init\n";
89void EST_Item::copy(
const EST_Item &s)
100 *p_contents = *s.p_contents;
121 if (p != 0) p->n = n;
122 if (u != 0) u->d = n;
126 if (p_relation->p_head ==
this)
127 p_relation->p_head = n;
128 if (p_relation->p_tail ==
this)
129 p_relation->p_tail = p;
168 set_contents(
li->contents());
177 evaluate(
this,p_contents->
f);
180void EST_Item::unref_contents()
192void EST_Item::unref_all()
196 p_contents->unref_and_delete();
201 return ((
this == 0) || (p_relation == 0)) ?
231int EST_Item::length()
const
252 if (p_relation && (p_relation->p_tail ==
this))
277 if (p_relation && (p_relation->p_head ==
this))
308 if (p_relation && (p_relation->p_head ==
this))
310 if (p_relation && (p_relation->p_tail ==
this))
321 d->set_contents(grab_contents());
323 set_contents(
si->grab_contents());
390 if (
x == NULL)
return NULL;
391 if (inext(
x) != NULL)
392 return first_leaf(inext(
x));
394 return next_leaf(parent(
x));
402 else if (idown(
x) != NULL)
404 else if (inext(
x) != NULL)
409 if (inext(
pp))
return inext(
pp);
417 if (
x == NULL)
return NULL;
418 if (idown(
x) == NULL)
421 return first_leaf(idown(
x));
427 if (
x == NULL)
return NULL;
429 return last_leaf(last(
x));
431 return last_leaf(idown(
x));
438 if (root == NULL)
return NULL;
439 return first_leaf(root);
444 if (root == NULL)
return NULL;
445 if (idown(root) == NULL)
448 return last_leaf(idown(root));
462 if (in_list(c,p_relation->
head()))
472 nnode = last(d)->insert_after(
si);
485 nnode = last(d)->insert_after(
si);
499 if (in_list(c,p_relation->
head()))
556 if (inext(from) != 0)
557 copy_node_tree(inext(from),to->insert_after(inext(from)));
559 if (idown(from) != 0)
560 copy_node_tree(idown(from),to->insert_below(idown(from)));
569 if (inext(from) != 0)
572 copy_node_tree_contents(inext(from),to->insert_after(&i));
575 if (idown(from) != 0)
578 copy_node_tree_contents(idown(from),to->insert_below(&i));
583int EST_Item::verify()
const
588 if (((d == 0) || (d->u ==
this)) &&
589 ((n == 0) || (n->p ==
this)))
591 if ((d) && (!d->verify()))
593 if ((n) && (!n->verify()))
603 return n->append_daughter(p);
608 return append_daughter(as(n,
relname),p);
613 return n->prepend_daughter(p);
618 return prepend_daughter(as(n,
relname),p);
626 if ((
lr != 0) && (r != 0))
638 a.features().
save(s);
647 for(p.
begin(f); p; ++p)
648 if (p->v.type() == val_type_featfunc)
650 if (featfunc(p->v) != NULL)
651 p->v = (featfunc(p->v))(a);
655 p->v = EST_Features::feature_default_value;
660VAL_REGISTER_CLASS_NODEL(item,
EST_Item)
EST_write_status save(ostream &outf) const
save features in already opened ostream
EST_Features f
General features for this item.
void set(const EST_String &name, int ival)
const EST_String & relation_name() const
The relation name of this particular item.
EST_Item * as_relation(const char *relname) const
View item from another relation (const char *) method.
EST_Item()
Default constructor.
int f_present(const EST_String &name) const
~EST_Item()
Deletes it and references to it in its contents.
void remove_item(EST_Item *item)
const EST_String & name() const
static const EST_String Empty
Constant empty string.
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
void begin(Container &over)
Set the iterator ready to run over this container.
int next_id()
return the id of the next item