1 // -*- C++ -*-
2 /**
3  * \file MathAtom.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 
12 #ifndef MATH_ATOM_H
13 #define MATH_ATOM_H
14 
15 
16 /**
17 Wrapper for InsetMath * with copy-semantics
18 
19 --
20 
21 The 'atom' is the major blob in math typesetting.  And 'atom' consists
22 of a nucleus, an optional superscript, and an optional subscript.
23 
24 Exactly where the subscript and superscript are drawn depends on the
25 size, and type, of the nucleus they are attached to.
26 
27 Jules
28 
29 --
30 
31 Ok: Implementing it thusly is not feasible since cursor movement gets
32 hackish. We use MathAtom only as a wrapper around InsetMath * with value
33 semantics.
34 
35 The MathAtom owns the InsetMath * and is responsible for proper cloning and
36 destruction. Every InsetMath * should be put into a MathAtom after its
37 creation as soon as possible.
38 
39 Andre'
40 
41 */
42 
43 #include "support/unique_ptr.h"
44 
45 namespace lyx {
46 
47 class Inset;
48 class InsetMath;
49 
50 class MathAtom {
51 public:
52 	MathAtom() = default;
53 	MathAtom(MathAtom &&) = default;
54 	MathAtom & operator=(MathAtom &&) = default;
55 	/// the "real constructor"
56 	explicit MathAtom(InsetMath * p);
57 	/// copy constructor, invokes clone()
58 	MathAtom(MathAtom const &);
59 	MathAtom & operator=(MathAtom const &);
60 	/// access to the inset
nucleus()61 	InsetMath * nucleus() { return nucleus_.get(); }
nucleus()62 	InsetMath const * nucleus() const { return nucleus_.get(); }
63 	InsetMath * operator->() { return nucleus_.get(); }
64 	InsetMath const * operator->() const { return nucleus_.get(); }
65 private:
66 	std::unique_ptr<InsetMath> nucleus_;
67 };
68 
69 
70 } // namespace lyx
71 
72 #endif
73