CVB++ 14.0
four_state_royal_mail.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
13
15
18 {
19public:
20
22
27 void SetEvaluateCheckDigit(bool evalCheckDigit)
28 {
29 SetDirty();
30 evalCheckDigit_ = evalCheckDigit;
31 }
32
34
39 bool EvaluateCheckDigit() const
40 {
41 return evalCheckDigit_;
42 };
43
44
46
51 void SetTransmitCheckDigit(bool transmitCheckDigit)
52 {
53 SetDirty();
54 transmitCheckDigit_ = transmitCheckDigit;
55 };
56
58
63 bool TransmitCheckDigit() const
64 {
65 return transmitCheckDigit_;
66 };
67
69
74 void SetTransmitStartStop(bool transmitStartStop)
75 {
76 SetDirty();
77 transmitStartStop_ = transmitStartStop;
78 };
79
81
86 bool TransmitStartStop() const
87 {
88 return transmitStartStop_;
89 };
90
91
93
98 void SetMinDigits(int minDigits)
99 {
100 if(minDigits < minDigitsLimit_ ||
101 minDigits > maxDigits_)
102 throw std::runtime_error("MinDigits out of range");
103 if(minDigits_ != minDigits)
104 SetDirty();
105 minDigits_ = static_cast<short>(minDigits);
106 }
107
109
114 int MinDigits() const
115 {
116 return static_cast<int>(minDigits_);
117 };
118
119
121
126 void SetMaxDigits(int maxDigits)
127 {
128 if(maxDigits < minDigits_ ||
129 maxDigits > maxDigitsLimit_)
130 throw std::runtime_error("MaxDigits out of range");
131 if(maxDigits_ != maxDigits)
132 SetDirty();
133 maxDigits_ = static_cast<short>(maxDigits);
134 }
135
137
142 int MaxDigits() const
143 {
144 return static_cast<int>(maxDigits_);
145 };
146
148
154 {
155 if(orientation_ != orientation)
156 SetDirty();
157 orientation_ = orientation;
158 }
159
161
167 {
168 return orientation_;
169 };
170
171
172
173 protected:
174 SmartBool evalCheckDigit_;
175 SmartBool transmitCheckDigit_;
176 SmartBool transmitStartStop_;
177 short minDigits_;
178 short maxDigits_;
179 CodeOrientation orientation_;
180
181
182
183
184 const short minDigitsLimit_ = 7;
185 const short maxDigitsLimit_ = 13;
186
187
188 public:
189 virtual Symbology Type() const override { return Symbology::FourStateRoyalMail; };
190
192
198 static std::unique_ptr<FourStateRoyalMail> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
199 {
201 isActiveOut = pConfig->ReadFromHandle(guard);
202 return pConfig;
203 }
204
205 protected:
206 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
207 {
208 CExports::cvbbool_t active;
209 short tmpOrientation;
210 CVB_CALL_CAPI(CvcBcGetFourStateRoyalMail(reinterpret_cast<std::intptr_t>(guard.Handle()),
211 &active,
212 &minDigits_,
213 &maxDigits_,
214 &tmpOrientation,
215 &threshold_,
216 inverse_.Ptr(),
217 mirrored_.Ptr(),
218 &quietzoneWidth_,
219 evalCheckDigit_.Ptr(),
220 transmitCheckDigit_.Ptr(),
221 transmitStartStop_.Ptr()
222 ));
223 orientation_ = static_cast<CodeOrientation>(tmpOrientation);
224 return SmartBool(active);
225 }
226
227 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
228 {
229 Internal::DoResCall([&]()
230 {
231 return CVB_CALL_CAPI(CvcBcSetFourStateRoyalMail(reinterpret_cast<std::intptr_t>(guard.Handle()),
232 active,
233 minDigits_,
234 maxDigits_,
235 static_cast<short>(orientation_),
236 threshold_,
237 inverse_,
238 mirrored_,
239 quietzoneWidth_,
240 evalCheckDigit_,
241 transmitCheckDigit_,
242 transmitStartStop_
243 ));
244 });
245 }
246 protected:
247 FourStateRoyalMail()
248 : ReaderFourStateConfigBase()
249 {
250 }
251
252 };
253
254 using FourStateRoyalMailPtr = std::shared_ptr<FourStateRoyalMail>;
255 }
256
257 CVB_END_INLINE_NS
258}
Configuration to access parameters of ReaderFourStateConfigBase.
Definition: reader_four_state_config_base.hpp:20
Configuration to access parameters of FourStateRoyalMail (4-State RoyalMail Postal Code).
Definition: four_state_royal_mail.hpp:18
void SetMinDigits(int minDigits)
Sets the minimum number of the 4-State Royal Mail code words.
Definition: four_state_royal_mail.hpp:98
bool EvaluateCheckDigit() const
Returns whether to evaluate/ignore check digit.
Definition: four_state_royal_mail.hpp:39
CodeOrientation Orientation() const
Returns the direction of the 4-State Royal Mail in the picture.
Definition: four_state_royal_mail.hpp:166
int MaxDigits() const
Returns the maximum number of the 4-State Royal Mail code words.
Definition: four_state_royal_mail.hpp:142
int MinDigits() const
Returns the minimum number of the 4-State Royal Mail code words.
Definition: four_state_royal_mail.hpp:114
bool TransmitStartStop() const
Returns whether to transmit start and stop digits with data.
Definition: four_state_royal_mail.hpp:86
void SetTransmitCheckDigit(bool transmitCheckDigit)
Sets whether to append check digit to data.
Definition: four_state_royal_mail.hpp:51
void SetOrientation(CodeOrientation orientation)
Sets the direction of the 4-State Royal Mail in the picture.
Definition: four_state_royal_mail.hpp:153
void SetTransmitStartStop(bool transmitStartStop)
Sets whether to transmit start and stop digits with data.
Definition: four_state_royal_mail.hpp:74
bool TransmitCheckDigit() const
Returns whether to append check digit to data.
Definition: four_state_royal_mail.hpp:63
void SetMaxDigits(int maxDigits)
Sets the maximum number of the 4-State Royal Mail code words.
Definition: four_state_royal_mail.hpp:126
void SetEvaluateCheckDigit(bool evalCheckDigit)
Sets whether to evaluate/ignore check digit.
Definition: four_state_royal_mail.hpp:27
static std::unique_ptr< FourStateRoyalMail > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_royal_mail.hpp:198
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ FourStateRoyalMail
Four State Royal Mail Barcode.
CodeOrientation
Directions that a four state code may have.
Definition: barcode.hpp:190
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24