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 | */ |
| 21 | #ifndef CCNX_SELECTORS_H |
| 22 | #define CCNX_SELECTORS_H |
| 23 | |
| 24 | #include "ccnx-common.h" |
| 25 | #include "ccnx-name.h" |
| 26 | |
| 27 | namespace Ccnx { |
| 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(); |
Zhenkai Zhu | ff4fa8a | 2013-01-28 22:02:40 -0800 | [diff] [blame] | 36 | Selectors(const ccn_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, |
| 59 | SCOPE_LOCAL_CCND = 0, |
| 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 | |
| 86 | CcnxCharbufPtr |
| 87 | toCcnxCharbuf() const; |
| 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 | |
| 106 | } // Ccnx |
| 107 | |
| 108 | #endif |