blob: 54306d62daf2dad4d5dee955622d00f8209d7413 [file] [log] [blame]
Zhenkai Zhu974c5a62012-12-28 14:15:30 -08001#ifndef CCNX_CLOSURE_H
2#define CCNX_CLOSURE_H
3
4#include "ccnx-common.h"
5
6using namespace std;
7
8namespace Ccnx {
9
10class Closure
11{
12public:
13 typedef boost::function<void (const string &, const Bytes &)> DataCallback;
14
15 typedef enum
16 {
17 RESULT_OK,
18 RESULT_REEXPRESS
19 } TimeoutCallbackReturnValue;
20
21 typedef boost::function<TimeoutCallbackReturnValue (const string &)> TimeoutCallback;
22
23 Closure(int retry, const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback);
24 Closure(const Closure &other);
25 int getRetry() {return m_retry;}
26 void decRetry() { m_retry--;}
27 virtual ~Closure();
28 virtual void
29 runDataCallback(const string &name, const Bytes &content);
30 virtual TimeoutCallbackReturnValue
31 runTimeoutCallback(const string &interest);
32
33protected:
34 int m_retry;
35 TimeoutCallback *m_timeoutCallback;
36 DataCallback *m_dataCallback;
37};
38
39} // Ccnx
40
41#endif