/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         Chaoyi Bian <bcy@pku.edu.cn>
 *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#ifndef SYNC_CCNX_WRAPPER_H
#define SYNC_CCNX_WRAPPER_H

#include <boost/exception/all.hpp>
#include <boost/function.hpp>
#include <string>

#include <ns3/ptr.h>
#include <ns3/node.h>
#include <ns3/random-variable.h>
#include <ns3/ccnx-app.h>
#include <ns3/ccnx-name-components.h>
#include <ns3/hash-helper.h>

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>

/**
 * \defgroup sync SYNC protocol
 *
 * Implementation of SYNC protocol
 */
namespace Sync {

template<class Callback>
struct CcnxFilterEntry
{
public:
  CcnxFilterEntry (ns3::Ptr<const ns3::CcnxNameComponents> prefix)
    : m_prefix (prefix)
  { }
  
  const ns3::CcnxNameComponents &
  GetPrefix () const
  { return *m_prefix; }

  void
  AddCallback (Callback callback)
  { 
    m_callback = callback;
  }

  void
  ClearCallback ()
  {
    m_callback = 0;
  }
  
public:
  ns3::Ptr<const ns3::CcnxNameComponents> m_prefix; ///< \brief Prefix of the PIT entry
  Callback m_callback;
};


template<class Callback>
struct CcnxFilterEntryContainer
{
  typedef
  boost::multi_index::multi_index_container<
    CcnxFilterEntry<Callback>,
    boost::multi_index::indexed_by<
      // indexed by hash
      boost::multi_index::hashed_unique<
        boost::multi_index::const_mem_fun< CcnxFilterEntry<Callback>, const ns3::CcnxNameComponents&, &CcnxFilterEntry<Callback>::GetPrefix >,
        ns3::CcnxPrefixHash
        >
      >
    > type;
};



struct CcnxOperationException : virtual boost::exception, virtual std::exception { };
/**
 * \ingroup sync
 * @brief A wrapper for ccnx library; clients of this code do not need to deal
 * with ccnx library
 */
class CcnxWrapper
  : public ns3::CcnxApp
{
public:
  typedef boost::function<void (std::string, std::string)> DataCallback;
  typedef boost::function<void (std::string)> InterestCallback;
  
  /**
   * @brief initialize the wrapper; a lot of things needs to be done. 1) init
   * keystore 2) init keylocator 3) start a thread to hold a loop of ccn_run
   *
   */
  CcnxWrapper();
  ~CcnxWrapper();

  // from CcnxApp
  /**
   * @brief Should be called after Node pointer is set to create face and start application
   */
  virtual void
  StartApplication ();

  /**
   * @brief Stop application
   */
  virtual void
  StopApplication ();

  /**
   * @brief send Interest; need to grab lock m_mutex first
   *
   * @param strInterest the Interest name
   * @param dataCallback the callback function to deal with the returned data
   * @return the return code of ccn_express_interest
   */
  int
  sendInterest (const std::string &strInterest, const DataCallback &dataCallback);

  /**
   * @brief set Interest filter (specify what interest you want to receive)
   *
   * @param prefix the prefix of Interest
   * @param interestCallback the callback function to deal with the returned data
   * @return the return code of ccn_set_interest_filter
   */
  int
  setInterestFilter (const std::string &prefix, const InterestCallback &interestCallback);

  /**
   * @brief clear Interest filter
   * @param prefix the prefix of Interest
   */
  void
  clearInterestFilter (const std::string &prefix);

  /**
   * @brief publish data and put it to local ccn content store; need to grab
   * lock m_mutex first
   *
   * @param name the name for the data object
   * @param dataBuffer the data to be published
   * @param freshness the freshness time for the data object
   * @return code generated by ccnx library calls, >0 if success
   */
  int
  publishData (const std::string &name, const std::string &dataBuffer, int freshness);

  // from CcnxApp
  virtual void
  OnInterest (const ns3::Ptr<const ns3::CcnxInterestHeader> &interest, ns3::Ptr<ns3::Packet> packet);
 
  virtual void
  OnContentObject (const ns3::Ptr<const ns3::CcnxContentObjectHeader> &contentObject,
                   ns3::Ptr<ns3::Packet> payload);

private:
  CcnxFilterEntryContainer<InterestCallback>::type::iterator
  InterestCallbackLookup (const ns3::CcnxNameComponents &name);

  CcnxFilterEntryContainer<DataCallback>::type::iterator
  DataCallbackLookup (const ns3::CcnxNameComponents &name);

private:
  ns3::UniformVariable m_rand; // nonce generator

  CcnxFilterEntryContainer<DataCallback>::type m_dataCallbacks;
  CcnxFilterEntryContainer<InterestCallback>::type m_interestCallbacks;
};

typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;

} // Sync

#endif // SYNC_CCNX_WRAPPER_H
