/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  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::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);

  /** \return counters provided by LinkService
   *  \tparam T LinkService counters type
   *  \throw std::bad_cast counters type mismatch
   */
  template<typename T>
  std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&>
  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>
  std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&>
  get() const
  {
    return dynamic_cast<const T&>(m_transportCounters);
  }

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

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

  /** \brief Count of incoming Interests dropped due to HopLimit == 0.
   */
  PacketCounter nInHopLimitZero;

  /** \brief Count of outgoing Interests dropped due to HopLimit == 0 on non-local faces.
   */
  PacketCounter nOutHopLimitZero;

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

} // namespace nfd::face

#endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP
