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

#include <map>

#include "ArtsInterfaceMatrixAggregator.hh"
#include "ArtsAggregatorMapKey.hh"

typedef map<ArtsAggregatorMapKey,ArtsInterfaceMatrixAggregator *,less<ArtsAggregatorMapKey> >  _artsInterfaceMatrixAggregatorMap_t_;

//---------------------------------------------------------------------------
//  class ArtsInterfaceMatrixAggregatorMap : public _artsInterfaceMatrixAggregatorMap_t_
//---------------------------------------------------------------------------
//  This class abstracts a collection of ArtsInterfaceMatrixAggregator
//  objects keyed by an ArtsAggregatorMapKey object.  It can be used to
//  build multiple ArtsInterfaceMatrixAggregator objects from
//  ArtsInterfaceMatrix objects.
//
//  The ArtsAggregatorMapKey class contains a router IP address
//  and an interface index.  These are the keys we need to keep data
//  separate per router interface, and should be present in the input
//  data (as host and interface attributes in Arts::Attributes()).
//
//  Once you're done loading an ArtsInterfaceMatrixAggregatorMap using Add()
//  one or more times, you can iterate over the entries and do whatever
//  you'd normally do with an ArtsInterfaceMatrixAggregator object (typically,
//  convert to an ArtsInterfaceMatrix object and write to an ofstream).  Note
//  that since an STL <map> iterator dereference returns a <pair>,
//  you'll have access to the key (an ArtsAggregatorMapKey)
//  via (*iter).first and the value (an ArtsInterfaceMatrixAggregator) via
//  (*iter).second.  Standard STL stuff...
//
//  Note we just inherit from an STL map instantiation, since we're not
//  much more than a pure <map>.
//---------------------------------------------------------------------------
class ArtsInterfaceMatrixAggregatorMap : public _artsInterfaceMatrixAggregatorMap_t_
{
public:
  //-------------------------------------------------------------------------
  //  Some typedefs to make things obvious.
  //-------------------------------------------------------------------------
  typedef _artsInterfaceMatrixAggregatorMap_t_::iterator        iterator;
  typedef _artsInterfaceMatrixAggregatorMap_t_::const_iterator  const_iterator;

  //-------------------------------------------------------------------------
  //                       void Add(const Arts & arts)
  //.........................................................................
  //  Adds the data contained in an Arts object (which should be an
  //  interface matrix object) to the aggregator map.  We use the
  //  Attributes() in the input Arts object to determine where in the
  //  map we should add the data (router and interface index).
  //-------------------------------------------------------------------------
  void Add(const Arts & arts);

  //-------------------------------------------------------------------------
  //     int AddAllFromFile(const string & fileName, bool quiet = true)
  //.........................................................................
  //  Adds the data contained in all interface matrix objects in the
  //  file named by fileName.  Returns the number of interface matrix
  //  objects added on success, -1 on failure.  If quiet is set to
  //  false, this function will print a single '.'  on stdout every time
  //  it reads an interface matrix object.
  //-------------------------------------------------------------------------
  int AddAllFromFile(const string & fileName, bool quiet = true);
  
  
};

#endif  // _ARTSINTERFACEMATRIXAGGREGATORMAP_HH_
