Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -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 | #ifndef NFD_FACE_FACE_H |
| 8 | #define NFD_FACE_FACE_H |
| 9 | |
| 10 | #include "common.hpp" |
Junxiao Shi | 7f02c1e | 2014-01-29 22:57:01 -0700 | [diff] [blame] | 11 | #include "core/event-emitter.hpp" |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 14 | |
| 15 | /** \class FaceId |
| 16 | * \brief identifies a face |
| 17 | */ |
| 18 | typedef int FaceId; |
| 19 | |
Alexander Afanasyev | d32cb96 | 2014-01-28 12:43:47 -0800 | [diff] [blame] | 20 | const std::size_t MAX_NDN_PACKET_SIZE = 8800; |
| 21 | |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 22 | /** \class Face |
| 23 | * \brief represents a face |
| 24 | */ |
Alexander Afanasyev | d32cb96 | 2014-01-28 12:43:47 -0800 | [diff] [blame] | 25 | class Face : noncopyable, public enable_shared_from_this<Face> |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 26 | { |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 27 | public: |
| 28 | Face(FaceId id); |
| 29 | |
| 30 | virtual |
| 31 | ~Face(); |
| 32 | |
| 33 | /// fires when an Interest is received |
| 34 | EventEmitter<const Interest&> onReceiveInterest; |
| 35 | |
| 36 | /// fires when a Data is received |
| 37 | EventEmitter<const Data&> onReceiveData; |
Alexander Afanasyev | d32cb96 | 2014-01-28 12:43:47 -0800 | [diff] [blame] | 38 | |
| 39 | /// fires when face disconnects or fails to perform properly |
| 40 | EventEmitter<const std::string& /*reason*/> onFail; |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 41 | |
| 42 | /// send an Interest |
| 43 | virtual void |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 44 | sendInterest(const Interest& interest) = 0; |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 45 | |
| 46 | /// send a Data |
| 47 | virtual void |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 48 | sendData(const Data& data) = 0; |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 49 | |
| 50 | /** \brief Get whether underlying communicate is up |
| 51 | * In this base class this property is always true. |
| 52 | */ |
| 53 | virtual bool |
| 54 | isUp() const; |
| 55 | |
| 56 | /** \brief Set the description |
| 57 | * This is typically invoked by mgmt on set description command |
| 58 | */ |
| 59 | virtual void |
| 60 | setDescription(const std::string& description); |
| 61 | |
| 62 | /// Get the description |
| 63 | virtual const std::string& |
| 64 | getDescription() const; |
| 65 | |
| 66 | /** \brief Get whether packets sent this Face may reach multiple peers |
| 67 | * In this base class this property is always false. |
| 68 | */ |
| 69 | virtual bool |
| 70 | isMultiAccess() const; |
| 71 | |
| 72 | /// Get whether the face has opted in for local control header |
| 73 | virtual bool |
| 74 | isLocalControlHeaderEnabled() const; |
| 75 | |
| 76 | protected: |
| 77 | // void |
| 78 | // receiveInterest(); |
| 79 | |
| 80 | // void |
| 81 | // receiveData(); |
| 82 | |
| 83 | private: |
| 84 | FaceId m_id; |
| 85 | std::string m_description; |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 88 | } // namespace nfd |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 89 | |
| 90 | #endif // NFD_FACE_FACE_H |