//===========================================================================
//  $Name: arts++-1-1-a8 $
//  $Id: ArtsAggregatorMapKey.hh,v 1.5 2000/10/02 17:05:14 dwm Exp $
//===========================================================================
//  Copyright Notice
//
//  By accessing this software, arts++, you are duly informed
//  of and agree to be bound by the conditions described below in this
//  notice:
//
//  This software product, arts++, is developed by Daniel W. McRobb, and
//  copyrighted(C) 1998 by the University of California, San Diego
//  (UCSD), with all rights reserved.  UCSD administers the CAIDA grant,
//  NCR-9711092, under which part of this code was developed.
//
//  There is no charge for arts++ software.  You can redistribute it
//  and/or modify it under the terms of the GNU Lesser General Public
//  License, Version 2.1, February 1999, which is incorporated by
//  reference herein.
//
//  arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF
//  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use
//  of it will not infringe on any third party's intellectual
//  property rights.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with arts++.  Copies can also be obtained from:
//
//    http://www.gnu.org/copyleft/lesser.html
//
//  or by writing to:
//
//  Free Software Foundation, Inc.
//  59 Temple Place, Suite 330
//  Boston, MA 02111-1307
//  USA
//
//  Or contact:
//
//    info@caida.org
//===========================================================================

#ifndef _ARTSAGGREGATORMAPKEY_HH_
#define _ARTSAGGREGATORMAPKEY_HH_

extern "C" {
#include "caida_t.h"
}

//---------------------------------------------------------------------------
//  class ArtsAggregatorMapKey
//---------------------------------------------------------------------------
//!  This class is used as a key in the Arts*AggregatorMap classes,
//!  which are STL <map> classes.  We use both a router IP address and
//!  interface index in ArtsAggregatorMapKey, so that we may
//!  key on a per-router-interface basis (and hence aggregate data
//!  separately per router interface).
//---------------------------------------------------------------------------
class ArtsAggregatorMapKey
{
public:
  //-------------------------------------------------------------------------
  //                     inline ipv4addr_t Router() const                    
  //.........................................................................
  //!  Returns the router IP address in the key.
  //-------------------------------------------------------------------------
  inline ipv4addr_t Router() const
  {
    return(this->_router);
  }
  
  //-------------------------------------------------------------------------
  //                   ipv4addr_t Router(ipv4addr_t router)                  
  //.........................................................................
  //!  Sets and returns the router IP address in the key.
  //-------------------------------------------------------------------------
  ipv4addr_t Router(ipv4addr_t router)
  {
    this->_router = router;
    return(this->_router);
  }
  
  //-------------------------------------------------------------------------
  //                         uint16_t IfIndex() const                        
  //.........................................................................
  //!  Returns the interface index in the key.
  //-------------------------------------------------------------------------
  uint16_t IfIndex() const
  {
    return(this->_ifIndex);
  }
  
  //-------------------------------------------------------------------------
  //                    uint16_t IfIndex(uint16_t ifIndex)                   
  //.........................................................................
  //!  Sets and returns the interface index in the key.
  //-------------------------------------------------------------------------
  uint16_t IfIndex(uint16_t ifIndex)
  {
    this->_ifIndex = ifIndex;
    return(this->_ifIndex);
  }

  //-------------------------------------------------------------------------
  // inline bool operator < (const ArtsAggregatorMapKey & key) const 
  //.........................................................................
  //!  Used by less<ArtsAggregatorMapKey> when used as a key in
  //!  an ArtsAsMatrixAggregatorMap (for ordering).
  //-------------------------------------------------------------------------
  inline bool operator < (const ArtsAggregatorMapKey & key) const
  {
    if (this->_router < key.Router())
      return(true);
    if (this->_router > key.Router())
      return(false);

    if (this->_ifIndex < key.IfIndex())
      return(true);

    return(false);
  }
  
private:
  ipv4addr_t  _router;
  uint16_t    _ifIndex;
};

#endif  // _ARTSAGGREGATORMAPKEY_HH_
