]> git.lyx.org Git - lyx.git/blob - src/mathed/math_atom.C
make \newcommand{\bb}[1]{\mathbf{#1}} work for read/write/display.
[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 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "math_atom.h"
22 #include "math_inset.h"
23 #include "support/LAssert.h"
24
25 #include <utility>
26
27 MathAtom::MathAtom()
28         : nucleus_(0)
29 {}
30
31
32 MathAtom::MathAtom(MathInset * p)
33         : nucleus_(p)
34 {}
35
36
37 MathAtom::MathAtom(MathAtom const & p)
38         : nucleus_(p.nucleus_ ? p.nucleus_->clone() : 0)
39 {}
40
41
42 void MathAtom::operator=(MathAtom const & p)
43 {
44         if (&p == this)
45                 return;
46         MathAtom tmp(p);
47         std::swap(tmp.nucleus_, nucleus_);
48 }
49
50
51 MathAtom::~MathAtom()
52 {
53         delete nucleus_;
54 }
55
56
57 void MathAtom::reset(MathInset * p)
58 {
59         if (p == nucleus_)
60                 return;
61         delete nucleus_;
62         nucleus_ = p;
63 }
64
65
66 MathInset * MathAtom::nucleus() const
67 {
68         lyx::Assert(nucleus_);
69         return nucleus_;
70 }
71
72
73 MathInset * MathAtom::operator->() const
74 {
75         return nucleus();
76 }