/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013 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>
 *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#include "ndnx-closure.h"

namespace Ndnx {

Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
  : m_timeoutCallback (timeoutCallback)
  , m_dataCallback (dataCallback)
{
}

Closure::~Closure ()
{
}

void
Closure::runTimeoutCallback(Name interest, const Closure &closure, Selectors selectors)
{
  if (!m_timeoutCallback.empty ())
    {
      m_timeoutCallback (interest, closure, selectors);
    }
}


void
Closure::runDataCallback(Name name, PcoPtr content)
{
  if (!m_dataCallback.empty ())
    {
      m_dataCallback (name, content);
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

// ExecutorClosure::ExecutorClosure(const Closure &closure, ExecutorPtr executor)
//   : Closure(closure.m_dataCallback, closure.m_timeoutCallback)
//   , m_executor(executor)
// {
// }

// ExecutorClosure::~ExecutorClosure()
// {
// }

// void
// ExecutorClosure::runDataCallback(Name name, PcoPtr content)
// {
//   m_executor->execute(boost::bind(&Closure::runDataCallback, this, name, content));
// }

// // void
// // ExecutorClosure::execute(Name name, PcoPtr content)
// // {
// //   Closure::runDataCallback(name, content);
// // }


////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////


// ExecutorInterestClosure::ExecutorInterestClosure(const InterestCallback &callback, ExecutorPtr executor)
//   : m_callback(callback)
//   , m_executor(executor)
// {
// }

// void
// ExecutorInterestClosure::runInterestCallback(Name interest)
// {
//   m_executor->execute(boost::bind(&ExecutorInterestClosure::execute, this, interest));
// }

// void
// ExecutorInterestClosure::execute(Name interest)
// {
//   if (!m_callback.empty())
//   {
//     m_callback(interest);
//   }
// }

} // Ndnx
