1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef _BC_DATAMATRIXVERSION_H_
8 #define _BC_DATAMATRIXVERSION_H_
9 class ECBlocks;
10 class CBC_DataMatrixVersion;
11 class ECB {
12  public:
ECB(int32_t count,int32_t dataCodewords)13   ECB(int32_t count, int32_t dataCodewords) {
14     m_count = count;
15     m_dataCodewords = dataCodewords;
16   }
17 
GetCount()18   int32_t GetCount() { return m_count; }
19 
GetDataCodewords()20   int32_t GetDataCodewords() { return m_dataCodewords; }
21 
22  private:
23   int32_t m_count;
24   int32_t m_dataCodewords;
25 };
26 class ECBlocks {
27  public:
ECBlocks(int32_t ecCodewords,ECB * ecBlocks)28   ECBlocks(int32_t ecCodewords, ECB* ecBlocks) {
29     m_ecCodewords = ecCodewords;
30     m_ecBlocks.Add(ecBlocks);
31   }
32 
ECBlocks(int32_t ecCodewords,ECB * ecBlocks1,ECB * ecBlocks2)33   ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) {
34     m_ecCodewords = ecCodewords;
35     m_ecBlocks.Add(ecBlocks1);
36     m_ecBlocks.Add(ecBlocks2);
37   }
~ECBlocks()38   ~ECBlocks() {
39     for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
40       delete (ECB*)m_ecBlocks[i];
41     }
42     m_ecBlocks.RemoveAll();
43   }
44 
GetECCodewords()45   int32_t GetECCodewords() { return m_ecCodewords; }
46 
GetECBlocks()47   const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; }
48 
49  private:
50   int32_t m_ecCodewords;
51   CFX_PtrArray m_ecBlocks;
52 };
53 class CBC_DataMatrixVersion {
54  public:
55   CBC_DataMatrixVersion(int32_t versionNumber,
56                         int32_t symbolSizeRows,
57                         int32_t symbolSizeColumns,
58                         int32_t dataRegionSizeRows,
59                         int32_t dataRegionSizeColumns,
60                         ECBlocks* ecBlocks);
61   virtual ~CBC_DataMatrixVersion();
62   static void Initialize();
63   static void Finalize();
64   int32_t GetVersionNumber();
65   int32_t GetSymbolSizeRows();
66   int32_t GetSymbolSizeColumns();
67   int32_t GetDataRegionSizeRows();
68   int32_t GetDataRegionSizeColumns();
69   int32_t GetTotalCodewords();
70   ECBlocks* GetECBlocks();
71   static CBC_DataMatrixVersion* GetVersionForDimensions(int32_t numRows,
72                                                         int32_t numColumns,
73                                                         int32_t& e);
74   static void ReleaseAll();
75 
76  private:
77   int32_t m_versionNumber;
78   int32_t m_symbolSizeRows;
79   int32_t m_symbolSizeColumns;
80   int32_t m_dataRegionSizeRows;
81   int32_t m_dataRegionSizeColumns;
82   ECBlocks* m_ecBlocks;
83   int32_t m_totalCodewords;
84   static CFX_PtrArray* VERSIONS;
85 };
86 #endif
87