src/misc/DocumentPointer.h

Wed, 05 Mar 2014 20:49:28 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 05 Mar 2014 20:49:28 +0200
changeset 652
5d37b2f2ae16
parent 642
751a8df42842
permissions
-rw-r--r--

- doxygen'd DocumentPointer.h

629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
641
425b169a82aa - changed header guards into #pragma once
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
19 #pragma once
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "../Main.h"
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 class LDSubfile;
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 class LDDocument;
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
26 //!
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
27 //! \brief A reference-counting pointer to LDDocument.
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
28 //!
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
29 //! The LDDocumentPointer class defines a reference-counting pointer which
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
30 //! points to LDDocument.
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
31 //!
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 class LDDocumentPointer
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 {
642
751a8df42842 - migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents: 641
diff changeset
34 PROPERTY (private, LDDocument*, pointer, setPointer, STOCK_WRITE)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 public:
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
37 //! Constructs a null LDDocumentPointer
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 LDDocumentPointer();
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
39
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
40 //! Constructs a document pointer with the given pointer
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 LDDocumentPointer (LDDocument* ptr);
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
42
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
43 //! Copy-constructs a LDDocumentPointer.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 LDDocumentPointer (const LDDocumentPointer& other);
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
45
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
46 //! Destructs the pointer.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 ~LDDocumentPointer();
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
48
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
49 //! \param ptr the new pointer to change to.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 LDDocumentPointer& operator= (LDDocument* ptr);
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
52 //! Copy operator.
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
53 //! \param other the pointer whose internal pointer to copy.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 inline LDDocumentPointer& operator= (LDDocumentPointer& other)
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 {
642
751a8df42842 - migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents: 641
diff changeset
56 return operator= (other.pointer());
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
59 //! Operator overload for a->b support.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 inline LDDocument* operator->() const
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 {
642
751a8df42842 - migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents: 641
diff changeset
62 return pointer();
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
652
5d37b2f2ae16 - doxygen'd DocumentPointer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 642
diff changeset
65 //! Cast operator overload
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 inline operator LDDocument*() const
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 {
642
751a8df42842 - migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents: 641
diff changeset
68 return pointer();
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 private:
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 void addReference();
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 void removeReference();
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 };

mercurial