src/misc/DocumentPointer.h

changeset 675
450827da2376
parent 629
b75c6cce02e2
child 641
425b169a82aa
equal deleted inserted replaced
674:3d8ab0f89102 675:450827da2376
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013, 2014 Santeri Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef LDFORGE_DOCUMENT_POINTER_H
20 #define LDFORGE_DOCUMENT_POINTER_H
21
22 #include "../Main.h"
23
24 class LDSubfile;
25 class LDDocument;
26
27 class LDDocumentPointer
28 {
29 PROPERTY (private, LDDocument*, Pointer, NO_OPS, STOCK_WRITE)
30
31 public:
32 LDDocumentPointer();
33 LDDocumentPointer (LDDocument* ptr);
34 LDDocumentPointer (const LDDocumentPointer& other);
35 ~LDDocumentPointer();
36 LDDocumentPointer& operator= (LDDocument* ptr);
37
38 inline LDDocumentPointer& operator= (LDDocumentPointer& other)
39 {
40 return operator= (other.getPointer());
41 }
42
43 inline LDDocument* operator->() const
44 {
45 return getPointer();
46 }
47
48 inline operator LDDocument*() const
49 {
50 return getPointer();
51 }
52
53 private:
54 void addReference();
55 void removeReference();
56 };
57
58 #endif // LDFORGE_DOCUMENT_POINTER_H

mercurial