Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012-2013 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 19 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 21 | #ifndef NDNX_SELECTORS_H |
| 22 | #define NDNX_SELECTORS_H |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 23 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 24 | #include "ndnx-common.h" |
| 25 | #include "ndnx-name.h" |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 27 | namespace Ndnx { |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 28 | |
| 29 | struct InterestSelectorException: |
Alexander Afanasyev | 053e5ac | 2013-01-22 20:59:13 -0800 | [diff] [blame] | 30 | virtual boost::exception, virtual std::exception {}; |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 31 | |
| 32 | class Selectors |
| 33 | { |
| 34 | public: |
| 35 | Selectors(); |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 36 | Selectors(const ndn_parsed_interest *); |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 37 | Selectors(const Selectors &other); |
| 38 | ~Selectors(){}; |
| 39 | |
| 40 | typedef enum |
| 41 | { |
| 42 | AOK_CS = 0x1, |
| 43 | AOK_NEW = 0x2, |
| 44 | AOK_DEFAULT = 0x3, // (AOK_CS | AOK_NEW) |
| 45 | AOK_STALE = 0x4, |
| 46 | AOK_EXPIRE = 0x10 |
| 47 | } AOK; |
| 48 | |
| 49 | typedef enum |
| 50 | { |
| 51 | LEFT = 0, |
| 52 | RIGHT = 1, |
| 53 | DEFAULT = 2 |
| 54 | } CHILD_SELECTOR; |
| 55 | |
Alexander Afanasyev | efb12d7 | 2013-03-02 21:24:54 -0800 | [diff] [blame] | 56 | enum Scope |
| 57 | { |
| 58 | NO_SCOPE = -1, |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 59 | SCOPE_LOCAL_NDND = 0, |
Alexander Afanasyev | efb12d7 | 2013-03-02 21:24:54 -0800 | [diff] [blame] | 60 | SCOPE_LOCAL_HOST = 1, |
| 61 | SCOPE_NEXT_HOST = 2 |
| 62 | }; |
| 63 | |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 64 | inline Selectors & |
| 65 | maxSuffixComps(int maxSCs) {m_maxSuffixComps = maxSCs; return *this;} |
| 66 | |
| 67 | inline Selectors & |
| 68 | minSuffixComps(int minSCs) {m_minSuffixComps = minSCs; return *this;} |
| 69 | |
| 70 | inline Selectors & |
| 71 | answerOriginKind(AOK kind) {m_answerOriginKind = kind; return *this;} |
| 72 | |
| 73 | inline Selectors & |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 74 | interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;} |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 75 | |
| 76 | inline Selectors & |
Alexander Afanasyev | efb12d7 | 2013-03-02 21:24:54 -0800 | [diff] [blame] | 77 | scope(Scope scope) {m_scope = scope; return *this;} |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 78 | |
| 79 | inline Selectors & |
| 80 | childSelector(CHILD_SELECTOR child) {m_childSelector = child; return *this;} |
| 81 | |
| 82 | // this has no effect now |
| 83 | inline Selectors & |
| 84 | publisherPublicKeyDigest(const Bytes &digest) {m_publisherPublicKeyDigest = digest; return *this;} |
| 85 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 86 | NdnxCharbufPtr |
| 87 | toNdnxCharbuf() const; |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 88 | |
| 89 | bool |
| 90 | isEmpty() const; |
| 91 | |
| 92 | bool |
| 93 | operator==(const Selectors &other); |
| 94 | |
| 95 | private: |
| 96 | int m_maxSuffixComps; |
| 97 | int m_minSuffixComps; |
| 98 | AOK m_answerOriginKind; |
| 99 | double m_interestLifetime; |
Alexander Afanasyev | efb12d7 | 2013-03-02 21:24:54 -0800 | [diff] [blame] | 100 | Scope m_scope; |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 101 | CHILD_SELECTOR m_childSelector; |
| 102 | // not used now |
| 103 | Bytes m_publisherPublicKeyDigest; |
| 104 | }; |
| 105 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 106 | } // Ndnx |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 107 | |
| 108 | #endif |