Worklist.hpp

Go to the documentation of this file.
00001 #ifndef wali_WORKLIST_GUARD
00002 #define wali_WORKLIST_GUARD 1
00003 
00004 /*!
00005  * @author Nicholas Kidd
00006  */
00007 
00008 #include "wali/Common.hpp"
00009 #include "wali/Countable.hpp"
00010 
00011 namespace wali
00012 {
00013 
00014   /*! @class Worklist
00015    *
00016    * Worklist defines the interface of a worklist. All items must subclass
00017    * wali::Markable. When an item is placed on a worklist, the worklist
00018    * treats the item's "marked" state as only being modified by the worklist
00019    * (i.e., do not place a Markable item on two worklists at the same time).
00020    */
00021 
00022   template< typename T > class Worklist : public Countable
00023   {
00024 
00025     public:
00026 
00027       Worklist() {}
00028 
00029       virtual ~Worklist() {}
00030 
00031       /*!
00032        * put
00033        *
00034        * Put a Trans * in the Worklist.
00035        * This method should be idempotent but
00036        * it really does not matter.
00037        *
00038        * @return true if the item was added, false if not
00039        * A false return value means the item was already "marked"
00040        * and hence, is already on this worklist.
00041        */
00042       virtual bool put( T *item ) = 0;
00043 
00044       /*!
00045        * get
00046        *
00047        * Return an item from the worklist.
00048        * Guaranteed only to be called if 
00049        * Worklist is not empty. May throw an exception or return 
00050        * NULL if the worklist is not empty.
00051        *
00052        * @return Trans *
00053        */
00054       virtual T * get() = 0;
00055 
00056       /*!
00057        * emtpy
00058        *
00059        * @return true if the Worklist is empty
00060        */
00061       virtual bool empty() const = 0;
00062 
00063       /*!
00064        * clear
00065        *
00066        * Remove and unmark each item in this worklist.
00067        */
00068       virtual void clear() = 0;
00069 
00070     protected:
00071 
00072   }; // class Worklist
00073 
00074 } // namespace wali
00075 
00076 #endif // wali_WORKLIST_GUARD
00077