]> git.lyx.org Git - lyx.git/blob - src/mathed/math_atom.C
Essentially Lars' "thread safe" patch
[lyx.git] / src / mathed / math_atom.C
1 /*
2  *  File:        math_atom.C
3  *  Purpose:     Wrapper for MathInset * 
4  *  Author:      André Pönitz
5  *  Created:     July 2001
6  *
7  *  Copyright: 2001 The LyX team
8  *
9  *   Version: 1.2.0
10  *
11  *   You are free to use and modify this code under the terms of
12  *   the GNU General Public Licence version 2 or later.
13  */
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "math_atom.h"
20 #include "math_inset.h"
21 #include "support/LAssert.h"
22
23 #include <utility>
24
25 MathAtom::MathAtom()
26         : nucleus_(0)
27 {}
28
29
30 MathAtom::MathAtom(MathInset * p)
31         : nucleus_(p)
32 {}
33
34
35 MathAtom::MathAtom(MathAtom const & p)
36         : nucleus_(p.nucleus_ ? p.nucleus_->clone() : 0)
37 {}
38
39
40 void MathAtom::operator=(MathAtom const & p)
41 {
42         if (&p == this)
43                 return;
44         MathAtom tmp(p);
45         std::swap(tmp.nucleus_, nucleus_);
46 }
47
48
49 MathAtom::~MathAtom()
50 {
51         delete nucleus_;
52 }
53
54
55 void MathAtom::reset(MathInset * p)
56 {
57         if (p == nucleus_)
58                 return;
59         delete nucleus_;
60         nucleus_ = p;
61 }
62
63
64 MathInset * MathAtom::nucleus() const
65 {
66         lyx::Assert(nucleus_);
67         return nucleus_;
68 }
69
70
71 MathInset * MathAtom::operator->() const
72 {
73         return nucleus();
74 }