postnet.hpp
1 #pragma once
2 
3 #include "reader_planet_postnet_config_base.hpp"
4 
5 namespace Cvb
6 {
7  CVB_BEGIN_INLINE_NS
8 
9  namespace Barcode
10  {
11  using namespace Internal;
12 
14 
17  {
18 public:
19 
21 
26  void SetLevels(PostnetLevels levels)
27  {
28  if(levels_ != levels)
29  SetDirty();
30  levels_ = levels;
31  }
32 
34 
40  {
41  return levels_;
42  };
43 
44 
45 
46  protected:
47  PostnetLevels levels_;
48 
49 
50  public:
51  virtual Symbology Type() const override { return Symbology::Postnet; };
52 
54 
60  static std::unique_ptr<Postnet> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
61  {
62  auto pConfig = std::unique_ptr<Postnet>(new Postnet());
63  isActiveOut = pConfig->ReadFromHandle(guard);
64  return pConfig;
65  }
66 
67  protected:
68  virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
69  {
70  CExports::cvbbool_t active;
71  unsigned short tmpLevels;
72  short tmpOrientation;
73  CVB_CALL_CAPI(CvcBcGetPostnet(reinterpret_cast<std::intptr_t>(guard.Handle()),
74  &active,
75  &tmpLevels,
76  &tmpOrientation,
77  &threshold_,
78  inverse_.Ptr(),
79  mirrored_.Ptr(),
80  evalCheckDigit_.Ptr(),
81  transmitCheckDigit_.Ptr(),
82  &quietzoneWidth_
83  ));
84  levels_ = static_cast<PostnetLevels>(tmpLevels);
85  orientation_ = static_cast<CodeOrientation>(tmpOrientation);
86  return SmartBool(active);
87  }
88 
89  virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
90  {
91  Internal::DoResCall([&]()
92  {
93  return CVB_CALL_CAPI(CvcBcSetPostnet(reinterpret_cast<std::intptr_t>(guard.Handle()),
94  active,
95  static_cast<unsigned short>(levels_),
96  static_cast<short>(orientation_),
97  threshold_,
98  inverse_,
99  mirrored_,
100  evalCheckDigit_,
101  transmitCheckDigit_,
102  quietzoneWidth_
103  ));
104  });
105  }
106  protected:
107  Postnet()
108  : ReaderPlanetPostnetConfigBase()
109  {
110  }
111 
112  };
113 
114  using PostnetPtr = std::shared_ptr<Postnet>;
115  }
116 
117  CVB_END_INLINE_NS
118 }
STL class.
PostnetLevels Levels() const
Returns the levels for the allowed code types.
Definition: postnet.hpp:39
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:96
void SetLevels(PostnetLevels levels)
Specifies the levels for the allowed code types.
Definition: postnet.hpp:26
static std::unique_ptr< Postnet > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: postnet.hpp:60
Configuration to access parameters of Postnet.
Definition: postnet.hpp:16
Configuration to access parameters of ReaderPlanetPostnetConfigBase.
Definition: reader_planet_postnet_config_base.hpp:19
Root namespace for the Image Manager interface.
Definition: version.hpp:11
virtual Symbology Type() const override
Symbology of configuration object.
Definition: postnet.hpp:51
PostnetLevels
Available level flags for Postnet codes.
Definition: barcode.hpp:251
STL class.