blob: 01358c454f833077d02b1ab7d1eeb4f3f9091f8d [file] [log] [blame]
#ifndef CCNX_CLOSURE_H
#define CCNX_CLOSURE_H
#include "ccnx-common.h"
using namespace std;
namespace Ccnx {
class Closure
{
public:
typedef boost::function<void (const string &, const Bytes &)> DataCallback;
typedef enum
{
RESULT_OK,
RESULT_REEXPRESS
} TimeoutCallbackReturnValue;
typedef boost::function<TimeoutCallbackReturnValue (const string &)> TimeoutCallback;
Closure(int retry, const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback);
Closure(const Closure &other);
int getRetry() {return m_retry;}
void decRetry() { m_retry--;}
virtual ~Closure();
virtual void
runDataCallback(const string &name, const Bytes &content);
virtual TimeoutCallbackReturnValue
runTimeoutCallback(const string &interest);
protected:
int m_retry;
TimeoutCallback *m_timeoutCallback;
DataCallback *m_dataCallback;
};
} // Ccnx
#endif