4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Richard Heck (typedefs and such)
10 * Full author contact details are available in file CREDITS.
13 #ifndef BASECLASSLIST_H
14 #define BASECLASSLIST_H
16 #include "TextClass.h"
18 #include "support/strfwd.h"
20 #include <boost/noncopyable.hpp>
31 /// Reads the style files
32 extern bool LyXSetStyle();
35 /// Index into LayoutFileList. Basically a 'strong typedef'.
36 class LayoutFileIndex {
39 typedef std::string base_type;
41 LayoutFileIndex(base_type t) { data_ = t; }
43 operator base_type() const { return data_; }
45 bool empty() const { return data_.empty(); }
50 /// This class amounts to little more than a `strong typedef'.
52 /// A LayoutFile represents the layout information that is
53 /// contained in a *.layout file.
55 /// No document- (that is, Buffer-) specific information should
56 /// be placed in these objects. They are used as the basis for
57 /// constructing DocumentClass objects, which are what represent
58 /// the layout information associated with a Buffer. (This is also
59 /// a subclass of TextClass, implemented in TextClass.{h,cpp}.)
60 /// Buffer-specific information should therefore be placed in a
61 /// DocumentClass object.
63 class LayoutFile : public TextClass, boost::noncopyable {
65 /// check whether the TeX class is available
66 bool isTeXClassAvailable() const { return texClassAvail_; }
68 std::list<std::string> const & defaultModules() const
69 { return default_modules_; }
70 std::list<std::string> const & providedModules() const
71 { return provided_modules_; }
72 std::list<std::string> const & excludedModules() const
73 { return excluded_modules_; }
75 /// Construct a layout with default values. Actual values loaded later.
76 explicit LayoutFile(std::string const & filename,
77 std::string const & className = std::string(),
78 std::string const & description = std::string(),
79 bool texClassAvail = false);
80 /// The only class that should create a LayoutFile is
81 /// LayoutFileList, which calls the private constructor.
82 friend class LayoutFileList;
83 /// can't create empty LayoutFile
88 /// A list of base document classes (*.layout files).
89 /// This is a singleton class. The sole instance is accessed
90 /// via LayoutFileList::get()
91 class LayoutFileList {
96 /// \return The sole instance of this class.
97 static LayoutFileList & get();
99 bool empty() const { return classmap_.empty(); }
101 bool haveClass(std::string const & classname) const;
103 LayoutFile const & operator[](std::string const & classname) const;
105 LayoutFile & operator[](std::string const & classname);
106 /// Read textclass list. Returns false if this fails.
108 /// Clears the textclass so as to force it to be reloaded
109 void reset(LayoutFileIndex const & tc);
111 /// add a default textclass with all standard layouts.
112 LayoutFileIndex addEmptyClass(std::string const & textclass);
114 /// add a textclass from user local directory.
115 /// \return the identifier for the loaded file, or else an
116 /// empty string if no file was loaded.
118 addLocalLayout(std::string const & textclass, std::string const & path);
119 /// a list of the available classes
120 std::vector<LayoutFileIndex> classList() const;
123 typedef std::map<std::string, LayoutFile *> ClassMap;
125 LayoutFileList(LayoutFileList const &);
127 void operator=(LayoutFileList const &);
129 mutable ClassMap classmap_; //FIXME
133 LayoutFileIndex defaultBaseclass();