/* -*- 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>
 */

#ifndef CCNX_CLOSURE_H
#define CCNX_CLOSURE_H

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

namespace Ccnx {

class ParsedContentObject;
typedef boost::shared_ptr<ParsedContentObject> PcoPtr;

class Closure
{
public:
  typedef boost::function<void (Name, PcoPtr pco)> DataCallback;

  typedef enum
  {
    RESULT_OK,
    RESULT_REEXPRESS
  } TimeoutCallbackReturnValue;

  typedef boost::function<TimeoutCallbackReturnValue (Name )> TimeoutCallback;

  Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback = TimeoutCallback());
  virtual ~Closure();

  virtual void
  runDataCallback(Name name, Ccnx::PcoPtr pco);

  virtual TimeoutCallbackReturnValue
  runTimeoutCallback(Name interest);

protected:
  TimeoutCallback m_timeoutCallback;
  DataCallback m_dataCallback;
};

class ExecutorClosure : public Closure
{
public:
  ExecutorClosure(const Closure &closure, ExecutorPtr executor);
  virtual ~ExecutorClosure();

  virtual void
  runDataCallback(Name name, PcoPtr pco);

private:
  void
  execute(Name nae, PcoPtr content);

private:
  ExecutorPtr m_executor;
};

class ExecutorInterestClosure
{
public:
  typedef boost::function<void (Name)> InterestCallback;
  ExecutorInterestClosure(const InterestCallback &callback, ExecutorPtr executor);
  ~ExecutorInterestClosure() {}

  void
  runInterestCallback(Name interest);

  void
  execute(Name interest);

private:
  InterestCallback m_callback;
  ExecutorPtr m_executor;
};

} // Ccnx

#endif
