/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2015,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NFD_DAEMON_FACE_FACE_COUNTERS_HPP
#define NFD_DAEMON_FACE_FACE_COUNTERS_HPP

#include "link-service.hpp"
#include "transport.hpp"

namespace nfd {

class OldFaceCounters;

namespace face {

/** \brief gives access to counters provided by Face
 *
 *  This type is a facade that exposes common counters of a Face.
 *
 *  get<T>() can be used to access extended counters provided by
 *  LinkService or Transport of the Face.
 */
class FaceCounters
{
public:
  FaceCounters(const LinkService::Counters& linkServiceCounters,
               const Transport::Counters& transportCounters);

  /** \brief wraps old counters
   *
   *  FaceCounters instance created from this constructor only provides Interest/Data counters
   *  and Nack counters. Other counters are always zero. get<T>() should not be used.
   */
  explicit
  FaceCounters(const OldFaceCounters& oldCounters);

  /** \return counters provided by LinkService
   *  \tparam T LinkService counters type
   *  \throw std::bad_cast counters type mismatch
   */
  template<typename T>
  typename std::enable_if<std::is_base_of<LinkService::Counters, T>::value, const T&>::type
  get() const
  {
    return dynamic_cast<const T&>(m_linkServiceCounters);
  }

  /** \return counters provided by Transport
   *  \tparam T Transport counters type
   *  \throw std::bad_cast counters type mismatch
   */
  template<typename T>
  typename std::enable_if<std::is_base_of<Transport::Counters, T>::value, const T&>::type
  get() const
  {
    return dynamic_cast<const T&>(m_transportCounters);
  }

public:
  const PacketCounter& nInInterests;
  const PacketCounter& nOutInterests;
  const PacketCounter& nInData;
  const PacketCounter& nOutData;
  const PacketCounter& nInNacks;
  const PacketCounter& nOutNacks;

  const PacketCounter& nInPackets;
  const PacketCounter& nOutPackets;
  const ByteCounter& nInBytes;
  const ByteCounter& nOutBytes;

private:
  const LinkService::Counters& m_linkServiceCounters;
  const Transport::Counters& m_transportCounters;
};

} // namespace face
} // namespace nfd

#endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP
