src/misc/documentPointer.cc

Tue, 21 Jan 2014 01:05:03 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 21 Jan 2014 01:05:03 +0200
changeset 672
0925d25ea32c
parent 607
353e418f161a
permissions
-rw-r--r--

- renamed VertexCompiler to GLCompiler

584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
600
209e3f1f7b2c - updated copyright year. Best wishes for 2014!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 590
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "documentPointer.h"
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "../document.h"
607
353e418f161a - corrected relationships between documents: opening a main file with the same name as another document is to overload it and editing the document is to invalidate its cache so that it gets rendered properly in other documents possibly referencing it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
21 #include "../misc.h"
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 LDDocumentPointer::LDDocumentPointer() : m_Pointer (null) {}
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 LDDocumentPointer::LDDocumentPointer (LDDocument* ptr) :
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 m_Pointer (ptr)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
29 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
30 addReference ();
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 }
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 LDDocumentPointer::LDDocumentPointer (const LDDocumentPointer& other) :
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 m_Pointer (other.getPointer())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
37 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
38 addReference ();
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 }
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 LDDocumentPointer::~LDDocumentPointer()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
44 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
45 removeReference();
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 }
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 void LDDocumentPointer::addReference()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
51 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
52 if (getPointer() != null)
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 getPointer()->addReference (this);
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 }
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 void LDDocumentPointer::removeReference()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
59 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
60 if (getPointer() != null)
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 getPointer()->removeReference (this);
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 }
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 // =============================================================================
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 // -----------------------------------------------------------------------------
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 LDDocumentPointer& LDDocumentPointer::operator= (LDDocument* ptr)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
67 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
68 if (ptr != getPointer())
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
69 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
70 removeReference();
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 setPointer (ptr);
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 addReference();
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 }
590
7aec744ce97b - refactored config code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 584
diff changeset
74
7aec744ce97b - refactored config code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 584
diff changeset
75 return *this;
584
12caa4e7b874 - forgot these new files out...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 }

mercurial