Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "internal-face.hpp" |
| 8 | |
| 9 | namespace nfd { |
| 10 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame^] | 11 | NFD_LOG_INIT("InternalFace"); |
| 12 | |
| 13 | InternalFace::InternalFace() |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 14 | { |
| 15 | |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | InternalFace::sendInterest(const Interest& interest) |
| 20 | { |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame^] | 21 | const Name& interestName(interest.getName()); |
| 22 | NFD_LOG_DEBUG("received Interest: " << interestName); |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 23 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame^] | 24 | size_t nComps = interestName.size(); |
| 25 | for (size_t i = 0; i < nComps; i++) |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 26 | { |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame^] | 27 | Name prefix(interestName.getPrefix(nComps - i)); |
| 28 | std::map<Name, OnInterest>::const_iterator filter = |
| 29 | m_interestFilters.find(prefix); |
| 30 | |
| 31 | if (filter != m_interestFilters.end()) |
| 32 | { |
| 33 | NFD_LOG_DEBUG("found Interest filter for " << prefix); |
| 34 | filter->second(interestName, interest); |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | NFD_LOG_DEBUG("no Interest filter found for " << prefix); |
| 39 | } |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 40 | } |
| 41 | //Drop Interest |
| 42 | } |
| 43 | |
| 44 | void |
| 45 | InternalFace::sendData(const Data& data) |
| 46 | { |
| 47 | |
| 48 | } |
| 49 | |
| 50 | void |
| 51 | InternalFace::setInterestFilter(const Name& filter, |
| 52 | OnInterest onInterest) |
| 53 | { |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame^] | 54 | NFD_LOG_INFO("registering callback for " << filter); |
| 55 | m_interestFilters[filter] = onInterest; |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void |
| 59 | InternalFace::put(const Data& data) |
| 60 | { |
| 61 | onReceiveData(data); |
| 62 | } |
| 63 | |
| 64 | InternalFace::~InternalFace() |
| 65 | { |
| 66 | |
| 67 | } |
| 68 | |
| 69 | } // namespace nfd |