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 "LayoutModuleList.h"
17 #include "TextClass.h"
19 #include "support/strfwd.h"
21 #include <boost/noncopyable.hpp>
32 /// Reads the style files
33 extern bool LyXSetStyle();
36 /// Index into LayoutFileList. Basically a 'strong typedef'.
37 class LayoutFileIndex {
40 typedef std::string base_type;
42 LayoutFileIndex(base_type t) { data_ = t; }
44 operator base_type() const { return data_; }
46 bool empty() const { return data_.empty(); }
51 /// This class amounts to little more than a `strong typedef'.
53 /// A LayoutFile represents the layout information that is
54 /// contained in a *.layout file.
56 /// No document- (that is, Buffer-) specific information should
57 /// be placed in these objects. They are used as the basis for
58 /// constructing DocumentClass objects, which are what represent
59 /// the layout information associated with a Buffer. (This is also
60 /// a subclass of TextClass, implemented in TextClass.{h,cpp}.)
61 /// Buffer-specific information should therefore be placed in a
62 /// DocumentClass object.
64 class LayoutFile : public TextClass, boost::noncopyable {
66 /// check whether the TeX class is available
67 bool isTeXClassAvailable() const { return texClassAvail_; }
69 LayoutModuleList const & defaultModules() const
70 { return default_modules_; }
72 LayoutModuleList const & providedModules() const
73 { return provided_modules_; }
75 LayoutModuleList const & excludedModules() const
76 { return excluded_modules_; }
78 /// Construct a layout with default values. Actual values loaded later.
79 explicit LayoutFile(std::string const & filename,
80 std::string const & className = std::string(),
81 std::string const & description = std::string(),
82 bool texClassAvail = false);
83 /// The only class that should create a LayoutFile is
84 /// LayoutFileList, which calls the private constructor.
85 friend class LayoutFileList;
86 /// can't create empty LayoutFile
91 /// A list of base document classes (*.layout files).
92 /// This is a singleton class. The sole instance is accessed
93 /// via LayoutFileList::get()
94 class LayoutFileList {
100 /// \return The sole instance of this class.
101 static LayoutFileList & get();
103 bool empty() const { return classmap_.empty(); }
105 bool haveClass(std::string const & classname) const;
106 /// Note that this will assert if we don't have classname, so
107 /// check via haveClass() first.
108 LayoutFile const & operator[](std::string const & classname) const;
109 /// Note that this will assert if we don't have classname, so
110 /// check via haveClass() first.
111 LayoutFile & operator[](std::string const & classname);
112 /// Read textclass list. Returns false if this fails.
114 /// Clears the textclass so as to force it to be reloaded
115 void reset(LayoutFileIndex const & tc);
117 /// add a default textclass with all standard layouts.
118 LayoutFileIndex addEmptyClass(std::string const & textclass);
120 /// add a textclass from user local directory.
121 /// \return the identifier for the loaded file, or else an
122 /// empty string if no file was loaded.
124 addLocalLayout(std::string const & textclass, std::string const & path);
125 /// a list of the available classes
126 std::vector<LayoutFileIndex> classList() const;
129 bool load(std::string const & name, std::string const & buf_path);
133 typedef std::map<std::string, LayoutFile *> ClassMap;
135 LayoutFileList(LayoutFileList const &);
137 void operator=(LayoutFileList const &);
139 mutable ClassMap classmap_; //FIXME
143 LayoutFileIndex defaultBaseclass();