"Fossies" - the Fresh Open Source Software Archive

Member "speech_tools/ling_class/EST_Item_Content.cc" (4 Sep 2017, 5014 Bytes) of package /linux/misc/speech_tools-2.5.0-release.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "EST_Item_Content.cc" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.4-release_vs_2.5.0-release.

    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)