/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
 * Copyright (C) 2013 Regents of the University of California.
 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
 * See COPYING for copyright and distribution information.
 */

#ifndef NDN_TRANSPORT_HPP
#define NDN_TRANSPORT_HPP

#include "common.hpp"

#include <vector>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>

namespace ndn {

class Transport {
public:
  struct Error : public std::runtime_error { inline Error(const boost::system::error_code &code, const std::string &msg); };
  
  typedef ptr_lib::function<void (const Block &wire)> ReceiveCallback;
  typedef ptr_lib::function<void ()> ErrorCallback;
  
  inline
  Transport();
  
  inline virtual
  ~Transport();

  /**
   * Connect transport
   *
   * @throws If connection cannot be established
   */
  inline virtual void 
  connect(boost::asio::io_service &io_service,
          const ReceiveCallback &receiveCallback);
  
  /**
   * Close the connection.
   */
  virtual void 
  close() = 0;

  /**
   * Set data to the host
   * @param data A pointer to the buffer of data to send.
   * @param dataLength The number of bytes in data.
   */
  virtual void 
  send(const Block &wire) = 0;

  inline bool 
  isConnected();

protected:
  inline void
  receive(const Block &wire);
  
protected:
  boost::asio::io_service *ioService_;
  bool isConnected_;
  ReceiveCallback receiveCallback_;
};

inline
Transport::Transport()
  : ioService_(0)
  , isConnected_(false)
{
}

inline Transport::Error::Error(const boost::system::error_code &code, const std::string &msg)
  : std::runtime_error(msg + (code.value() ? " (" + code.category().message(code.value()) + ")" : ""))
{
}

inline
Transport::~Transport()
{
}

inline void 
Transport::connect(boost::asio::io_service &ioService,
                   const ReceiveCallback &receiveCallback)
{
  ioService_ = &ioService;
  receiveCallback_ = receiveCallback;
}

inline bool 
Transport::isConnected()
{
  return isConnected_;
}

inline void
Transport::receive(const Block &wire)
{
  receiveCallback_(wire);
}

}

#endif
