From c2f04c487e5f21d5ab5e7c0096e0d97d5c8f3089 Mon Sep 17 00:00:00 2001 From: junyang Date: Wed, 11 Jul 2018 02:05:44 +0800 Subject: [PATCH] Increase the effectiveness of checking all values. --- src/api/processor/object.h | 9 +++++++++ src/api/processor/processor.cc | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/api/processor/object.h b/src/api/processor/object.h index 8f43829..808b150 100644 --- a/src/api/processor/object.h +++ b/src/api/processor/object.h @@ -31,6 +31,7 @@ struct MYNTEYE_API Object { virtual ~Object() = default; virtual Object *Clone() const = 0; + virtual bool DecValidity() const = 0; /** Cast the obj to T pointer */ template @@ -65,6 +66,10 @@ struct MYNTEYE_API ObjMat : public Object { mat->value = value.clone(); return mat; } + + bool DecValidity() const { + return !value.empty(); + } }; /** @@ -87,6 +92,10 @@ struct MYNTEYE_API ObjMat2 : public Object { mat2->second = second.clone(); return mat2; } + + bool DecValidity() const { + return !first.empty() && !second.empty(); + } }; MYNTEYE_END_NAMESPACE diff --git a/src/api/processor/processor.cc b/src/api/processor/processor.cc index 851b464..067cfe3 100644 --- a/src/api/processor/processor.cc +++ b/src/api/processor/processor.cc @@ -130,6 +130,10 @@ bool Processor::Process(const Object &in) { return false; } } + if (!in.DecValidity()){ + LOG(WARNING) << "Input is invalid"; + return false; + } { std::lock_guard lk(mtx_input_ready_); input_.reset(in.Clone());