From 9716c20bcac0942887ab4e3be3748ccb99612f85 Mon Sep 17 00:00:00 2001 From: Osenberg Date: Fri, 29 Mar 2019 20:18:53 +0800 Subject: [PATCH] feat(src): added device sort function --- src/mynteye/device/utils.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mynteye/device/utils.cc b/src/mynteye/device/utils.cc index 075210a..bff87b7 100644 --- a/src/mynteye/device/utils.cc +++ b/src/mynteye/device/utils.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "mynteye/device/utils.h" +#include #include #include "mynteye/logger.h" @@ -20,10 +21,14 @@ #include "mynteye/device/context.h" #include "mynteye/device/device.h" -#include "mynteye/logger.h" - MYNTEYE_BEGIN_NAMESPACE +bool sort_sn(std::shared_ptr device1, + std::shared_ptr device2) { + return device1->GetInfo(Info::SERIAL_NUMBER) < + device2->GetInfo(Info::SERIAL_NUMBER); +} + namespace device { std::shared_ptr select() { @@ -37,6 +42,9 @@ std::shared_ptr select() { return nullptr; } + if (n > 1) + sort(devices.begin(), devices.end(), sort_sn); + LOG(INFO) << "MYNT EYE devices:"; for (std::size_t i = 0; i < n; i++) { auto &&device = devices[i];