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 | |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 12 | NFD_LOG_INIT("Face"); |
| 13 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 14 | Face::Face() |
| 15 | : m_id(INVALID_FACEID) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 16 | { |
| 17 | } |
| 18 | |
| 19 | Face::~Face() |
| 20 | { |
| 21 | } |
| 22 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 23 | FaceId |
| 24 | Face::getId() const |
| 25 | { |
| 26 | return m_id; |
| 27 | } |
| 28 | |
Alexander Afanasyev | 46f6647 | 2014-01-31 16:50:58 -0800 | [diff] [blame] | 29 | // this method is private and should be used only by the Forwarder |
| 30 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 31 | Face::setId(FaceId faceId) |
| 32 | { |
| 33 | m_id = faceId; |
| 34 | } |
| 35 | |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 36 | bool |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame^] | 37 | Face::isLocal() const |
| 38 | { |
| 39 | return m_isLocal; |
| 40 | } |
| 41 | |
| 42 | // this method is protected and can be used only in derived class |
| 43 | // to set localhost scope |
| 44 | void |
| 45 | Face::setLocal(bool isLocal) |
| 46 | { |
| 47 | m_isLocal = isLocal; |
| 48 | } |
| 49 | |
| 50 | bool |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 51 | Face::isUp() const |
| 52 | { |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | void |
| 57 | Face::setDescription(const std::string& description) |
| 58 | { |
| 59 | m_description = description; |
| 60 | } |
| 61 | |
| 62 | const std::string& |
| 63 | Face::getDescription() const |
| 64 | { |
| 65 | return m_description; |
| 66 | } |
| 67 | |
| 68 | bool |
| 69 | Face::isMultiAccess() const |
| 70 | { |
| 71 | return false; |
| 72 | } |
| 73 | |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame^] | 74 | bool |
| 75 | Face::decodeAndDispatchInput(const Block& element) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 76 | { |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame^] | 77 | /// \todo Ensure lazy field decoding process |
| 78 | |
| 79 | if (element.type() == tlv::Interest) |
| 80 | { |
| 81 | shared_ptr<Interest> i = make_shared<Interest>(); |
| 82 | i->wireDecode(element); |
| 83 | this->onReceiveInterest(*i); |
| 84 | } |
| 85 | else if (element.type() == tlv::Data) |
| 86 | { |
| 87 | shared_ptr<Data> d = make_shared<Data>(); |
| 88 | d->wireDecode(element); |
| 89 | this->onReceiveData(*d); |
| 90 | } |
| 91 | else |
| 92 | return false; |
| 93 | |
| 94 | return true; |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 95 | } |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 96 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 97 | } //namespace nfd |