blob: bdc69bf38c28fc5d9d84cf776929fe81350dc970 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -08002/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +00003 * Copyright (c) 2013-2016 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080020 */
21
22#ifndef NDN_DETAIL_REGISTERED_PREFIX_HPP
23#define NDN_DETAIL_REGISTERED_PREFIX_HPP
24
25#include "../common.hpp"
Alexander Afanasyevc348f832014-02-17 16:35:17 -080026#include "../name.hpp"
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080027#include "../interest.hpp"
28
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070029#include "interest-filter-record.hpp"
Joao Pereiraba1e3b92015-06-01 17:50:37 -040030#include "management/nfd-command-options.hpp"
31#include "management/nfd-control-parameters.hpp"
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070032
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080033namespace ndn {
34
Junxiao Shi103d8ed2016-08-07 20:34:10 +000035/**
36 * @brief stores information about a prefix registered in NDN forwarder
37 */
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070038class RegisteredPrefix : noncopyable
Alexander Afanasyev90164962014-03-06 08:29:59 +000039{
40public:
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070041 RegisteredPrefix(const Name& prefix,
Junxiao Shi103d8ed2016-08-07 20:34:10 +000042 shared_ptr<InterestFilterRecord> filter,
Joao Pereiraba1e3b92015-06-01 17:50:37 -040043 const nfd::CommandOptions& options)
Alexander Afanasyev90164962014-03-06 08:29:59 +000044 : m_prefix(prefix)
45 , m_filter(filter)
Joao Pereiraba1e3b92015-06-01 17:50:37 -040046 , m_options(options)
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080047 {
48 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049
50 const Name&
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080051 getPrefix() const
52 {
Alexander Afanasyev90164962014-03-06 08:29:59 +000053 return m_prefix;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080054 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070055
Alexander Afanasyev90164962014-03-06 08:29:59 +000056 const shared_ptr<InterestFilterRecord>&
57 getFilter() const
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080058 {
Alexander Afanasyev90164962014-03-06 08:29:59 +000059 return m_filter;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080060 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061
Joao Pereiraba1e3b92015-06-01 17:50:37 -040062 const nfd::CommandOptions&
63 getCommandOptions() const
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070064 {
Joao Pereiraba1e3b92015-06-01 17:50:37 -040065 return m_options;
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070066 }
67
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080068private:
Alexander Afanasyev90164962014-03-06 08:29:59 +000069 Name m_prefix;
Alexander Afanasyev90164962014-03-06 08:29:59 +000070 shared_ptr<InterestFilterRecord> m_filter;
Joao Pereiraba1e3b92015-06-01 17:50:37 -040071 nfd::CommandOptions m_options;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080072};
73
Alexander Afanasyev90164962014-03-06 08:29:59 +000074/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000075 * @brief Opaque type to identify a RegisteredPrefix
Alexander Afanasyev90164962014-03-06 08:29:59 +000076 */
77class RegisteredPrefixId;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080078
79/**
Alexander Afanasyev90164962014-03-06 08:29:59 +000080 * @brief Functor to match RegisteredPrefixId
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080081 */
Alexander Afanasyev90164962014-03-06 08:29:59 +000082class MatchRegisteredPrefixId
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080083{
Alexander Afanasyev90164962014-03-06 08:29:59 +000084public:
85 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070086 MatchRegisteredPrefixId(const RegisteredPrefixId* registeredPrefixId)
87 : m_id(registeredPrefixId)
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080088 {
89 }
90
91 bool
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070092 operator()(const shared_ptr<RegisteredPrefix>& registeredPrefix) const
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080093 {
Junxiao Shi103d8ed2016-08-07 20:34:10 +000094 return reinterpret_cast<const RegisteredPrefixId*>(registeredPrefix.get()) == m_id;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080095 }
Junxiao Shi103d8ed2016-08-07 20:34:10 +000096
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080097private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070098 const RegisteredPrefixId* m_id;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080099};
100
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -0800101} // namespace ndn
102
103#endif // NDN_DETAIL_REGISTERED_PREFIX_HPP