| /** |
| * @author: Jeff Thompson |
| * This is a port of py from PyCCN, written by: |
| * Derek Kulinski <takeda@takeda.tk> |
| * Jeff Burke <jburke@ucla.edu> |
| * |
| * See COPYING for copyright and distribution information. |
| */ |
| |
| #ifndef NDN_CLOSURE_HPP |
| #define NDN_CLOSURE_HPP |
| |
| #include "common.hpp" |
| |
| namespace ndn { |
| |
| enum UpcallResult { |
| CLOSURE_RESULT_ERR = -1, // upcall detected an error |
| CLOSURE_RESULT_OK = 0, // normal upcall return |
| CLOSURE_RESULT_REEXPRESS = 1, // reexpress the same interest again |
| CLOSURE_RESULT_INTEREST_CONSUMED = 2, // upcall claims to consume interest |
| CLOSURE_RESULT_VERIFY = 3, // force an unverified result to be verified |
| CLOSURE_RESULT_FETCHKEY = 4 // get the key in the key locator and re-call the interest |
| }; |
| |
| enum UpcallKind { |
| UPCALL_FINAL = 0, // handler is about to be deregistered |
| UPCALL_INTEREST = 1, // incoming interest |
| UPCALL_CONSUMED_INTEREST = 2, // incoming interest, someone has answered |
| UPCALL_DATA = 3, // incoming verified data packet |
| UPCALL_INTEREST_TIMED_OUT = 4, // interest timed out |
| UPCALL_DATA_UNVERIFIED = 5, // data packet that has not been verified |
| UPCALL_DATA_BAD = 6 // verification failed |
| }; |
| |
| class Node; |
| class Interest; |
| class Data; |
| |
| class UpcallInfo { |
| public: |
| UpcallInfo(Node *node, const ptr_lib::shared_ptr<const Interest> &interest, int matchedComps, const ptr_lib::shared_ptr<Data> &data) |
| : node_(node), interest_(interest), data_(data) |
| { |
| } |
| |
| Node *getNode() { return node_; } |
| |
| const ptr_lib::shared_ptr<const Interest> &getInterest() const { return interest_; } |
| |
| const ptr_lib::shared_ptr<Data> &getData() const { return data_; } |
| |
| private: |
| Node *node_; |
| ptr_lib::shared_ptr<const Interest> interest_; |
| ptr_lib::shared_ptr<Data> data_; |
| }; |
| |
| class Closure { |
| public: |
| virtual UpcallResult upcall(UpcallKind kind, const UpcallInfo &upcallInfo) = 0; |
| }; |
| |
| } |
| |
| #endif |