OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_COUNTEDOBJECT_H_ | 7 #ifndef CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_COUNTEDOBJECT_H_ | 8 #define CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_ |
9 | 9 |
10 #include "core/fpdfapi/fpdf_page/cpdf_colorspace.h" | 10 #include "core/fpdfapi/page/cpdf_colorspace.h" |
11 #include "core/fpdfapi/fpdf_page/cpdf_pattern.h" | 11 #include "core/fpdfapi/page/cpdf_pattern.h" |
12 #include "core/fxcrt/fx_system.h" | 12 #include "core/fxcrt/fx_system.h" |
13 | 13 |
14 template <class T> | 14 template <class T> |
15 class CPDF_CountedObject { | 15 class CPDF_CountedObject { |
16 public: | 16 public: |
17 explicit CPDF_CountedObject(T* ptr) : m_nCount(1), m_pObj(ptr) {} | 17 explicit CPDF_CountedObject(T* ptr) : m_nCount(1), m_pObj(ptr) {} |
18 void reset(T* ptr) { // CAUTION: tosses prior ref counts. | 18 void reset(T* ptr) { // CAUTION: tosses prior ref counts. |
19 m_nCount = 1; | 19 m_nCount = 1; |
20 m_pObj = ptr; | 20 m_pObj = ptr; |
21 } | 21 } |
(...skipping 15 matching lines...) Expand all Loading... |
37 } | 37 } |
38 size_t use_count() const { return m_nCount; } | 38 size_t use_count() const { return m_nCount; } |
39 | 39 |
40 protected: | 40 protected: |
41 size_t m_nCount; | 41 size_t m_nCount; |
42 T* m_pObj; | 42 T* m_pObj; |
43 }; | 43 }; |
44 using CPDF_CountedColorSpace = CPDF_CountedObject<CPDF_ColorSpace>; | 44 using CPDF_CountedColorSpace = CPDF_CountedObject<CPDF_ColorSpace>; |
45 using CPDF_CountedPattern = CPDF_CountedObject<CPDF_Pattern>; | 45 using CPDF_CountedPattern = CPDF_CountedObject<CPDF_Pattern>; |
46 | 46 |
47 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COUNTEDOBJECT_H_ | 47 #endif // CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_ |
OLD | NEW |