Jeff Thompson | fa30664 | 2013-06-17 15:06:57 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Alexander Afanasyev |
| 5 | * Zhenkai Zhu |
| 6 | * |
| 7 | * BSD license, See the LICENSE file for more information |
| 8 | * |
| 9 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 10 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 11 | */ |
| 12 | |
| 13 | #ifndef NDN_CLOSURE_H |
| 14 | #define NDN_CLOSURE_H |
| 15 | |
| 16 | #include "ndn.cxx/common.h" |
| 17 | #include "ndn.cxx/fields/name.h" |
| 18 | #include "ndn.cxx/interest.h" |
| 19 | |
| 20 | namespace ndn { |
| 21 | |
| 22 | class ParsedContentObject; |
| 23 | typedef boost::shared_ptr<ParsedContentObject> PcoPtr; |
| 24 | |
| 25 | class Closure |
| 26 | { |
| 27 | public: |
| 28 | typedef boost::function<void (Name, PcoPtr pco)> DataCallback; |
| 29 | |
| 30 | typedef boost::function<void (Name, const Closure &, InterestPtr)> TimeoutCallback; |
| 31 | |
| 32 | Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback = TimeoutCallback()); |
| 33 | virtual ~Closure(); |
| 34 | |
| 35 | virtual void |
| 36 | runDataCallback(Name name, ndn::PcoPtr pco); |
| 37 | |
| 38 | virtual void |
| 39 | runTimeoutCallback(Name interest, const Closure &closure, InterestPtr originalInterest); |
| 40 | |
| 41 | virtual Closure * |
| 42 | dup () const { return new Closure (*this); } |
| 43 | |
| 44 | public: |
| 45 | TimeoutCallback m_timeoutCallback; |
| 46 | DataCallback m_dataCallback; |
| 47 | }; |
| 48 | |
| 49 | } // ndn |
| 50 | |
| 51 | #endif |