/* -*- 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_LP_FACE_WRAPPER_HPP
#define NFD_DAEMON_FACE_LP_FACE_WRAPPER_HPP

#include "common.hpp"
#include "face.hpp"
#include "lp-face.hpp"

namespace nfd {
namespace face {

/** \brief an adaptor to provide old Face APIs from an LpFace
 *  \sa LpFace
 */
class LpFaceWrapper : public Face
{
public:
  explicit
  LpFaceWrapper(unique_ptr<LpFace> face);

  LpFace*
  getLpFace();

  virtual void
  sendInterest(const Interest& interest) DECL_OVERRIDE;

  virtual void
  sendData(const Data& data) DECL_OVERRIDE;

  virtual void
  sendNack(const lp::Nack& nack) DECL_OVERRIDE;

  virtual void
  close() DECL_OVERRIDE;

  virtual bool
  isUp() const DECL_OVERRIDE;

  virtual void
  setPersistency(ndn::nfd::FacePersistency persistency) DECL_OVERRIDE;

  virtual const FaceCounters&
  getCounters() const DECL_OVERRIDE;

protected:
  virtual void
  setId(nfd::FaceId faceId) DECL_OVERRIDE;

private:
  void
  dispatchInterest(const Interest& interest);

  void
  dispatchData(const Data& data);

  void
  dispatchNack(const lp::Nack& nack);

  void
  handleStateChange(FaceState oldState, FaceState newState);

private:
  unique_ptr<LpFace> m_face;
};

inline LpFace*
LpFaceWrapper::getLpFace()
{
  return m_face.get();
}

inline void
LpFaceWrapper::sendInterest(const Interest& interest)
{
  this->emitSignal(onSendInterest, interest);
  m_face->sendInterest(interest);
}

inline void
LpFaceWrapper::sendData(const Data& data)
{
  this->emitSignal(onSendData, data);
  m_face->sendData(data);
}

inline void
LpFaceWrapper::sendNack(const lp::Nack& nack)
{
  this->emitSignal(onSendNack, nack);
  m_face->sendNack(nack);
}

inline void
LpFaceWrapper::close()
{
  m_face->close();
}

inline bool
LpFaceWrapper::isUp() const
{
  return m_face->getState() == FaceState::UP;
}

inline const FaceCounters&
LpFaceWrapper::getCounters() const
{
  return m_face->getCounters();
}

} // namespace face
} // namespace nfd

#endif // NFD_DAEMON_FACE_LP_FACE_WRAPPER_HPP
