pit-entry.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "pit-entry.hpp"
27 #include <algorithm>
28 
29 namespace nfd {
30 namespace pit {
31 
32 Entry::Entry(const Interest& interest)
33  : m_interest(interest.shared_from_this())
34  , m_nameTreeEntry(nullptr)
35 {
36 }
37 
39 Entry::getInRecord(const Face& face)
40 {
41  return std::find_if(m_inRecords.begin(), m_inRecords.end(),
42  [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
43 }
44 
46 Entry::insertOrUpdateInRecord(Face& face, const Interest& interest)
47 {
48  auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
49  [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
50  if (it == m_inRecords.end()) {
51  m_inRecords.emplace_front(face);
52  it = m_inRecords.begin();
53  }
54 
55  it->update(interest);
56  return it;
57 }
58 
59 void
60 Entry::deleteInRecord(const Face& face)
61 {
62  auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
63  [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
64  if (it != m_inRecords.end()) {
65  m_inRecords.erase(it);
66  }
67 }
68 
69 void
71 {
72  m_inRecords.clear();
73 }
74 
76 Entry::getOutRecord(const Face& face)
77 {
78  return std::find_if(m_outRecords.begin(), m_outRecords.end(),
79  [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
80 }
81 
83 Entry::insertOrUpdateOutRecord(Face& face, const Interest& interest)
84 {
85  auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
86  [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
87  if (it == m_outRecords.end()) {
88  m_outRecords.emplace_front(face);
89  it = m_outRecords.begin();
90  }
91 
92  it->update(interest);
93  return it;
94 }
95 
96 void
97 Entry::deleteOutRecord(const Face& face)
98 {
99  auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
100  [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
101  if (it != m_outRecords.end()) {
102  m_outRecords.erase(it);
103  }
104 }
105 
106 } // namespace pit
107 } // namespace nfd
void deleteInRecord(const Face &face)
delete the in-record for face if it exists
Definition: pit-entry.cpp:60
OutRecordCollection::iterator getOutRecord(const Face &face)
get the out-record for face
Definition: pit-entry.cpp:76
contains information about an Interest toward an outgoing face
void deleteOutRecord(const Face &face)
delete the out-record for face if it exists
Definition: pit-entry.cpp:97
InRecordCollection::iterator insertOrUpdateInRecord(Face &face, const Interest &interest)
insert or update an in-record
Definition: pit-entry.cpp:46
Table::const_iterator iterator
Definition: cs-internal.hpp:41
void clearInRecords()
delete all in-records
Definition: pit-entry.cpp:70
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
contains information about an Interest from an incoming face
OutRecordCollection::iterator insertOrUpdateOutRecord(Face &face, const Interest &interest)
insert or update an out-record
Definition: pit-entry.cpp:83
Entry(const Interest &interest)
Definition: pit-entry.cpp:32
InRecordCollection::iterator getInRecord(const Face &face)
get the in-record for face
Definition: pit-entry.cpp:39