#ifndef CCNX_WRAPPER_H
#define CCNX_WRAPPER_H

#include <boost/thread/locks.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>

#include "ccnx-common.h"
#include "ccnx-name.h"
#include "ccnx-closure.h"

using namespace std;

namespace Ccnx {

struct CcnxOperationException : virtual boost::exception, virtual exception { };

class CcnxWrapper
{
public:
  typedef boost::shared_mutex Lock;
  typedef boost::unique_lock<Lock> WriteLock;
  typedef boost::shared_lock<Lock> ReadLock;

  typedef boost::recursive_mutex RecLock;
  typedef boost::unique_lock<RecLock> UniqueRecLock;

  typedef boost::function<void (const string &)> InterestCallback;

  CcnxWrapper();
  virtual ~CcnxWrapper();

  virtual int
  setInterestFilter (const string &prefix, const InterestCallback &interestCallback);

  virtual void
  clearInterestFilter (const string &prefix);

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

  virtual int
  publishData (const string &name, const unsigned char *buf, size_t len, int freshness);

  int
  publishData (const string &name, const Bytes &content, int freshness);

  static string
  getLocalPrefix ();

  static string
  extractName(const unsigned char *data, const ccn_indexbuf *comps);

protected:
  Bytes
  createContentObject(const string &name, const unsigned char *buf, size_t len, int freshness);

  int
  putToCcnd (const Bytes &contentObject);

protected:
  void
  connectCcnd();

  /// @cond include_hidden
  void
  createKeyLocator ();

  void
  initKeyStore ();

  const ccn_pkey *
  getPrivateKey ();

  const unsigned char *
  getPublicKeyDigest ();

  ssize_t
  getPublicKeyDigestLength ();

  void
  ccnLoop ();

  /// @endcond

protected:
  ccn* m_handle;
  ccn_keystore *m_keyStore;
  ccn_charbuf *m_keyLoactor;
  // to lock, use "boost::recursive_mutex::scoped_lock scoped_lock(mutex);
  RecLock m_mutex;
  boost::thread m_thread;
  bool m_running;
  bool m_connected;
  map<string, InterestCallback> m_registeredInterests;
  // std::list< std::pair<std::string, InterestCallback> > m_registeredInterests;
};

typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;


} // Ccnx

#endif
