blob: ed785048288255a5e5e0584cfd0a78d1f516b68a [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (C) 2014 Named Data Networking Project
* See COPYING for copyright and distribution information.
*/
#ifndef NFD_FACE_FACE_H
#define NFD_FACE_FACE_H
#include "common.hpp"
#include "core/event-emitter.hpp"
namespace nfd {
/** \class FaceId
* \brief identifies a face
*/
typedef int FaceId;
const FaceId INVALID_FACEID = -1;
const std::size_t MAX_NDN_PACKET_SIZE = 8800;
/** \class Face
* \brief represents a face
*/
class Face : noncopyable, public enable_shared_from_this<Face>
{
public:
Face();
virtual
~Face();
FaceId
getId() const;
/// fires when an Interest is received
EventEmitter<Interest> onReceiveInterest;
/// fires when a Data is received
EventEmitter<Data> onReceiveData;
/// fires when face disconnects or fails to perform properly
EventEmitter<std::string/*reason*/> onFail;
/// send an Interest
virtual void
sendInterest(const Interest& interest) = 0;
/// send a Data
virtual void
sendData(const Data& data) = 0;
/** \brief Get whether underlying communicate is up
* In this base class this property is always true.
*/
virtual bool
isUp() const;
/** \brief Set the description
* This is typically invoked by mgmt on set description command
*/
virtual void
setDescription(const std::string& description);
/// Get the description
virtual const std::string&
getDescription() const;
/** \brief Get whether packets sent this Face may reach multiple peers
* In this base class this property is always false.
*/
virtual bool
isMultiAccess() const;
/// Get whether the face has opted in for local control header
virtual bool
isLocalControlHeaderEnabled() const;
protected:
// void
// receiveInterest();
// void
// receiveData();
private:
void
setId(FaceId faceId);
private:
FaceId m_id;
std::string m_description;
// allow setting FaceId
friend class Forwarder;
};
} // namespace nfd
#endif // NFD_FACE_FACE_H