From a9353c965a4b029f1d94c0ed0bc9730c4234756d Mon Sep 17 00:00:00 2001 From: Kalman Date: Wed, 24 Oct 2018 11:16:19 +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..8ba3bca 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) << Name() << " process with invalid input"; + return false; + } { std::lock_guard lk(mtx_input_ready_); input_.reset(in.Clone());