blob: f014545d4b4c1d4e0ceecb8e9aaff593a250c559 [file] [log] [blame]
Junxiao Shi2c29f3a2014-01-24 19:59:00 -07001/* -*- 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 Shi32bfeb32014-01-25 18:22:02 -070011#include "util/event-emitter.hpp"
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070012
13namespace ndn {
14
15/** \class FaceId
16 * \brief identifies a face
17 */
18typedef int FaceId;
19
Alexander Afanasyevd32cb962014-01-28 12:43:47 -080020const std::size_t MAX_NDN_PACKET_SIZE = 8800;
21
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070022/** \class Face
23 * \brief represents a face
24 */
Alexander Afanasyevd32cb962014-01-28 12:43:47 -080025class Face : noncopyable, public enable_shared_from_this<Face>
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070026{
Junxiao Shi32bfeb32014-01-25 18:22:02 -070027public:
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 Afanasyevd32cb962014-01-28 12:43:47 -080038
39 /// fires when face disconnects or fails to perform properly
40 EventEmitter<const std::string& /*reason*/> onFail;
Junxiao Shi32bfeb32014-01-25 18:22:02 -070041
42 /// send an Interest
43 virtual void
Alexander Afanasyeva9034b02014-01-26 18:32:02 -080044 sendInterest(const Interest& interest) = 0;
Junxiao Shi32bfeb32014-01-25 18:22:02 -070045
46 /// send a Data
47 virtual void
Alexander Afanasyeva9034b02014-01-26 18:32:02 -080048 sendData(const Data& data) = 0;
Junxiao Shi32bfeb32014-01-25 18:22:02 -070049
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
76protected:
77 // void
78 // receiveInterest();
79
80 // void
81 // receiveData();
82
83private:
84 FaceId m_id;
85 std::string m_description;
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070086};
87
88} // namespace ndn
89
90#endif // NFD_FACE_FACE_H