CVB++ 14.0
four_state_kix.hpp
1#pragma once
2
3#include "reader_four_state_config_base.hpp"
4
5namespace Cvb
6{
7 CVB_BEGIN_INLINE_NS
8
9 namespace Barcode
10 {
11 using namespace Internal;
12
14
17 {
18public:
19
21
27 {
28 if(lsb_ != lsb)
29 SetDirty();
30 lsb_ = lsb;
31 }
32
34
40 {
41 return lsb_;
42 };
43
44
46
51 void SetMinDigits(int minDigits)
52 {
53 if(minDigits < minDigitsLimit_ ||
54 minDigits > maxDigits_)
55 throw std::runtime_error("MinDigits out of range");
56 if(minDigits_ != minDigits)
57 SetDirty();
58 minDigits_ = static_cast<short>(minDigits);
59 }
60
62
67 int MinDigits() const
68 {
69 return static_cast<int>(minDigits_);
70 };
71
72
74
79 void SetMaxDigits(int maxDigits)
80 {
81 if(maxDigits < minDigits_ ||
82 maxDigits > maxDigitsLimit_)
83 throw std::runtime_error("MaxDigits out of range");
84 if(maxDigits_ != maxDigits)
85 SetDirty();
86 maxDigits_ = static_cast<short>(maxDigits);
87 }
88
90
95 int MaxDigits() const
96 {
97 return static_cast<int>(maxDigits_);
98 };
99
100
101 protected:
102 FourStateLsb lsb_;
103 short minDigits_;
104 short maxDigits_;
105
106 const short minDigitsLimit_ = 6;
107 const short maxDigitsLimit_ = 18;
108
109 public:
110 virtual Symbology Type() const override { return Symbology::FourStateKix; };
111
113
119 static std::unique_ptr<FourStateKix> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
120 {
121 auto pConfig = std::unique_ptr<FourStateKix>(new FourStateKix());
122 isActiveOut = pConfig->ReadFromHandle(guard);
123 return pConfig;
124 }
125
126 protected:
127 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
128 {
129 CExports::cvbbool_t active;
130 short tmpLsb;
131 CVB_CALL_CAPI(CvcBcGetFourStateKix(reinterpret_cast<std::intptr_t>(guard.Handle()),
132 &active,
133 &minDigits_,
134 &maxDigits_,
135 &tmpLsb,
136 &threshold_,
137 inverse_.Ptr(),
138 mirrored_.Ptr(),
139 &quietzoneWidth_
140 ));
141 lsb_ = static_cast<FourStateLsb>(tmpLsb);
142 return SmartBool(active);
143 }
144
145 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
146 {
147 Internal::DoResCall([&]()
148 {
149 return CVB_CALL_CAPI(CvcBcSetFourStateKix(reinterpret_cast<std::intptr_t>(guard.Handle()),
150 SmartBool(active),
151 minDigits_,
152 maxDigits_,
153 static_cast<short>(lsb_),
154 threshold_,
155 inverse_,
156 mirrored_,
157 quietzoneWidth_
158 ));
159 });
160 }
161 protected:
162 FourStateKix()
163 : ReaderFourStateConfigBase()
164 {
165 }
166
167 };
168
169 using FourStateKixPtr = std::shared_ptr<FourStateKix>;
170 }
171
172 CVB_END_INLINE_NS
173}
Configuration to access parameters of ReaderFourStateConfigBase.
Definition: reader_four_state_config_base.hpp:20
Configuration to access parameters of FourStateKix.
Definition: four_state_kix.hpp:17
void SetMinDigits(int minDigits)
Sets the minimum number of the 4-State Kix code words.
Definition: four_state_kix.hpp:51
int MaxDigits() const
Returns the maximum number of the 4-State Kix code words.
Definition: four_state_kix.hpp:95
int MinDigits() const
Returns the minimum number of the 4-State Kix code words.
Definition: four_state_kix.hpp:67
static std::unique_ptr< FourStateKix > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_kix.hpp:119
FourStateLsb LsbPosition() const
Returns the position of the "low significant bit" of the code in the image.
Definition: four_state_kix.hpp:39
void SetMaxDigits(int maxDigits)
Sets the maximum number of the 4-State Kix code words.
Definition: four_state_kix.hpp:79
void SetLsbPosition(FourStateLsb lsb)
Sets the position of the "low significant bit" of the code in the image.
Definition: four_state_kix.hpp:26
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ FourStateKix
Four State KIX Barcode.
FourStateLsb
LSB settings for four state codes.
Definition: barcode.hpp:226
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24