blob: 56e29b59e6aaa9926146e653ccdfedbfca16097a [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();
36 Selectors(const Selectors &other);
37 ~Selectors(){};
38
39 typedef enum
40 {
41 AOK_CS = 0x1,
42 AOK_NEW = 0x2,
43 AOK_DEFAULT = 0x3, // (AOK_CS | AOK_NEW)
44 AOK_STALE = 0x4,
45 AOK_EXPIRE = 0x10
46 } AOK;
47
48 typedef enum
49 {
50 LEFT = 0,
51 RIGHT = 1,
52 DEFAULT = 2
53 } CHILD_SELECTOR;
54
55 inline Selectors &
56 maxSuffixComps(int maxSCs) {m_maxSuffixComps = maxSCs; return *this;}
57
58 inline Selectors &
59 minSuffixComps(int minSCs) {m_minSuffixComps = minSCs; return *this;}
60
61 inline Selectors &
62 answerOriginKind(AOK kind) {m_answerOriginKind = kind; return *this;}
63
64 inline Selectors &
Alexander Afanasyev650ba282013-01-20 20:14:06 -080065 interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;}
Zhenkai Zhua6472e02013-01-06 14:33:37 -080066
67 inline Selectors &
68 scope(int scope) {m_scope = scope; return *this;}
69
70 inline Selectors &
71 childSelector(CHILD_SELECTOR child) {m_childSelector = child; return *this;}
72
73 // this has no effect now
74 inline Selectors &
75 publisherPublicKeyDigest(const Bytes &digest) {m_publisherPublicKeyDigest = digest; return *this;}
76
77 CcnxCharbufPtr
78 toCcnxCharbuf() const;
79
80 bool
81 isEmpty() const;
82
83 bool
84 operator==(const Selectors &other);
85
86private:
87 int m_maxSuffixComps;
88 int m_minSuffixComps;
89 AOK m_answerOriginKind;
90 double m_interestLifetime;
91 int m_scope;
92 CHILD_SELECTOR m_childSelector;
93 // not used now
94 Bytes m_publisherPublicKeyDigest;
95};
96
97} // Ccnx
98
99#endif