Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -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 "face.hpp" |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 8 | #include "core/logger.hpp" |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 9 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 10 | namespace nfd { |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 11 | |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 12 | NFD_LOG_INIT("Face") |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 13 | |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 14 | Face::Face(const FaceUri& uri, bool isLocal) |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 15 | : m_id(INVALID_FACEID) |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 16 | , m_isLocal(isLocal) |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 17 | , m_uri(uri) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 18 | { |
| 19 | } |
| 20 | |
| 21 | Face::~Face() |
| 22 | { |
| 23 | } |
| 24 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 25 | FaceId |
| 26 | Face::getId() const |
| 27 | { |
| 28 | return m_id; |
| 29 | } |
| 30 | |
Alexander Afanasyev | 46f6647 | 2014-01-31 16:50:58 -0800 | [diff] [blame] | 31 | // this method is private and should be used only by the Forwarder |
| 32 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 33 | Face::setId(FaceId faceId) |
| 34 | { |
| 35 | m_id = faceId; |
| 36 | } |
| 37 | |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 38 | void |
| 39 | Face::setDescription(const std::string& description) |
| 40 | { |
| 41 | m_description = description; |
| 42 | } |
| 43 | |
| 44 | const std::string& |
| 45 | Face::getDescription() const |
| 46 | { |
| 47 | return m_description; |
| 48 | } |
| 49 | |
| 50 | bool |
| 51 | Face::isMultiAccess() const |
| 52 | { |
| 53 | return false; |
| 54 | } |
| 55 | |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 56 | bool |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 57 | Face::isUp() const |
| 58 | { |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | bool |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 63 | Face::decodeAndDispatchInput(const Block& element) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 64 | { |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 65 | /// \todo Ensure lazy field decoding process |
| 66 | |
| 67 | if (element.type() == tlv::Interest) |
| 68 | { |
| 69 | shared_ptr<Interest> i = make_shared<Interest>(); |
| 70 | i->wireDecode(element); |
| 71 | this->onReceiveInterest(*i); |
| 72 | } |
| 73 | else if (element.type() == tlv::Data) |
| 74 | { |
| 75 | shared_ptr<Data> d = make_shared<Data>(); |
| 76 | d->wireDecode(element); |
| 77 | this->onReceiveData(*d); |
| 78 | } |
| 79 | else |
| 80 | return false; |
| 81 | |
| 82 | return true; |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 83 | } |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 84 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 85 | } //namespace nfd |