#ifndef CCNX_TUNNEL_H
#define CCNX_TUNNEL_H

#include <boost/variant.hpp>

#include "ccnx-common.h"
#include "ccnx-wrapper.h"

#define _OVERRIDE
#ifdef __GNUC__
#if __GNUC_MAJOR >= 4 && __GNUC_MINOR__ >= 7
  #undef _OVERRIDE
  #define _OVERRIDE override
#endif // __GNUC__ version
#endif // __GNUC__

using namespace std;

// Eventually, Sync::CcnxWrapper should be moved to this namespace.
// It has nothing to do with Sync.
namespace Ccnx
{

class CcnxTunnel : public CcnxWrapper
{
public:
  typedef multimap<string, InterestCallback> RegisteredInterestTable;
  typedef multimap<string, InterestCallback>::iterator RitIter;


  CcnxTunnel();
  virtual ~CcnxTunnel();

  // name is topology-independent
  virtual int
  publishData(const string &name, const unsigned char *buf, size_t len, int freshness) _OVERRIDE;

  int
  publishContentObject(const string &name, const Bytes &contentObject, int freshness);

  virtual int
  sendInterest (const string &interest, Closure *closure);


  // prefix is topology-independent
  virtual int
  setInterestFilter(const string &prefix, const InterestCallback &interestCallback) _OVERRIDE;

  // prefix is topology-independent
  // this clears all entries with key equal to prefix
  virtual void
  clearInterestFilter(const string &prefix) _OVERRIDE;

  // subclass should provide translation service from topology-independent name
  // to routable name
  virtual string
  queryRoutableName(const string &name) = 0;

  // subclass should implement the function to store ContentObject with topoloy-independent
  // name to the permanent storage; default does nothing
  virtual void
  storeContentObject(const string &name, const Bytes &content) {}

  // should be called  when connect to a different network
  void
  refreshLocalPrefix();

  static bool
  isPrefix(const string &prefix, const string &name);

  void
  handleTunneledInterest(const string &tunneldInterest);

  void
  handleTunneledData(const string &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback);

protected:
  // need a way to update local prefix, perhaps using macports trick, but eventually we need something more portable
  string m_localPrefix;
  RegisteredInterestTable m_rit;
  Lock m_ritLock;
};

class TunnelClosure : public Closure
{
public:
  TunnelClosure(int retry, const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback, CcnxTunnel *tunnel, const string &originalInterest);

  TunnelClosure(const Closure *closure, CcnxTunnel *tunnel, const string &originalInterest);

  virtual void
  runDataCallback(const string &name, const Bytes &content) _OVERRIDE;

  virtual TimeoutCallbackReturnValue
  runTimeoutCallback(const string &interest) _OVERRIDE;

private:
  CcnxTunnel *m_tunnel;
  string m_originalInterest;
};

};

#endif
