Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

mootFSMgfsm.h

Go to the documentation of this file.
00001 /*-*- Mode: C++ -*-*/
00002 
00003 /*
00004    libmootm : moocow's morphology library:
00005    Copyright (C) 2003-2005 by Bryan Jurish <moocow@ling.uni-potsdam.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011    
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016    
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with this library; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 */
00021 
00022 /*----------------------------------------------------------------------
00023  * Name: mootFSMgfsm.h
00024  * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
00025  * Description:
00026  *   + mootm FSMs: GNU gfsm
00027  *----------------------------------------------------------------------*/
00032 #ifndef _moot_FSM_GFSM_H
00033 #define _moot_FSM_GFSM_H
00034 
00035 #ifdef HAVE_CONFIG_H
00036 # include <mootmUnConfig.h>
00037 # include <mootmConfig.h>
00038 #endif
00039 
00040 #if defined(USE_FSM_GFSM)
00041 
00042 #include <mootFSMBase.h>
00043 
00044 extern "C" {
00045 #include <gfsm.h>
00046 }
00047 
00048 namespace mootm {
00049   using namespace std;
00050   using namespace moot;
00051 
00053   typedef class mootFSMgfsm mootFSM;
00054 
00055 
00056   /*------------------------------------------------------------
00057    * Utilities
00058    */
00059 
00061   struct _mootFSMgfsm_analyze_token_params {
00062     gfsmAlphabet *abet;              
00063     gboolean      warn_on_undefined;
00064     gboolean      att_style;
00065     mootToken    *tokp;              
00066     GString      *gstr;              
00067   };
00068 
00070   gboolean _mootFSMgfsm_analyze_token_foreach_func(gfsmPath *path,
00071                                                    gpointer value_dummy,
00072                                                    struct _mootFSMgfsm_analyze_token_params *params);
00073 
00074 
00078   class mootFSMgfsm : public mootFSMBase {
00079   protected:
00080     /*------------------------------------------------------------
00081      * protected data
00082      */
00083     gfsmAlphabet  *abet_lo;    
00084     gfsmAlphabet  *abet_hi;    
00085     gfsmAutomaton *mfst;       
00087     gfsmLabelVector *tlabs;    
00088     gfsmAutomaton   *result;   
00089     gfsmSet         *paths;    
00090     struct _mootFSMgfsm_analyze_token_params analyze_params; 
00092   public:
00093     /*------------------------------------------------------------
00094      * public methods
00095      */
00097     mootFSMgfsm(void)
00098       : abet_lo(NULL),
00099         abet_hi(NULL),
00100         mfst(NULL),
00101         tlabs(NULL),
00102         result(NULL),
00103         paths(NULL)
00104     {
00105       analyze_params.abet=NULL;
00106       analyze_params.warn_on_undefined=TRUE;
00107       analyze_params.att_style=TRUE;
00108       analyze_params.tokp=NULL;
00109       analyze_params.gstr=g_string_new("");
00110     };
00111 
00113     ~mootFSMgfsm(void) {
00114       if (abet_lo)                       gfsm_alphabet_free(abet_lo);
00115       if (abet_hi && abet_hi != abet_lo) gfsm_alphabet_free(abet_hi);
00116       if (mfst) gfsm_automaton_free(mfst);
00117       if (tlabs) g_ptr_array_free(tlabs,TRUE);
00118       if (result) gfsm_automaton_free(result);
00119       if (paths) gfsm_set_free(paths);
00120       if (analyze_params.gstr) { g_string_free(analyze_params.gstr,TRUE); }
00121     };
00122 
00126     virtual bool load(const string &fstfile, const string &symfile="");
00127 
00129     virtual bool valid(void) const
00130     { return abet_lo && abet_hi && mfst; }
00131 
00133     virtual mootToken& analyze_token(mootToken &tok, bool want_avm=true, bool want_warnings=true);
00134 
00135   }; // class mootFSMgfsm
00136 
00137 
00138 
00139 }; // namespace mootm
00140 
00141 #endif /* defined(USE_FSM_GFSM) */
00142 
00143 
00144 #ifdef HAVE_CONFIG_H
00145 # include <mootmUnConfig.h>
00146 #endif
00147 
00148 
00149 #endif /* _moot_FSM_GFSM_H */

Generated on Fri Dec 2 18:14:56 2005 for libmootm by  doxygen 1.4.3-20050530