ccnx: Adding enum for Scope field in Selectors
Change-Id: I5753f5036ee2cdce95a078c8ffdcebf00b34930f
diff --git a/ccnx/ccnx-selectors.cpp b/ccnx/ccnx-selectors.cpp
index 510aaa9..3ce6144 100644
--- a/ccnx/ccnx-selectors.cpp
+++ b/ccnx/ccnx-selectors.cpp
@@ -11,7 +11,7 @@
, m_minSuffixComps(-1)
, m_answerOriginKind(AOK_DEFAULT)
, m_interestLifetime(-1.0)
- , m_scope(-1)
+ , m_scope(NO_SCOPE)
, m_childSelector(DEFAULT)
{
}
@@ -32,7 +32,7 @@
, m_minSuffixComps(-1)
, m_answerOriginKind(AOK_DEFAULT)
, m_interestLifetime(-1.0)
- , m_scope(-1)
+ , m_scope(NO_SCOPE)
, m_childSelector(DEFAULT)
{
if (pi != NULL)
@@ -54,7 +54,7 @@
case 0x10: m_answerOriginKind = AOK_EXPIRE; break;
default: break;
}
- m_scope = pi->scope;
+ m_scope = static_cast<Scope> (pi->scope);
// scope and interest lifetime do not really matter to receiving application, it's only meaningful to routers
}
}
@@ -77,7 +77,7 @@
&& m_minSuffixComps == -1
&& m_answerOriginKind == AOK_DEFAULT
&& (m_interestLifetime - (-1.0)) < 10e-4
- && m_scope == -1
+ && m_scope == NO_SCOPE
&& m_childSelector == DEFAULT;
}
@@ -118,7 +118,7 @@
ccn_charbuf_append_closer(cbuf); // <AnswerOriginKind>
}
- if (m_scope != -1)
+ if (m_scope != NO_SCOPE)
{
ccnb_tagged_putf(cbuf, CCN_DTAG_Scope, "%d", m_scope);
}
diff --git a/ccnx/ccnx-selectors.h b/ccnx/ccnx-selectors.h
index a1125b9..3a04ff5 100644
--- a/ccnx/ccnx-selectors.h
+++ b/ccnx/ccnx-selectors.h
@@ -53,6 +53,14 @@
DEFAULT = 2
} CHILD_SELECTOR;
+ enum Scope
+ {
+ NO_SCOPE = -1,
+ SCOPE_LOCAL_CCND = 0,
+ SCOPE_LOCAL_HOST = 1,
+ SCOPE_NEXT_HOST = 2
+ };
+
inline Selectors &
maxSuffixComps(int maxSCs) {m_maxSuffixComps = maxSCs; return *this;}
@@ -66,7 +74,7 @@
interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;}
inline Selectors &
- scope(int scope) {m_scope = scope; return *this;}
+ scope(Scope scope) {m_scope = scope; return *this;}
inline Selectors &
childSelector(CHILD_SELECTOR child) {m_childSelector = child; return *this;}
@@ -89,7 +97,7 @@
int m_minSuffixComps;
AOK m_answerOriginKind;
double m_interestLifetime;
- int m_scope;
+ Scope m_scope;
CHILD_SELECTOR m_childSelector;
// not used now
Bytes m_publisherPublicKeyDigest;