encoding+mgmt: move FaceEventKind to nfd-constants
Change-Id: Iab98f9077d557027255434208f084c10ab96b1ef
diff --git a/src/encoding/nfd-constants.cpp b/src/encoding/nfd-constants.cpp
index 2b18d4d..ac34588 100644
--- a/src/encoding/nfd-constants.cpp
+++ b/src/encoding/nfd-constants.cpp
@@ -36,9 +36,8 @@
return os << "non-local";
case FACE_SCOPE_LOCAL:
return os << "local";
- default:
- return os << static_cast<unsigned>(faceScope);
}
+ return os << static_cast<unsigned>(faceScope);
}
std::ostream&
@@ -53,9 +52,8 @@
return os << "on-demand";
case FACE_PERSISTENCY_PERMANENT:
return os << "permanent";
- default:
- return os << static_cast<unsigned>(facePersistency);
}
+ return os << static_cast<unsigned>(facePersistency);
}
std::ostream&
@@ -68,9 +66,26 @@
return os << "point-to-point";
case LINK_TYPE_MULTI_ACCESS:
return os << "multi-access";
- default:
- return os << static_cast<unsigned>(linkType);
}
+ return os << static_cast<unsigned>(linkType);
+}
+
+std::ostream&
+operator<<(std::ostream& os, FaceEventKind faceEventKind)
+{
+ switch (faceEventKind) {
+ case FACE_EVENT_NONE:
+ return os << "none";
+ case FACE_EVENT_CREATED:
+ return os << "created";
+ case FACE_EVENT_DESTROYED:
+ return os << "destroyed";
+ case FACE_EVENT_UP:
+ return os << "up";
+ case FACE_EVENT_DOWN:
+ return os << "down";
+ }
+ return os << static_cast<unsigned>(faceEventKind);
}
std::ostream&
@@ -91,9 +106,8 @@
return os << "nlsr";
case ROUTE_ORIGIN_STATIC:
return os << "static";
- default:
- return os << static_cast<unsigned>(routeOrigin);
}
+ return os << static_cast<unsigned>(routeOrigin);
}
std::ostream&
diff --git a/src/encoding/nfd-constants.hpp b/src/encoding/nfd-constants.hpp
index 688ea74..7026898 100644
--- a/src/encoding/nfd-constants.hpp
+++ b/src/encoding/nfd-constants.hpp
@@ -32,13 +32,9 @@
/** \ingroup management
*/
enum FaceScope : uint8_t {
- FACE_SCOPE_NONE = std::numeric_limits<uint8_t>::max(),
- /** \brief face is non-local
- */
- FACE_SCOPE_NON_LOCAL = 0,
- /** \brief face is local
- */
- FACE_SCOPE_LOCAL = 1
+ FACE_SCOPE_NONE = std::numeric_limits<uint8_t>::max(),
+ FACE_SCOPE_NON_LOCAL = 0, ///< face is non-local
+ FACE_SCOPE_LOCAL = 1, ///< face is local
};
std::ostream&
@@ -47,16 +43,10 @@
/** \ingroup management
*/
enum FacePersistency : uint8_t {
- FACE_PERSISTENCY_NONE = std::numeric_limits<uint8_t>::max(),
- /** \brief face is persistent
- */
- FACE_PERSISTENCY_PERSISTENT = 0,
- /** \brief face is on-demand
- */
- FACE_PERSISTENCY_ON_DEMAND = 1,
- /** \brief face is permanent
- */
- FACE_PERSISTENCY_PERMANENT = 2
+ FACE_PERSISTENCY_NONE = std::numeric_limits<uint8_t>::max(),
+ FACE_PERSISTENCY_PERSISTENT = 0, ///< face is persistent
+ FACE_PERSISTENCY_ON_DEMAND = 1, ///< face is on-demand
+ FACE_PERSISTENCY_PERMANENT = 2, ///< face is permanent
};
std::ostream&
@@ -64,22 +54,10 @@
/** \ingroup management
*/
-enum FaceFlagBit {
- /** \brief bit that controls whether local fields are enabled on a face
- */
- BIT_LOCAL_FIELDS_ENABLED = 0
-};
-
-/** \ingroup management
- */
enum LinkType : uint8_t {
- LINK_TYPE_NONE = std::numeric_limits<uint8_t>::max(),
- /** \brief link is point-to-point
- */
- LINK_TYPE_POINT_TO_POINT = 0,
- /** \brief link is multi-access
- */
- LINK_TYPE_MULTI_ACCESS = 1
+ LINK_TYPE_NONE = std::numeric_limits<uint8_t>::max(),
+ LINK_TYPE_POINT_TO_POINT = 0, ///< link is point-to-point
+ LINK_TYPE_MULTI_ACCESS = 1, ///< link is multi-access
};
std::ostream&
@@ -87,6 +65,25 @@
/** \ingroup management
*/
+enum FaceFlagBit {
+ BIT_LOCAL_FIELDS_ENABLED = 0, ///< controls whether local fields are enabled on a face
+};
+
+/** \ingroup management
+ */
+enum FaceEventKind : uint8_t {
+ FACE_EVENT_NONE = 0,
+ FACE_EVENT_CREATED = 1, ///< face was created
+ FACE_EVENT_DESTROYED = 2, ///< face was destroyed
+ FACE_EVENT_UP = 3, ///< face went UP (from DOWN state)
+ FACE_EVENT_DOWN = 4, ///< face went DOWN (from UP state)
+};
+
+std::ostream&
+operator<<(std::ostream& os, FaceEventKind faceEventKind);
+
+/** \ingroup management
+ */
enum RouteOrigin : uint16_t {
ROUTE_ORIGIN_NONE = std::numeric_limits<uint16_t>::max(),
ROUTE_ORIGIN_APP = 0,
@@ -94,7 +91,7 @@
ROUTE_ORIGIN_CLIENT = 65,
ROUTE_ORIGIN_AUTOCONF = 66,
ROUTE_ORIGIN_NLSR = 128,
- ROUTE_ORIGIN_STATIC = 255
+ ROUTE_ORIGIN_STATIC = 255,
};
std::ostream&
@@ -105,7 +102,7 @@
enum RouteFlags {
ROUTE_FLAGS_NONE = 0,
ROUTE_FLAG_CHILD_INHERIT = 1,
- ROUTE_FLAG_CAPTURE = 2
+ ROUTE_FLAG_CAPTURE = 2,
};
std::ostream&
diff --git a/src/mgmt/nfd/face-event-notification.cpp b/src/mgmt/nfd/face-event-notification.cpp
index 81ef384..505026b 100644
--- a/src/mgmt/nfd/face-event-notification.cpp
+++ b/src/mgmt/nfd/face-event-notification.cpp
@@ -189,24 +189,6 @@
}
std::ostream&
-operator<<(std::ostream& os, FaceEventKind kind)
-{
- switch (kind) {
- case FACE_EVENT_NONE:
- return os << "none";
- case FACE_EVENT_CREATED:
- return os << "created";
- case FACE_EVENT_DESTROYED:
- return os << "destroyed";
- case FACE_EVENT_UP:
- return os << "up";
- case FACE_EVENT_DOWN:
- return os << "down";
- }
- return os << static_cast<unsigned>(kind);
-}
-
-std::ostream&
operator<<(std::ostream& os, const FaceEventNotification& notification)
{
os << "FaceEvent(Kind: " << notification.getKind() << ",\n"
diff --git a/src/mgmt/nfd/face-event-notification.hpp b/src/mgmt/nfd/face-event-notification.hpp
index 06836e7..1c6ae4c 100644
--- a/src/mgmt/nfd/face-event-notification.hpp
+++ b/src/mgmt/nfd/face-event-notification.hpp
@@ -29,20 +29,6 @@
/**
* \ingroup management
- */
-enum FaceEventKind {
- FACE_EVENT_NONE = 0,
- FACE_EVENT_CREATED = 1, ///< face created
- FACE_EVENT_DESTROYED = 2, ///< face destroyed
- FACE_EVENT_UP = 3, ///< face went UP (from DOWN state)
- FACE_EVENT_DOWN = 4 ///< face went DOWN (from UP state)
-};
-
-std::ostream&
-operator<<(std::ostream& os, FaceEventKind kind);
-
-/**
- * \ingroup management
* \brief represents a Face status change notification
* \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Status-Change-Notification
*/
diff --git a/tests/unit-tests/encoding/nfd-constants.t.cpp b/tests/unit-tests/encoding/nfd-constants.t.cpp
index 6146307..2dbb580 100644
--- a/tests/unit-tests/encoding/nfd-constants.t.cpp
+++ b/tests/unit-tests/encoding/nfd-constants.t.cpp
@@ -31,7 +31,7 @@
BOOST_AUTO_TEST_SUITE(Encoding)
BOOST_AUTO_TEST_SUITE(TestNfdConstants)
-BOOST_AUTO_TEST_CASE(FaceScopeOutputStream)
+BOOST_AUTO_TEST_CASE(PrintFaceScope)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_SCOPE_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_SCOPE_NON_LOCAL), "non-local");
@@ -39,7 +39,7 @@
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FaceScope>(126)), "126");
}
-BOOST_AUTO_TEST_CASE(FacePersistencyOutputStream)
+BOOST_AUTO_TEST_CASE(PrintFacePersistency)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_ON_DEMAND), "on-demand");
@@ -48,7 +48,7 @@
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FacePersistency>(110)), "110");
}
-BOOST_AUTO_TEST_CASE(LinkTypeOutputStream)
+BOOST_AUTO_TEST_CASE(PrintLinkType)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_POINT_TO_POINT), "point-to-point");
@@ -56,7 +56,17 @@
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<LinkType>(104)), "104");
}
-BOOST_AUTO_TEST_CASE(RouteOriginOutputStream)
+BOOST_AUTO_TEST_CASE(PrintFaceEventKind)
+{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_NONE), "none");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_CREATED), "created");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_DESTROYED), "destroyed");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_UP), "up");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_DOWN), "down");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FaceEventKind>(175)), "175");
+}
+
+BOOST_AUTO_TEST_CASE(PrintRouteOrigin)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_APP), "app");
@@ -68,17 +78,15 @@
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteOrigin>(27)), "27");
}
-BOOST_AUTO_TEST_CASE(RouteFlagsOutputStream)
+BOOST_AUTO_TEST_CASE(PrintRouteFlags)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAGS_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAG_CHILD_INHERIT), "child-inherit");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAG_CAPTURE), "capture");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteFlags>(
- ROUTE_FLAG_CHILD_INHERIT | ROUTE_FLAG_CAPTURE)),
- "child-inherit|capture");
+ ROUTE_FLAG_CHILD_INHERIT | ROUTE_FLAG_CAPTURE)), "child-inherit|capture");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteFlags>(
- ROUTE_FLAG_CAPTURE | static_cast<RouteFlags>(0x9c))),
- "capture|0x9c");
+ ROUTE_FLAG_CAPTURE | 0x9c)), "capture|0x9c");
}
BOOST_AUTO_TEST_SUITE_END() // TestNfdConstants