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_; }
71 std::list<std::string> const & providedModules() const
72 { return provided_modules_; }
74 std::list<std::string> const & excludedModules() const
75 { return excluded_modules_; }
77 /// Construct a layout with default values. Actual values loaded later.
78 explicit LayoutFile(std::string const & filename,
79 std::string const & className = std::string(),
80 std::string const & description = std::string(),
81 bool texClassAvail = false);
82 /// The only class that should create a LayoutFile is
83 /// LayoutFileList, which calls the private constructor.
84 friend class LayoutFileList;
85 /// can't create empty LayoutFile
90 /// A list of base document classes (*.layout files).
91 /// This is a singleton class. The sole instance is accessed
92 /// via LayoutFileList::get()
93 class LayoutFileList {
99 /// \return The sole instance of this class.
100 static LayoutFileList & get();
102 bool empty() const { return classmap_.empty(); }
104 bool haveClass(std::string const & classname) const;
105 /// Note that this will assert if we don't have classname, so
106 /// check via haveClass() first.
107 LayoutFile const & operator[](std::string const & classname) const;
108 /// Note that this will assert if we don't have classname, so
109 /// check via haveClass() first.
110 LayoutFile & operator[](std::string const & classname);
111 /// Read textclass list. Returns false if this fails.
113 /// Clears the textclass so as to force it to be reloaded
114 void reset(LayoutFileIndex const & tc);
116 /// add a default textclass with all standard layouts.
117 LayoutFileIndex addEmptyClass(std::string const & textclass);
119 /// add a textclass from user local directory.
120 /// \return the identifier for the loaded file, or else an
121 /// empty string if no file was loaded.
123 addLocalLayout(std::string const & textclass, std::string const & path);
124 /// a list of the available classes
125 std::vector<LayoutFileIndex> classList() const;
128 typedef std::map<std::string, LayoutFile *> ClassMap;
130 LayoutFileList(LayoutFileList const &);
132 void operator=(LayoutFileList const &);
134 mutable ClassMap classmap_; //FIXME
138 LayoutFileIndex defaultBaseclass();