/src/xpdf-4.05/xpdf/Array.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // Array.h |
4 | | // |
5 | | // Copyright 1996-2003 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | #ifndef ARRAY_H |
10 | | #define ARRAY_H |
11 | | |
12 | | #include <aconf.h> |
13 | | |
14 | | #if MULTITHREADED |
15 | | #include "GMutex.h" |
16 | | #endif |
17 | | #include "Object.h" |
18 | | |
19 | | class XRef; |
20 | | |
21 | | //------------------------------------------------------------------------ |
22 | | // Array |
23 | | //------------------------------------------------------------------------ |
24 | | |
25 | | class Array { |
26 | | public: |
27 | | |
28 | | // Constructor. |
29 | | Array(XRef *xrefA); |
30 | | |
31 | | // Destructor. |
32 | | ~Array(); |
33 | | |
34 | | // Reference counting. |
35 | | #if MULTITHREADED |
36 | 543k | long incRef() { return gAtomicIncrement(&ref); } |
37 | 1.22M | long decRef() { return gAtomicDecrement(&ref); } |
38 | | #else |
39 | | long incRef() { return ++ref; } |
40 | | long decRef() { return --ref; } |
41 | | #endif |
42 | | |
43 | | // Get number of elements. |
44 | 11.8M | int getLength() { return length; } |
45 | | |
46 | | // Add an element. |
47 | | void add(Object *elem); |
48 | | |
49 | | // Accessors. |
50 | | Object *get(int i, Object *obj, int recursion = 0); |
51 | | Object *getNF(int i, Object *obj); |
52 | | |
53 | | private: |
54 | | |
55 | | XRef *xref; // the xref table for this PDF file |
56 | | Object *elems; // array of elements |
57 | | int size; // size of <elems> array |
58 | | int length; // number of elements in array |
59 | | #if MULTITHREADED |
60 | | GAtomicCounter ref; // reference count |
61 | | #else |
62 | | long ref; // reference count |
63 | | #endif |
64 | | }; |
65 | | |
66 | | #endif |