Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

dfa_profile.hh

Go to the documentation of this file.
00001 /*
00002  *  File:       dfa_profile.hh
00003  *              $Id: dfa_profile.hh,v 1.1 2002/06/23 23:42:39 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: dfa_profile.hh,v $
00012  *  Revision 1.1  2002/06/23 23:42:39  alec
00013  *  profiling based optimization added
00014  *
00015  */
00016 
00017 
00018 /* 
00019   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00020 
00021   This program is free software; you can redistribute it and/or modify
00022   it under the terms of the GNU General Public License as published by
00023   the Free Software Foundation; either version 2 of the License, or
00024   (at your option) any later version.
00025 
00026   This program is distributed in the hope that it will be useful,
00027   but WITHOUT ANY WARRANTY; without even the implied warranty of
00028   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00029   GNU General Public License for more details.
00030 
00031   You should have received a copy of the GNU General Public License
00032   along with this program; if not, write to the Free Software
00033   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00034 
00035  */
00036 
00037 #ifndef __DFA_PROFILE_HH__
00038 #define __DFA_PROFILE_HH__
00039 
00040 #include <vector>
00041 
00042 #include "debug.h"
00043 #include "scanner_dfa_spec.hh"
00044 #include "basic_dfa_spec.hh"
00045 
00046 class DfaStateProfile
00047 {
00048 public:
00049 
00050   DfaStateProfile (BasicDfaSpec::State &s);
00051 
00052   bool read (istream &is);
00053 
00054   void reset ();
00055   
00056   unsigned long int operator [] (int i)
00057   {
00058     ASSERT((0 <= i) && (i <= size()),
00059            "Bad index in DfaStateProfile::operator []")
00060     return freqs[i];
00061   }
00062 
00063   int size()
00064   {
00065     return freqs.size();
00066   }
00067   
00068 private:
00069   
00070   vector<unsigned long int> freqs;
00071 };
00072 
00073 class BasicDfaProfile
00074 {
00075 public:
00076 
00077   BasicDfaProfile (BasicDfaSpec &dfa);
00078 
00079   bool read (istream &is);
00080 
00081   void reset ();
00082   
00083   DfaStateProfile& operator [] (int i)
00084   {
00085     ASSERT((0 <= i) && (i <= size()),
00086            "Bad index in BasicDfaProfile::operator []")
00087     return stateProfiles[i];
00088   }
00089 
00090   int size () const
00091   {
00092     return stateProfiles.size();
00093   }
00094 
00095 private:
00096   
00097   vector<DfaStateProfile> stateProfiles;
00098 };
00099 
00100 class ScannerDfaProfile
00101 {
00102 public:
00103 
00104   ScannerDfaProfile (ScannerDfaSpec &dfa);
00105 
00106   bool read (istream &is);
00107 
00108   void reset ();
00109   
00110   BasicDfaProfile& operator [] (int i)
00111   {
00112     ASSERT((0 <= i) && (i <= size()),
00113            "Bad index in ScannerDfaProfile::operator []")
00114     return dfaProfiles[i];
00115   }
00116 
00117   int size() const
00118   {
00119     return dfaProfiles.size();
00120   }
00121   
00122   vector<BasicDfaProfile> dfaProfiles;
00123 };
00124 
00125 
00126 #endif /* #ifndef __DFA_PROFILE_HH__ */

Generated at Tue Jul 9 21:05:43 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001