//===========================================================================
//  @(#) $Name: arts++-1-1-a8 $
//  @(#) $Id: ArtsNextHopTableAggregator.hh,v 1.5 2000/10/02 17:05:17 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 _ARTSNEXTHOPTABLEAGGREGATOR_HH_
#define _ARTSNEXTHOPTABLEAGGREGATOR_HH_

#include <map>
#include <vector>

#include "ArtsNextHopTable.hh"

//---------------------------------------------------------------------------
//  class ArtsNextHopTableAggregator
//---------------------------------------------------------------------------
//!  This class is used to aggregate NextHop table objects in the time
//!  domain.
//---------------------------------------------------------------------------
class ArtsNextHopTableAggregator
{
public:
  //--------------------------------------------------------------------------
  //!  Holds a packet and byte counter.
  //--------------------------------------------------------------------------
  typedef struct {
    uint64_t  Pkts;
    uint64_t  Bytes;
  } counter_t;
  
  //-------------------------------------------------------------------------
  //               ArtsNextHopTableAggregator(const Arts & arts)
  //.........................................................................
  //!  Construct from an Arts object.  \c arts must be a nexthop table
  //!  object.
  //-------------------------------------------------------------------------
  ArtsNextHopTableAggregator(const Arts & arts);
  
  //-------------------------------------------------------------------------
  //                       void Add(const Arts & arts)
  //.........................................................................
  //!  Add the contents of an Arts object.  The input Arts object must be
  //!  a nexthop table object.  Adds any new nexthop entries in \c arts
  //!  and adds to the counters for existing nexthop entries.
  //-------------------------------------------------------------------------
  void Add(const Arts & arts);
  
  //-------------------------------------------------------------------------
  //              ArtsNextHopTable *ConvertToArtsNextHopTable() const
  //.........................................................................
  //!  Returna an ArtsNextHopTable object (dynamically allocated)
  //!  containing the aggregate data.  The caller is responsible for
  //!  calling delete() on the returned ArtsNetMatrix pointer.
  //-------------------------------------------------------------------------
  ArtsNextHopTable *ConvertToArtsNextHopTable() const;
  
private:
  ArtsHeader                                     _header;
  vector<ArtsAttribute>                          _attributes;
  map<ipv4addr_t,counter_t,less<ipv4addr_t> >    _NextHopCounters;
  
};

#endif  // _ARTSNEXTHOPTABLEAGGREGATOR_HH_
