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"
27 /// Index into LayoutFileList. Basically a 'strong typedef'.
28 class LayoutFileIndex {
31 typedef std::string base_type;
33 LayoutFileIndex(base_type const & t) : data_(t) { }
35 operator base_type() const { return data_; }
37 bool empty() const { return data_.empty(); }
42 /// This class amounts to little more than a `strong typedef'.
44 /// A LayoutFile represents the layout information that is
45 /// contained in a *.layout file.
47 /// No document- (that is, Buffer-) specific information should
48 /// be placed in these objects. They are used as the basis for
49 /// constructing DocumentClass objects, which are what represent
50 /// the layout information associated with a Buffer. (This is also
51 /// a subclass of TextClass, implemented in TextClass.{h,cpp}.)
52 /// Buffer-specific information should therefore be placed in a
53 /// DocumentClass object.
55 class LayoutFile : public TextClass {
57 /// check whether the TeX class is available
58 bool isTeXClassAvailable() const { return tex_class_avail_; }
60 LayoutModuleList const & defaultModules() const
61 { return default_modules_; }
63 LayoutModuleList const & providedModules() const
64 { return provided_modules_; }
66 LayoutModuleList const & excludedModules() const
67 { return excluded_modules_; }
70 LayoutFile(LayoutFile const &);
71 void operator=(LayoutFile const &);
72 /// Construct a layout with default values. Actual values loaded later.
73 explicit LayoutFile(std::string const & filename,
74 std::string const & className = std::string(),
75 std::string const & description = std::string(),
76 std::string const & prerequisites = std::string(),
77 std::string const & category = std::string(),
78 bool texclassavail = false);
79 /// The only class that should create a LayoutFile is
80 /// LayoutFileList, which calls the private constructor.
81 friend class LayoutFileList;
82 /// can't create empty LayoutFile
87 /// A list of base document classes (*.layout files).
88 /// This is a singleton class. The sole instance is accessed
89 /// via LayoutFileList::get()
90 class LayoutFileList {
94 /// \return The sole instance of this class.
95 static LayoutFileList & get();
97 bool empty() const { return classmap_.empty(); }
99 bool haveClass(std::string const & classname) const;
100 /// Note that this will assert if we don't have classname, so
101 /// check via haveClass() first.
102 LayoutFile const & operator[](std::string const & classname) const;
103 /// Note that this will assert if we don't have classname, so
104 /// check via haveClass() first.
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 /// Note that this will over-write any information we may have
113 /// gotten from textclass.lst about this class.
114 LayoutFileIndex addEmptyClass(std::string const & textclass);
116 /// add a textclass from user local directory.
117 /// \return the identifier for the loaded file, or else an
118 /// empty string if no file was loaded.
119 LayoutFileIndex addLocalLayout(std::string const & textclass,
120 std::string const & path,
121 std::string const & oldpath = empty_string());
122 /// a list of the available classes
123 std::vector<LayoutFileIndex> classList() const;
126 bool load(std::string const & name, std::string const & buf_path);
132 typedef std::map<std::string, LayoutFile *> ClassMap;
134 LayoutFileList(LayoutFileList const &);
136 void operator=(LayoutFileList const &);
138 mutable ClassMap classmap_; //FIXME
142 LayoutFileIndex defaultBaseclass();