X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_atom.h;h=9e02b7a8d30883d17d865cb1a9154433a66681a6;hb=cd03e2b7db8379a91f3d31eac2c5bc25b159c541;hp=8713c4113b17823d2acd64df1338df8af3a98d44;hpb=c93e9dcbc59d0b404561dbc7c373716f11fc13f1;p=lyx.git diff --git a/src/mathed/math_atom.h b/src/mathed/math_atom.h index 8713c4113b..9e02b7a8d3 100644 --- a/src/mathed/math_atom.h +++ b/src/mathed/math_atom.h @@ -1,18 +1,28 @@ // -*- C++ -*- +/** + * \file math_atom.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ #ifndef MATH_ATOM_H #define MATH_ATOM_H -#ifdef __GNUG__ -#pragma interface -#endif -/** +/** +Wrapper for MathInset * with copy-semantics + +-- + The 'atom' is the major blob in math typesetting. And 'atom' consists of a nucleus, an optional superscript, and an optional subscript. Exactly where the subscript and superscript are drawn depends on the -size, and type, of the nucleus they are attached to. +size, and type, of the nucleus they are attached to. Jules @@ -22,39 +32,41 @@ Ok: Implementing it thusly is not feasible since cursor movement gets hackish. We use MathAtom only as a wrapper around MathInset * with value semantics. +The MathAtom owns the MathInset * and is responsible for proper cloning and +destruction. Every MathInset * should be put into a MathAtom after its +creation as soon as possible. + Andre' */ +class InsetBase; class MathInset; class MathAtom { -public: - /// +public: + /// default constructor, object is useless, but we need it to put it into + // std::containers MathAtom(); - /// + /// the "real constructor" + explicit MathAtom(InsetBase * p); + /// copy constructor, invokes nucleus_->clone() MathAtom(MathAtom const &); - /// - explicit MathAtom(MathInset * p); - /// - virtual ~MathAtom(); - /// + /// we really need to clean up + ~MathAtom(); + /// assignment invokes nucleus_->clone() void operator=(MathAtom const &); - /// - void reset(MathInset * p); - /// - MathInset * nucleus() const; - /// - MathInset * operator->() const; + /// access to the inset (checked with gprof) + MathInset * nucleus() { return nucleus_; } + /// access to the inset + MathInset const * operator->() const { return nucleus_; } + + /// width cache. Not nice... + mutable int width_; private: /// MathInset * nucleus_; - - /// raw copy - void copy(MathAtom const & p); - /// raw destruction - void done(); }; #endif