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 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #ifndef NDN_CXX_H |
| 12 | #define NDN_CXX_H |
| 13 | |
| 14 | #include "ndn-cpp/common.h" |
| 15 | #include "ndn-cpp/fields/name.h" |
| 16 | #include "ndn-cpp/interest.h" |
| 17 | #include "ndn-cpp/data.h" |
| 18 | |
| 19 | #include "trie/trie-with-policy.h" |
| 20 | #include "trie/policies/counting-policy.h" |
| 21 | |
| 22 | #include <list> |
| 23 | |
| 24 | namespace ndn { |
| 25 | |
| 26 | template<class Callback> |
| 27 | struct CallbackTable : |
| 28 | public trie::trie_with_policy< Name, |
| 29 | trie::ptr_payload_traits< std::list<Callback> >, |
| 30 | trie::counting_policy_traits > |
| 31 | { |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | class Face |
| 36 | { |
| 37 | public: |
| 38 | typedef boost::function<void (Ptr<Data> incomingData, Ptr<const Interest> satisfiedInterest)> SatisfiedInterestCallback; |
| 39 | typedef boost::function<void (Ptr<Interest> incomingInterest, Ptr<const Name> registeredPrefix)> ExpectedInterestCallback; |
| 40 | |
| 41 | // some internal definitions |
| 42 | typedef CallbackTable< SatisfiedInterestCallback > sent_interest_container; |
| 43 | typedef CallbackTable< ExpectedInterestCallback > registered_prefix_container; |
| 44 | |
| 45 | typedef sent_interest_container::iterator sent_interest; |
| 46 | typedef registered_prefix_container::iterator registered_prefix; |
| 47 | |
| 48 | sent_interest |
| 49 | sendInterest (Ptr<const Interest> interest, const SatisfiedInterestCallback &dataCallback); |
| 50 | |
| 51 | void |
| 52 | clearInterest (sent_interest interest); |
| 53 | |
| 54 | registered_prefix |
| 55 | setInterestFilter (Ptr<const Name> prefix, const ExpectedInterestCallback &interestCallback); |
| 56 | |
| 57 | void |
| 58 | clearInterestFilter (const Name &prefix); |
| 59 | |
| 60 | void |
| 61 | clearInterestFilter (registered_prefix filter); |
| 62 | |
| 63 | private: |
| 64 | sent_interest_container m_sentInterests; |
| 65 | registered_prefix_container m_registeredPrefixes; |
| 66 | }; |
| 67 | |
| 68 | } // ndn |
| 69 | |
| 70 | #endif // NDN_CXX_H |