name-prefix-list.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_NAME_PREFIX_LIST_HPP
23 #define NLSR_NAME_PREFIX_LIST_HPP
24 
25 #include <list>
26 #include <string>
27 #include <boost/cstdint.hpp>
28 #include <ndn-cxx/name.hpp>
29 
30 
31 namespace nlsr {
33 {
34 public:
35  using NamePair = std::tuple<ndn::Name, std::vector<std::string>>;
39  };
40 
42 
43  NamePrefixList(const std::initializer_list<ndn::Name>& names);
44 
45  NamePrefixList(const std::initializer_list<NamePrefixList::NamePair>& namesAndSources);
46 
47  template<class ContainerType>
48  NamePrefixList(const ContainerType& names)
49  {
50  for (const auto& elem : names) {
51  m_names.push_back(NamePair{elem, {""}});
52  }
53  }
54 
56 
61  bool
62  insert(const ndn::Name& name, const std::string& source = "");
63 
68  bool
69  remove(const ndn::Name& name, const std::string& source = "");
70 
71  void
72  sort();
73 
74  size_t
75  size() const
76  {
77  return m_names.size();
78  }
79 
80  std::list<ndn::Name>
81  getNames() const;
82 
83  bool
84  operator==(const NamePrefixList& other) const;
85 
90  uint32_t
91  countSources(const ndn::Name& name) const;
92 
98  const std::vector<std::string>
99  getSources(const ndn::Name& name) const;
100 
101 private:
107  std::vector<NamePair>::iterator
108  get(const ndn::Name& name);
109 
112  std::vector<std::string>::iterator
113  getSource(const std::string& source, std::vector<NamePair>::iterator& entry);
114 
115  std::vector<NamePair> m_names;
116 };
117 
118 std::ostream&
119 operator<<(std::ostream& os, const NamePrefixList& list);
120 
121 } // namespace nlsr
122 
123 #endif // NLSR_NAME_PREFIX_LIST_HPP
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:99
std::list< ndn::Name > getNames() const
bool operator==(const NamePrefixList &other) const
std::tuple< ndn::Name, std::vector< std::string >> NamePair
bool insert(const ndn::Name &name, const std::string &source="")
inserts name into NamePrefixList
const std::vector< std::string > getSources(const ndn::Name &name) const
NamePrefixList(const ContainerType &names)
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
uint32_t countSources(const ndn::Name &name) const