Jeff Thompson | fa30664 | 2013-06-17 15:06:57 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Alexander Afanasyev |
| 5 | * Zhenkai Zhu |
| 6 | * |
| 7 | * BSD license, See the LICENSE file for more information |
| 8 | * |
| 9 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 10 | * Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 11 | */ |
| 12 | |
| 13 | #include "interest.h" |
| 14 | #include <boost/lexical_cast.hpp> |
| 15 | |
| 16 | using namespace std; |
| 17 | |
| 18 | namespace ndn { |
| 19 | |
| 20 | Interest::Interest () |
| 21 | // m_name |
| 22 | : m_maxSuffixComponents (Interest::ncomps) |
| 23 | , m_minSuffixComponents (Interest::ncomps) |
| 24 | , m_answerOriginKind (AOK_DEFAULT) |
| 25 | , m_interestLifetime (time::Seconds (-1.0)) |
| 26 | , m_scope (NO_SCOPE) |
| 27 | , m_childSelector (CHILD_DEFAULT) |
| 28 | // m_publisherKeyDigest |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | Interest::Interest (const Name &name) |
| 33 | : m_name (name) |
| 34 | , m_maxSuffixComponents (Interest::ncomps) |
| 35 | , m_minSuffixComponents (Interest::ncomps) |
| 36 | , m_answerOriginKind(AOK_DEFAULT) |
| 37 | , m_interestLifetime (time::Seconds (-1.0)) |
| 38 | , m_scope (NO_SCOPE) |
| 39 | , m_childSelector (CHILD_DEFAULT) |
| 40 | // m_publisherKeyDigest |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | Interest::Interest (const Interest &other) |
| 45 | { |
| 46 | m_name = other.m_name; |
| 47 | m_maxSuffixComponents = other.m_maxSuffixComponents; |
| 48 | m_minSuffixComponents = other.m_minSuffixComponents; |
| 49 | m_answerOriginKind = other.m_answerOriginKind; |
| 50 | m_interestLifetime = other.m_interestLifetime; |
| 51 | m_scope = other.m_scope; |
| 52 | m_childSelector = other.m_childSelector; |
| 53 | m_publisherPublicKeyDigest = other.m_publisherPublicKeyDigest; |
| 54 | } |
| 55 | |
| 56 | Interest::Interest (const ccn_parsed_interest *pi) |
| 57 | : m_maxSuffixComponents (Interest::ncomps) |
| 58 | , m_minSuffixComponents (Interest::ncomps) |
| 59 | , m_answerOriginKind (AOK_DEFAULT) |
| 60 | , m_interestLifetime (time::Seconds (-1.0)) |
| 61 | , m_scope (NO_SCOPE) |
| 62 | , m_childSelector (CHILD_DEFAULT) |
| 63 | { |
| 64 | if (pi != NULL) |
| 65 | { |
| 66 | m_maxSuffixComponents = pi->max_suffix_comps; |
| 67 | m_minSuffixComponents = pi->min_suffix_comps; |
| 68 | switch(pi->orderpref) |
| 69 | { |
| 70 | case 0: m_childSelector = CHILD_LEFT; break; |
| 71 | case 1: m_childSelector = CHILD_RIGHT; break; |
| 72 | default: m_childSelector = CHILD_DEFAULT; break; |
| 73 | } |
| 74 | |
| 75 | switch(pi->answerfrom) |
| 76 | { |
| 77 | case 0x1: m_answerOriginKind = AOK_CS; break; |
| 78 | case 0x2: m_answerOriginKind = AOK_NEW; break; |
| 79 | case 0x3: m_answerOriginKind = AOK_DEFAULT; break; |
| 80 | case 0x4: m_answerOriginKind = AOK_STALE; break; |
| 81 | case 0x10: m_answerOriginKind = AOK_EXPIRE; break; |
| 82 | default: break; |
| 83 | } |
| 84 | m_scope = static_cast<Scope> (pi->scope); |
| 85 | } |
| 86 | |
| 87 | /// @todo copy publisher key digest |
| 88 | } |
| 89 | |
| 90 | bool |
| 91 | Interest::operator == (const Interest &other) |
| 92 | { |
| 93 | return |
| 94 | m_name == other.m_name |
| 95 | && m_maxSuffixComponents == other.m_maxSuffixComponents |
| 96 | && m_minSuffixComponents == other.m_minSuffixComponents |
| 97 | && m_answerOriginKind == other.m_answerOriginKind |
| 98 | && m_interestLifetime == other.m_interestLifetime |
| 99 | && m_scope == other.m_scope |
| 100 | && m_childSelector == other.m_childSelector; |
| 101 | } |
| 102 | |
| 103 | } // ndn |