blob: 9ac4df65cba07b568766b09a926148c5516cda87 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson990599b2013-08-27 15:14:25 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson990599b2013-08-27 15:14:25 -07005 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_FORWARDING_ENTRY_HPP
Jeff Thompsone589c3f2013-10-12 17:30:50 -07009#define NDN_FORWARDING_ENTRY_HPP
Jeff Thompson990599b2013-08-27 15:14:25 -070010
11#include <string>
12#include "name.hpp"
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070013#include "forwarding-flags.hpp"
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080014#include "encoding/block.hpp"
Jeff Thompson990599b2013-08-27 15:14:25 -070015
16namespace ndn {
17
18/**
19 * An ForwardingEntry holds an action and Name prefix and other fields for an forwarding entry.
20 */
21class ForwardingEntry {
22public:
23 ForwardingEntry
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080024 (const std::string& action,
25 const Name& prefix,
26 int faceId,
27 const ForwardingFlags& forwardingFlags,
28 int freshnessPeriod)
29 : action_(action)
30 , prefix_(prefix)
31 , faceId_(faceId)
32 , forwardingFlags_(forwardingFlags)
33 , freshnessPeriod_(freshnessPeriod)
Jeff Thompson990599b2013-08-27 15:14:25 -070034 {
35 }
36
37 ForwardingEntry()
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080038 : faceId_(-1), freshnessPeriod_(-1)
Jeff Thompson990599b2013-08-27 15:14:25 -070039 {
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070040 forwardingFlags_.setActive(true);
41 forwardingFlags_.setChildInherit(true);
Jeff Thompson990599b2013-08-27 15:14:25 -070042 }
43
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080044 Block
45 wireEncode() const
Jeff Thompson990599b2013-08-27 15:14:25 -070046 {
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080047 return wire_;
48 // return wireFormat.encodeForwardingEntry(*this);
Jeff Thompson990599b2013-08-27 15:14:25 -070049 }
Jeff Thompson0050abe2013-09-17 12:50:25 -070050
51 void
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080052 wireDecode(const Block &wire)
Jeff Thompson990599b2013-08-27 15:14:25 -070053 {
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080054 // wireFormat.decodeForwardingEntry(*this, input, inputLength);
Jeff Thompson990599b2013-08-27 15:14:25 -070055 }
Jeff Thompson0050abe2013-09-17 12:50:25 -070056
Jeff Thompson0050abe2013-09-17 12:50:25 -070057 const std::string&
58 getAction() const { return action_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070059
Jeff Thompson0050abe2013-09-17 12:50:25 -070060 Name&
61 getPrefix() { return prefix_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070062
Jeff Thompson0050abe2013-09-17 12:50:25 -070063 const Name&
64 getPrefix() const { return prefix_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070065
Jeff Thompson0050abe2013-09-17 12:50:25 -070066 int
67 getFaceId() const { return faceId_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070068
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070069 const ForwardingFlags&
Jeff Thompson0050abe2013-09-17 12:50:25 -070070 getForwardingFlags() const { return forwardingFlags_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070071
Jeff Thompson0050abe2013-09-17 12:50:25 -070072 int
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080073 getFreshnessPeriod() const { return freshnessPeriod_; }
Jeff Thompson990599b2013-08-27 15:14:25 -070074
Jeff Thompson0050abe2013-09-17 12:50:25 -070075 void
Jeff Thompson83bf07e2013-11-19 11:46:18 -080076 setAction(const std::string& action) { action_ = action; }
Jeff Thompson990599b2013-08-27 15:14:25 -070077
Jeff Thompson0050abe2013-09-17 12:50:25 -070078 void
Jeff Thompson83bf07e2013-11-19 11:46:18 -080079 setFaceId(int faceId) { faceId_ = faceId; }
Jeff Thompson990599b2013-08-27 15:14:25 -070080
Jeff Thompson0050abe2013-09-17 12:50:25 -070081 void
Jeff Thompson83bf07e2013-11-19 11:46:18 -080082 setForwardingFlags(const ForwardingFlags& forwardingFlags) { forwardingFlags_ = forwardingFlags; }
Jeff Thompson990599b2013-08-27 15:14:25 -070083
Jeff Thompson0050abe2013-09-17 12:50:25 -070084 void
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080085 setFreshnessPeriod(int freshnessPeriod) { freshnessPeriod_ = freshnessPeriod; }
Jeff Thompson990599b2013-08-27 15:14:25 -070086
Jeff Thompson0050abe2013-09-17 12:50:25 -070087private:
Jeff Thompson990599b2013-08-27 15:14:25 -070088 std::string action_; /**< empty for none. */
89 Name prefix_;
Jeff Thompson990599b2013-08-27 15:14:25 -070090 int faceId_; /**< -1 for none. */
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070091 ForwardingFlags forwardingFlags_;
Alexander Afanasyev895b2f32014-01-03 13:24:52 -080092 int freshnessPeriod_; /**< -1 for none. */
93
94 Block wire_;
Jeff Thompson990599b2013-08-27 15:14:25 -070095};
96
97}
98
99#endif