/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (C) 2014 Named Data Networking Project
 * See COPYING for copyright and distribution information.
 */

#ifndef NFD_TABLE_PIT_ENTRY_HPP
#define NFD_TABLE_PIT_ENTRY_HPP

#include "pit-in-record.hpp"
#include "pit-out-record.hpp"

namespace nfd {
namespace pit {

/** \class InRecordCollection
 *  \brief represents an unordered collection of InRecords
 */
typedef std::list< InRecord>  InRecordCollection;

/** \class OutRecordCollection
 *  \brief represents an unordered collection of OutRecords
 */
typedef std::list<OutRecord> OutRecordCollection;

/** \class Entry
 *  \brief represents a PIT entry
 */
class Entry : noncopyable
{
public:
  explicit
  Entry(const Interest& interest);
  
  const Interest&
  getInterest() const;
  
  /** \return{ Interest Name }
   */
  const Name&
  getName() const;
  
  const InRecordCollection&
  getInRecords() const;
  
  const OutRecordCollection&
  getOutRecords() const;
  
  /** \brief determines whether nonce is seen before
   *         in an incoming or outgoing Interest
   */
  bool
  isNonceSeen(uint32_t nonce) const;
  
  /** \brief inserts a InRecord for face, and updates it with interest
   *  If InRecord for face exists, the existing one is updated.
   *  \return{ an iterator to the InRecord }
   */
  InRecordCollection::iterator
  insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest);
  
  /// deletes all InRecords
  void
  deleteInRecords();
  
  /** \brief inserts a OutRecord for face, and updates it with interest
   *  If OutRecord for face exists, the existing one is updated.
   *  \return{ an iterator to the OutRecord }
   */
  OutRecordCollection::iterator
  insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
  
  /// deletes one OutRecord for face if exists
  void
  deleteOutRecord(shared_ptr<Face> face);

private:
  std::set<uint32_t> m_nonces;
  const Interest m_interest;
  InRecordCollection m_inRecords;
  OutRecordCollection m_outRecords;
};

inline const Interest&
Entry::getInterest() const
{
  return m_interest;
}

} // namespace pit
} // namespace nfd

#endif // NFD_TABLE_PIT_ENTRY_HPP
