Get rid of the boost::shared_ptr's in TextClass.{h,cpp}. It's not clear what these were really doing here now, and they will cause bugs now that DocumentClass objects are more dynamic.

Abdel suggested it might be worth pimpl'ing the FloatList and Counter objects, to get the header dependencies back down.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23530 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-03-07 03:41:12 +00:00
parent 2222b3f367
commit ac6e5b871c
4 changed files with 27 additions and 21 deletions

View File

@ -37,6 +37,8 @@
#include <sstream> #include <sstream>
#include "boost/assert.hpp"
using namespace std; using namespace std;
using namespace lyx::support; using namespace lyx::support;
@ -114,8 +116,6 @@ InsetLayout DocumentClass::empty_insetlayout_;
TextClass::TextClass() TextClass::TextClass()
{ {
floatlist_ = boost::shared_ptr<FloatList>(new FloatList);
counters_ = boost::shared_ptr<Counters>(new Counters);
outputType_ = LATEX; outputType_ = LATEX;
columns_ = 1; columns_ = 1;
sides_ = OneSide; sides_ = OneSide;
@ -470,7 +470,7 @@ bool TextClass::read(FileName const & filename, ReadType rt)
case TC_NOFLOAT: case TC_NOFLOAT:
if (lexrc.next()) { if (lexrc.next()) {
string const nofloat = lexrc.getString(); string const nofloat = lexrc.getString();
floatlist_->erase(nofloat); floatlist_.erase(nofloat);
} }
break; break;
} }
@ -712,8 +712,8 @@ void TextClass::readFloat(Lexer & lexrc)
case FT_TYPE: case FT_TYPE:
lexrc.next(); lexrc.next();
type = lexrc.getString(); type = lexrc.getString();
if (floatlist_->typeExist(type)) { if (floatlist_.typeExist(type)) {
Floating const & fl = floatlist_->getType(type); Floating const & fl = floatlist_.getType(type);
placement = fl.placement(); placement = fl.placement();
ext = fl.ext(); ext = fl.ext();
within = fl.within(); within = fl.within();
@ -763,13 +763,13 @@ void TextClass::readFloat(Lexer & lexrc)
if (getout) { if (getout) {
Floating fl(type, placement, ext, within, Floating fl(type, placement, ext, within,
style, name, listName, builtin); style, name, listName, builtin);
floatlist_->newFloat(fl); floatlist_.newFloat(fl);
// each float has its own counter // each float has its own counter
counters_->newCounter(from_ascii(type), from_ascii(within), counters_.newCounter(from_ascii(type), from_ascii(within),
docstring(), docstring()); docstring(), docstring());
// also define sub-float counters // also define sub-float counters
docstring const subtype = "sub-" + from_ascii(type); docstring const subtype = "sub-" + from_ascii(type);
counters_->newCounter(subtype, from_ascii(type), counters_.newCounter(subtype, from_ascii(type),
"\\alph{" + subtype + "}", docstring()); "\\alph{" + subtype + "}", docstring());
} }
@ -816,7 +816,7 @@ void TextClass::readCounter(Lexer & lexrc)
case CT_NAME: case CT_NAME:
lexrc.next(); lexrc.next();
name = lexrc.getDocString(); name = lexrc.getDocString();
if (counters_->hasCounter(name)) if (counters_.hasCounter(name))
LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name)); LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name));
else else
LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name)); LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name));
@ -844,7 +844,7 @@ void TextClass::readCounter(Lexer & lexrc)
// Here if have a full counter if getout == true // Here if have a full counter if getout == true
if (getout) if (getout)
counters_->newCounter(name, within, counters_.newCounter(name, within,
labelstring, labelstring_appendix); labelstring, labelstring_appendix);
lexrc.popTable(); lexrc.popTable();
@ -950,9 +950,11 @@ bool TextClass::load(string const & path) const
InsetLayout const & DocumentClass::insetLayout(docstring const & name) const InsetLayout const & DocumentClass::insetLayout(docstring const & name) const
{ {
docstring n = name; docstring n = name;
InsetLayouts::const_iterator cen = insetlayoutlist_.end();
while (!n.empty()) { while (!n.empty()) {
if (insetlayoutlist_.count(n) > 0) InsetLayouts::const_iterator cit = insetlayoutlist_.lower_bound(n);
return insetlayoutlist_[n]; if (cit != cen && cit->first == n)
return cit->second;
size_t i = n.find(':'); size_t i = n.find(':');
if (i == string::npos) if (i == string::npos)
break; break;

View File

@ -11,6 +11,8 @@
#define TEXTCLASS_H #define TEXTCLASS_H
#include "ColorCode.h" #include "ColorCode.h"
#include "Counters.h"
#include "FloatList.h"
#include "FontInfo.h" #include "FontInfo.h"
#include "Layout.h" #include "Layout.h"
#include "LayoutEnums.h" #include "LayoutEnums.h"
@ -21,7 +23,6 @@
#include "support/types.h" #include "support/types.h"
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <list> #include <list>
#include <map> #include <map>
@ -167,9 +168,9 @@ protected:
/// document class description /// document class description
std::string description_; std::string description_;
/// available types of float, eg. figure, algorithm. /// available types of float, eg. figure, algorithm.
boost::shared_ptr<FloatList> floatlist_; mutable FloatList floatlist_;
/// Types of counters, eg. sections, eqns, figures, avail. in document class. /// Types of counters, eg. sections, eqns, figures, avail. in document class.
boost::shared_ptr<Counters> counters_; mutable Counters counters_;
/// Has this layout file been loaded yet? /// Has this layout file been loaded yet?
mutable bool loaded_; mutable bool loaded_;
/// Is the TeX class available? /// Is the TeX class available?
@ -219,7 +220,7 @@ protected:
/// The name of the title command /// The name of the title command
std::string titlename_; std::string titlename_;
/// Input layouts available to this layout /// Input layouts available to this layout
mutable InsetLayouts insetlayoutlist_; InsetLayouts insetlayoutlist_;
/// The minimal TocLevel of sectioning layouts /// The minimal TocLevel of sectioning layouts
int min_toclevel_; int min_toclevel_;
/// The maximal TocLevel of sectioning layouts /// The maximal TocLevel of sectioning layouts
@ -269,7 +270,7 @@ public:
/// A DocumentClass nevers count as loaded, since it is dynamic /// A DocumentClass nevers count as loaded, since it is dynamic
virtual bool loaded() { return false; } virtual bool loaded() { return false; }
/// Inset layouts of this doc class /// Inset layouts of this doc class
InsetLayouts & insetLayouts() const { return insetlayoutlist_; }; InsetLayouts const & insetLayouts() const { return insetlayoutlist_; };
/// \return the layout object of an inset given by name. If the name /// \return the layout object of an inset given by name. If the name
/// is not found as such, the part after the ':' is stripped off, and /// is not found as such, the part after the ':' is stripped off, and
/// searched again. In this way, an error fallback can be provided: /// searched again. In this way, an error fallback can be provided:
@ -286,11 +287,10 @@ public:
// accessors // accessors
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
/// the list of floats defined in the document class /// the list of floats defined in the document class
FloatList & floats() { return *floatlist_.get(); }
/// the list of floats defined in the document class /// the list of floats defined in the document class
FloatList const & floats() const { return *floatlist_.get(); } FloatList const & floats() const { return floatlist_; }
/// The Counters present in this document class. ///
Counters & counters() const { return *counters_.get(); } Counters & counters() const { return counters_; }
/// ///
std::string const & opt_fontsize() const { return opt_fontsize_; } std::string const & opt_fontsize() const { return opt_fontsize_; }
/// ///

View File

@ -19,6 +19,8 @@
#include "support/convert.h" #include "support/convert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <boost/assert.hpp>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector> #include <vector>

View File

@ -26,6 +26,8 @@
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <boost/assert.hpp>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <sstream> #include <sstream>