blob: a1125b92c7123e168f5467570e64d426cd6420f3 [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
56 inline Selectors &
57 maxSuffixComps(int maxSCs) {m_maxSuffixComps = maxSCs; return *this;}
58
59 inline Selectors &
60 minSuffixComps(int minSCs) {m_minSuffixComps = minSCs; return *this;}
61
62 inline Selectors &
63 answerOriginKind(AOK kind) {m_answerOriginKind = kind; return *this;}
64
65 inline Selectors &
Alexander Afanasyev650ba282013-01-20 20:14:06 -080066 interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;}
Zhenkai Zhua6472e02013-01-06 14:33:37 -080067
68 inline Selectors &
69 scope(int scope) {m_scope = scope; return *this;}
70
71 inline Selectors &
72 childSelector(CHILD_SELECTOR child) {m_childSelector = child; return *this;}
73
74 // this has no effect now
75 inline Selectors &
76 publisherPublicKeyDigest(const Bytes &digest) {m_publisherPublicKeyDigest = digest; return *this;}
77
78 CcnxCharbufPtr
79 toCcnxCharbuf() const;
80
81 bool
82 isEmpty() const;
83
84 bool
85 operator==(const Selectors &other);
86
87private:
88 int m_maxSuffixComps;
89 int m_minSuffixComps;
90 AOK m_answerOriginKind;
91 double m_interestLifetime;
92 int m_scope;
93 CHILD_SELECTOR m_childSelector;
94 // not used now
95 Bytes m_publisherPublicKeyDigest;
96};
97
98} // Ccnx
99
100#endif