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