FSA.h

Go to the documentation of this file.
00001 // Copyright (C) 2005 Alexander Ushakov
00002 // Contents: Definition of class FSA
00003 //
00004 // Principal Authors: Alexander Ushakov
00005 //
00006 // Revision History:
00007 //
00008 
00009 #ifndef _FSA_h_
00010 #define _FSA_h_
00011 
00012 #include "FSARep.h"
00013 #include "ObjectOf.h"
00014 
00015 
00016 //---------------------------------------------------------------------------//
00017 //--------------------------------- FSA -------------------------------------//
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   //  Constructors                                       //
00032   //                                                     //
00034 public:
00035 
00036   FSA( ) : ObjectOf< FSARep >( new FSARep( ) ) { }
00037   // copy constructor supplied by compiler
00038   // destructor supplied by compiler
00039 
00040 private:
00041   
00042   FSA( const FSARep& rep ) : ObjectOf< FSARep >( new FSARep( rep ) ) { }
00043 
00044 
00045 
00047   //                                                     //
00048   //  Operators:                                         //
00049   //                                                     //
00051 public:
00052   
00053   FSA operator * ( const FSA& F ) const;
00054   bool operator== ( const FSA& F ) const; // "complete" equality
00055 
00057   //                                                     //
00058   //  Subgroup graph functions:                          //
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   //  Adding and removing elements                       //
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   //  Initial and terminal states:                       //
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Mon Sep 26 18:43:45 2011 for CRyptography And Groups (CRAG) by  doxygen 1.6.1