text: /*!
   * @author Nicholas Kidd
   */
  
  #include "wali/Common.hpp"
  #include "wali/KeyPairSource.hpp"
  
  namespace wali
  {
    KeyPairSource::KeyPairSource( Key k1, Key k2 ) : kp(k1,k2) {}
  
    KeyPairSource::KeyPairSource( const KeyPair& kp_ ) : kp(kp_) {}
  
    KeyPairSource::~KeyPairSource() {}
  
    bool KeyPairSource::equal( KeySource* rhs )
    {
      static wali::hm_equal< KeyPair > checker;
      KeyPairSource *kpsrc = dynamic_cast< KeyPairSource* >(rhs);
      if( 0 != kpsrc )
        return checker(kp,kpsrc->kp);
      else
        return false;
    }
  
    size_t KeyPairSource::hash() const
    {
      static wali::hm_hash< KeyPair > hasher;
      return hasher(kp);
    }
  
    std::ostream& KeyPairSource::print( std::ostream& o ) const
    {
      o << "(";
      printKey(o,kp.first);
      o << ",";
      printKey(o,kp.second);
      o << ")";
      return o;
    }
  
    const KeyPair& KeyPairSource::get_key_pair() const
    {
      return kp;
    }
  
    Key KeyPairSource::first() const
    {
      return kp.first;
    }
  
    Key KeyPairSource::second() const
    {
      return kp.second;
    }
  
    Key KeyPairSource::get_first(Key k)
    {
      key_src_t ks = getKeySource(k);
      KeyPairSource const * kps = dynamic_cast<KeyPairSource const *>(ks.get_ptr());
      if (kps == NULL) {
          std::cerr << "Key not a key pair: " << k << " " << key2str(k) << "\n";
          fast_assert(false && "Key not a key pair");
          return 0;
      }
      return kps->first();
    }
  
    Key KeyPairSource::get_second(Key k)
    {
      key_src_t ks = getKeySource(k);
      KeyPairSource const * kps = dynamic_cast<KeyPairSource const *>(ks.get_ptr());
      fast_assert(kps != NULL);
      if (kps == NULL)
          return 0;
      return kps->second();
    }
  
  } // namespace wali
  
  