FSA.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _FSA_h_
00010 #define _FSA_h_
00011
00012 #include "FSARep.h"
00013 #include "ObjectOf.h"
00014
00015
00016
00017
00018
00019
00020
00021 class FSA : public ObjectOf< FSARep >
00022 {
00023 public:
00024
00025 typedef FSAState state_type;
00026 typedef FSAState::edge_type edge_type;
00027
00028
00030
00031
00032
00034 public:
00035
00036 FSA( ) : ObjectOf< FSARep >( new FSARep( ) ) { }
00037
00038
00039
00040 private:
00041
00042 FSA( const FSARep& rep ) : ObjectOf< FSARep >( new FSARep( rep ) ) { }
00043
00044
00045
00047
00048
00049
00051 public:
00052
00053 FSA operator * ( const FSA& F ) const;
00054 bool operator== ( const FSA& F ) const;
00055
00057
00058
00059
00061 public:
00062
00063
00064 void fold( const set< int >* candidates = NULL , list< FoldDetails >* details = NULL ) {
00065 change( ) -> fold( candidates , details );
00066 }
00067 void pinch( int state1 , int state2 ) { change( ) -> pinch( state1 , state2 ); }
00068
00069 void unfold( const list< FoldDetails >& details ) { change( ) -> unfold( details ); }
00070 void liftup( const list< FoldDetails >& details , list< FSAEdge >& path , int init_state ) { change( ) -> liftup( details , path , init_state ); }
00071
00072 bool isDeterministic( ) const;
00073 FSA deterministic( ) const;
00074
00076
00077
00078
00080
00081 public:
00082 int newState( ) { return change( ) -> newState( ); }
00083 void eraseState( int state ) { change( ) -> eraseState( state ); }
00084 void newEdge( int state1 , int state2 , int label ) { change( ) -> newEdge( state1 , state2 , label ); }
00085 void eraseEdge( int state1 , int state2 , int label ) { change( ) -> eraseEdge( state1 , state2 , label ); }
00086
00087 template< class ConstIntIterator > void addLoop( int vert , ConstIntIterator F , ConstIntIterator L )
00088 { change( )->addLoop( vert , F , L ); }
00089 template< class ConstIntIterator > void addRay ( int vert , ConstIntIterator F , ConstIntIterator L )
00090 { change( )->addRay ( vert , F , L ); }
00091 void addFSA ( int vert1 , int vert2 , const FSA& fsa ) { change( )->addFSA( vert1 , vert2 , *fsa.look( ) ); }
00092
00093 const map< int , FSAState >& getStates( ) const { return look()->getStates( ); }
00094 map< int , FSAState >& getStates( ) { return change()->getStates( ); }
00095
00097
00098
00099
00101 public:
00102
00103
00104 void makeInitial ( int s ) { change( ) -> makeInitial( s ); }
00105 void makeTerminal ( int s ) { change( ) -> makeTerminal( s ); }
00106 void makeNonInitial ( int s ) { change( ) -> makeNonInitial( s ); }
00107 void makeNonTerminal( int s ) { change( ) -> makeNonTerminal( s ); }
00108 const set< int >& getInitStates( ) const { return look( ) -> getInitStates( ); }
00109 const set< int >& getTermStates( ) const { return look( ) -> getTermStates( ); }
00110
00111
00112 };
00113
00114
00115 ostream& operator << ( ostream& os , const FSA& g );
00116
00117
00118 #endif