Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_NDN_HPP |
| 7 | #define NDN_NDN_HPP |
| 8 | |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 9 | #include "Closure.hpp" |
Jeff Thompson | c172be3 | 2013-07-16 15:08:05 -0700 | [diff] [blame^] | 10 | #include "Interest.hpp" |
| 11 | #include "transport/Transport.hpp" |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 12 | #include "encoding/BinaryXMLElementReader.hpp" |
| 13 | |
| 14 | namespace ndn { |
| 15 | |
| 16 | class NDN : public ElementListener { |
| 17 | public: |
Jeff Thompson | c172be3 | 2013-07-16 15:08:05 -0700 | [diff] [blame^] | 18 | NDN(const ptr_lib::shared_ptr<Transport> &transport, const ptr_lib::shared_ptr<Closure> &tempClosure) |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 19 | { |
Jeff Thompson | c172be3 | 2013-07-16 15:08:05 -0700 | [diff] [blame^] | 20 | transport_ = transport; |
| 21 | tempClosure_ = tempClosure; |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Jeff Thompson | c172be3 | 2013-07-16 15:08:05 -0700 | [diff] [blame^] | 24 | /** |
| 25 | * Encode name as an Interest. If interestTemplate is not 0, use its interest selectors. |
| 26 | * Send the interest through the transport, read the entire response and call |
| 27 | * closure->upcall(UPCALL_CONTENT (or UPCALL_CONTENT_UNVERIFIED), |
| 28 | * UpcallInfo(this, interest, 0, contentObject)). |
| 29 | * @param name reference to a Name for the interest. This does not keep a pointer to the Name object. |
| 30 | * @param closure a shared_ptr for the Closure. This uses shared_ptr to take another reference to the object. |
| 31 | * @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object. |
| 32 | */ |
| 33 | void expressInterest(const Name &name, const ptr_lib::shared_ptr<Closure> &closure, const Interest *interestTemplate); |
| 34 | |
| 35 | Transport &tempGetTransport() { return *transport_; } |
| 36 | |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 37 | virtual void onReceivedElement(unsigned char *element, unsigned int elementLength); |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
Jeff Thompson | c172be3 | 2013-07-16 15:08:05 -0700 | [diff] [blame^] | 40 | ptr_lib::shared_ptr<Transport> transport_; |
| 41 | ptr_lib::shared_ptr<Closure> tempClosure_; |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | } |
| 45 | |
| 46 | #endif |