blob: 3a04ff54b7d6b811f54f70ee9a886acc974abb98 [file] [log] [blame]
Zhenkai Zhua6472e02013-01-06 14:33:37 -08001/* -*- 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
27namespace Ccnx {
28
29struct InterestSelectorException:
Alexander Afanasyev053e5ac2013-01-22 20:59:13 -080030 virtual boost::exception, virtual std::exception {};
Zhenkai Zhua6472e02013-01-06 14:33:37 -080031
32class Selectors
33{
34public:
35 Selectors();
Zhenkai Zhuff4fa8a2013-01-28 22:02:40 -080036 Selectors(const ccn_parsed_interest *);
Zhenkai Zhua6472e02013-01-06 14:33:37 -080037 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 Afanasyevefb12d72013-03-02 21:24:54 -080056 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 Zhua6472e02013-01-06 14:33:37 -080064 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 Afanasyev650ba282013-01-20 20:14:06 -080074 interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;}
Zhenkai Zhua6472e02013-01-06 14:33:37 -080075
76 inline Selectors &
Alexander Afanasyevefb12d72013-03-02 21:24:54 -080077 scope(Scope scope) {m_scope = scope; return *this;}
Zhenkai Zhua6472e02013-01-06 14:33:37 -080078
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
95private:
96 int m_maxSuffixComps;
97 int m_minSuffixComps;
98 AOK m_answerOriginKind;
99 double m_interestLifetime;
Alexander Afanasyevefb12d72013-03-02 21:24:54 -0800100 Scope m_scope;
Zhenkai Zhua6472e02013-01-06 14:33:37 -0800101 CHILD_SELECTOR m_childSelector;
102 // not used now
103 Bytes m_publisherPublicKeyDigest;
104};
105
106} // Ccnx
107
108#endif