KeySource.hpp

Go to the documentation of this file.
00001 #ifndef wali_KEY_SOURCE_GUARD
00002 #define wali_KEY_SOURCE_GUARD 1
00003 
00004 /**
00005  * @author Nicholas Kidd
00006  */
00007 
00008 #include "wali/Common.hpp"
00009 #include "wali/Countable.hpp"
00010 #include "wali/Printable.hpp"
00011 #include "wali/hm_hash.hpp"
00012 
00013 namespace wali
00014 {
00015   /**
00016    * @class KeySource
00017    */
00018   class KeySource : public Printable, public Countable
00019   {
00020   public:
00021     KeySource() {}
00022     
00023     virtual ~KeySource() {}
00024     
00025     virtual bool equal( KeySource* rhs ) = 0;
00026     
00027     virtual size_t hash() const = 0;
00028     
00029     virtual std::ostream& print( std::ostream& o ) const = 0;
00030     
00031   protected:
00032     
00033   }; // class KeySource
00034 
00035   template<> struct hm_hash< key_src_t >
00036   {
00037     size_t operator()( key_src_t ksrc ) const
00038     {
00039       return ksrc->hash();
00040     }
00041   };
00042 
00043   template<> struct hm_equal< key_src_t >
00044   {
00045     bool operator()( key_src_t lhs, key_src_t rhs ) const
00046     {
00047       return lhs->equal(rhs.get_ptr());
00048     }
00049   };
00050 
00051 }; // namespace wali
00052 
00053 #endif // wali_KEY_SOURCE_GUARD
00054