00001 #ifndef wali_wfa_TRANSSET_GUARD 00002 #define wali_wfa_TRANSSET_GUARD 1 00003 00004 /*! 00005 * @author Nicholas Kidd 00006 */ 00007 00008 #include "wali/Common.hpp" 00009 #include "wali/Printable.hpp" 00010 #include "wali/wfa/ITrans.hpp" 00011 00012 #define IMPL_LIST 0 00013 00014 #if IMPL_LIST 00015 # include <list> 00016 #else 00017 # include <set> 00018 #endif 00019 00020 00021 namespace wali 00022 { 00023 namespace wfa 00024 { 00025 class TransFunctor; 00026 class ConstTransFunctor; 00027 00028 /*! 00029 * @class TransSet 00030 * 00031 * This class basically wraps the std::set implementation 00032 * to provide a "wali::Key friendly" interface. 00033 */ 00034 class TransSet : public Printable 00035 { 00036 public: 00037 #if IMPL_LIST 00038 typedef std::list< ITrans* > impl_t; 00039 #else 00040 typedef std::set< ITrans*,ITransLT > impl_t; 00041 #endif 00042 typedef impl_t::iterator iterator; 00043 typedef impl_t::const_iterator const_iterator; 00044 00045 public: 00046 TransSet() {} 00047 00048 ~TransSet() {} 00049 00050 public: 00051 ITrans* erase( ITrans* t ); 00052 00053 ITrans* erase( Key from, Key stack, Key to ); 00054 00055 iterator find( Key from, Key stack, Key to ); 00056 00057 iterator find( ITrans* t ); 00058 00059 const_iterator find( Key from, Key stack, Key to ) const; 00060 00061 const_iterator find( ITrans* t ) const; 00062 00063 void each( TransFunctor& tf ); 00064 00065 void each( ConstTransFunctor& tf ) const; 00066 00067 bool insert( ITrans* t ); 00068 00069 std::ostream& print( std::ostream& o ) const; 00070 00071 void erase( iterator it ) { 00072 impl.erase( it ); 00073 } 00074 00075 void clear() { 00076 impl.clear(); 00077 } 00078 00079 bool empty() const { 00080 return impl.empty(); 00081 } 00082 00083 void clearAndReleaseResources() { 00084 impl_t tmp; 00085 tmp.swap(impl); 00086 } 00087 00088 iterator begin() { 00089 return impl.begin(); 00090 } 00091 00092 iterator end() { 00093 return impl.end(); 00094 } 00095 00096 const_iterator begin() const { 00097 return impl.begin(); 00098 } 00099 00100 const_iterator end() const { 00101 return impl.end(); 00102 } 00103 00104 size_t size() const; 00105 00106 protected: 00107 impl_t impl; 00108 00109 }; // class TransSet 00110 00111 } // namespace wfa 00112 00113 } // namespace wali 00114 00115 #endif // wali_wfa_TRANSSET_GUARD 00116