/* -*- 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
