This is the sample program that can see the decode result of barcode data on Watson IoT.
Dependencies: AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice
Counted.h
00001 // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 00002 #ifndef __COUNTED_H__ 00003 #define __COUNTED_H__ 00004 00005 /* 00006 * Copyright 2010 ZXing authors All rights reserved. 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 00021 #include <iostream> 00022 00023 namespace zxing { 00024 00025 /* base class for reference-counted objects */ 00026 class Counted { 00027 private: 00028 unsigned int count_; 00029 public: 00030 Counted() : 00031 count_(0) { 00032 } 00033 virtual ~Counted() { 00034 } 00035 Counted *retain() { 00036 count_++; 00037 return this; 00038 } 00039 void release() { 00040 count_--; 00041 if (count_ == 0) { 00042 count_ = 0xDEADF001; 00043 delete this; 00044 } 00045 } 00046 00047 00048 /* return the current count for denugging purposes or similar */ 00049 int count() const { 00050 return count_; 00051 } 00052 }; 00053 00054 /* counting reference to reference-counted objects */ 00055 template<typename T> class Ref { 00056 private: 00057 public: 00058 T *object_; 00059 explicit Ref(T *o = 0) : 00060 object_(0) { 00061 reset(o); 00062 } 00063 Ref(const Ref &other) : 00064 object_(0) { 00065 reset(other.object_); 00066 } 00067 00068 template<class Y> 00069 Ref(const Ref<Y> &other) : 00070 object_(0) { 00071 reset(other.object_); 00072 } 00073 00074 ~Ref() { 00075 if (object_) { 00076 object_->release(); 00077 } 00078 } 00079 00080 void reset(T *o) { 00081 if (o) { 00082 o->retain(); 00083 } 00084 if (object_ != 0) { 00085 object_->release(); 00086 } 00087 object_ = o; 00088 } 00089 Ref& operator=(const Ref &other) { 00090 reset(other.object_); 00091 return *this; 00092 } 00093 template<class Y> 00094 Ref& operator=(const Ref<Y> &other) { 00095 reset(other.object_); 00096 return *this; 00097 } 00098 Ref& operator=(T* o) { 00099 reset(o); 00100 return *this; 00101 } 00102 template<class Y> 00103 Ref& operator=(Y* o) { 00104 reset(o); 00105 return *this; 00106 } 00107 00108 T& operator*() { 00109 return *object_; 00110 } 00111 T* operator->() const { 00112 return object_; 00113 } 00114 operator T*() const { 00115 return object_; 00116 } 00117 00118 bool operator==(const T* that) { 00119 return object_ == that; 00120 } 00121 bool operator==(const Ref &other) const { 00122 return object_ == other.object_ || *object_ == *(other.object_); 00123 } 00124 template<class Y> 00125 bool operator==(const Ref<Y> &other) const { 00126 return object_ == other.object_ || *object_ == *(other.object_); 00127 } 00128 00129 bool operator!=(const T* that) { 00130 return !(*this == that); 00131 } 00132 00133 bool empty() const { 00134 return object_ == 0; 00135 } 00136 }; 00137 00138 } 00139 00140 #endif // __COUNTED_H__
Generated on Tue Jul 12 2022 18:38:05 by 1.7.2