Add add-ons enum type

This commit is contained in:
John Zhao 2018-05-04 13:44:13 +08:00
parent 8b21989dcc
commit 2e31a79b1a
4 changed files with 37 additions and 1 deletions

View File

@ -165,6 +165,19 @@ enum class Source : std::uint8_t {
LAST
};
/**
* @ingroup enumerations
* @brief Add-Ons are peripheral modules of our hardware.
*/
enum class AddOns : std::uint8_t {
/** Infrared */
INFRARED,
/** Second infrared */
INFRARED2,
/** Last guard */
LAST
};
#define MYNTEYE_ENUM_HELPERS(TYPE) \
MYNTEYE_API const char *to_string(const TYPE &value); \
inline bool is_valid(const TYPE &value) { \
@ -187,6 +200,7 @@ MYNTEYE_ENUM_HELPERS(Capabilities)
MYNTEYE_ENUM_HELPERS(Info)
MYNTEYE_ENUM_HELPERS(Option)
MYNTEYE_ENUM_HELPERS(Source)
MYNTEYE_ENUM_HELPERS(AddOns)
#undef MYNTEYE_ENUM_HELPERS

View File

@ -122,6 +122,19 @@ const char *to_string(const Source &value) {
#undef CASE
}
const char *to_string(const AddOns &value) {
#define CASE(X) \
case AddOns::X: \
return "AddOns::" #X;
switch (value) {
CASE(INFRARED)
CASE(INFRARED2)
default:
return "AddOns::UNKNOWN";
}
#undef CASE
}
const char *to_string(const Format &value) {
#define CASE(X) \
case Format::X: \

View File

@ -52,6 +52,9 @@ message(STATUS "Found mynteye: ${mynteye_VERSION}")
LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
find_package(OpenCV REQUIRED)
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
## gtest
set(TEST_DIR ${PROJECT_SOURCE_DIR})
@ -93,9 +96,10 @@ add_executable(${PROJECT_NAME}
${TEST_INTERNAL_SRC}
${TEST_PUBLIC_SRC}
)
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBS} mynteye)
target_link_libraries(${PROJECT_NAME} mynteye ${GTEST_LIBS} ${OpenCV_LIBS})
target_create_scripts(${PROJECT_NAME} DLL_SEARCH_PATHS
${PRO_DIR}/_install/bin
${OpenCV_LIB_SEARCH_PATH}
)
if(OS_WIN)

View File

@ -68,6 +68,11 @@ TEST(Source, VerifyToString) {
EXPECT_STREQ("Source::ALL", to_string(Source::ALL));
}
TEST(AddOns, VerifyToString) {
EXPECT_STREQ("AddOns::INFRARED", to_string(AddOns::INFRARED));
EXPECT_STREQ("AddOns::INFRARED2", to_string(AddOns::INFRARED2));
}
TEST(Format, VerifyToString) {
EXPECT_STREQ("Format::GREY", to_string(Format::GREY));
EXPECT_STREQ("Format::YUYV", to_string(Format::YUYV));