NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
regex-backref-manager.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP
25 #define NDN_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP
26 
27 #include "../../common.hpp"
28 
29 #include <vector>
30 
31 namespace ndn {
32 
33 class RegexMatcher;
34 
36 {
37 public:
38  size_t
39  pushRef(const shared_ptr<RegexMatcher>& matcher);
40 
41  void
42  popRef();
43 
44  size_t
45  size() const;
46 
47  shared_ptr<RegexMatcher>
48  getBackref(size_t i) const;
49 
50 private:
51  std::vector<weak_ptr<RegexMatcher>> m_backrefs;
52 };
53 
54 
55 inline size_t
56 RegexBackrefManager::pushRef(const shared_ptr<RegexMatcher>& matcher)
57 {
58  size_t last = m_backrefs.size();
59  m_backrefs.push_back(matcher);
60 
61  return last;
62 }
63 
64 inline void
66 {
67  m_backrefs.pop_back();
68 }
69 
70 inline size_t
72 {
73  return m_backrefs.size();
74 }
75 
76 inline shared_ptr<RegexMatcher>
78 {
79  auto backref = m_backrefs[i].lock();
80  BOOST_ASSERT(backref != nullptr);
81  return backref;
82 }
83 
84 } // namespace ndn
85 
86 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< RegexMatcher > getBackref(size_t i) const
size_t pushRef(const shared_ptr< RegexMatcher > &matcher)