/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2016 Regents of the University of California.
*
* This file is part of the nTorrent codebase.
*
* nTorrent is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* nTorrent 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 Lesser General Public License for more details.
*
* You should have received copies of the GNU General Public License and GNU Lesser
* General Public License along with nTorrent, e.g., in COPYING.md file. If not, see
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS for complete list of nTorrent authors and contributors.
*/

#ifndef SEQUENTIAL_DATA_FETCHER_HPP
#define SEQUENTIAL_DATA_FETCHER_HPP

#include "fetching-strategy-manager.hpp"
#include "torrent-manager.hpp"

#include <ndn-cxx/name.hpp>

namespace ndn {
namespace ntorrent {

class SequentialDataFetcher : FetchingStrategyManager {
  public:
    class Error : public std::runtime_error
	  {
  	public:
  	  explicit
  	  Error(const std::string& what)
  	    : std::runtime_error(what)
  	  {
  	  }
  	};
    /**
     * @brief Create a new SequentialDataFetcher
     * @param torrentFileName The name of the torrent file
     * @param dataPath The path that the manager would look for already stored data packets and
     *                 will write new data packets
     */
    SequentialDataFetcher(const ndn::Name&   torrentFileName,
                          const std::string& dataPath,
                          bool               seed =  true);

    ~SequentialDataFetcher();

    /**
     * @brief Start the sequential data fetcher
     */
    void
    start(const time::milliseconds& timeout = time::milliseconds::zero());

    /**
     * @brief Pause the sequential data fetcher
     */
    void
    pause();

    /**
     * @brief Resume the sequential data fetcher
     */
    void
    resume();

  protected:
    void
    downloadTorrentFile();

    void
    downloadManifestFiles(const std::vector<ndn::Name>& manifestsName);

    void
    downloadPackets(const std::vector<ndn::Name>& packetsName);

    void
    implementSequentialLogic();

    virtual void
    onDataPacketReceived(const ndn::Data& data);

    virtual void
    onDataRetrievalFailure(const ndn::Interest& interest, const std::string& errorCode);

    virtual void
    onManifestReceived(const std::vector<Name>& packetNames);

    virtual void
    onTorrentFileSegmentReceived(const std::vector<Name>& manifestNames);

  private:
    std::string m_dataPath;
    ndn::Name m_torrentFileName;
    shared_ptr<TorrentManager> m_manager;
    bool m_seedFlag;
};

} // namespace ntorrent
} // namespace ndn

#endif // SEQUENTIAL_DATA_FETCHER_HPP
