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