| #include "ccnx-closure.h" |
| |
| namespace Ccnx { |
| |
| Closure::Closure(int retry, const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback) |
| : m_retry(retry), m_timeoutCallback(NULL) |
| { |
| m_timeoutCallback = new TimeoutCallback (timeoutCallback); |
| m_dataCallback = new DataCallback (dataCallback); |
| } |
| |
| Closure::Closure(const Closure &other) |
| { |
| Closure(other.m_retry, *(other.m_dataCallback), *(other.m_timeoutCallback)); |
| } |
| |
| Closure::~Closure () |
| { |
| delete m_dataCallback; |
| delete m_timeoutCallback; |
| m_dataCallback = NULL; |
| m_timeoutCallback = NULL; |
| } |
| |
| Closure::TimeoutCallbackReturnValue |
| Closure::runTimeoutCallback(const string &interest) |
| { |
| if ((*m_timeoutCallback).empty()) |
| { |
| return RESULT_OK; |
| } |
| |
| return (*m_timeoutCallback)(interest); |
| } |
| |
| |
| void |
| Closure::runDataCallback(const string &name, const Bytes &content) |
| { |
| if (m_dataCallback != NULL) { |
| (*m_dataCallback)(name, content); |
| } |
| } |
| |
| } // Ccnx |