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"
29 /// Index into LayoutFileList. Basically a 'strong typedef'.
30 class LayoutFileIndex {
33 typedef std::string base_type;
35 LayoutFileIndex(base_type const & t) : data_(t) { }
37 operator base_type() const { return data_; }
39 bool empty() const { return data_.empty(); }
44 /// This class amounts to little more than a `strong typedef'.
46 /// A LayoutFile represents the layout information that is
47 /// contained in a *.layout file.
49 /// No document- (that is, Buffer-) specific information should
50 /// be placed in these objects. They are used as the basis for
51 /// constructing DocumentClass objects, which are what represent
52 /// the layout information associated with a Buffer. (This is also
53 /// a subclass of TextClass, implemented in TextClass.{h,cpp}.)
54 /// Buffer-specific information should therefore be placed in a
55 /// DocumentClass object.
57 class LayoutFile : public TextClass {
59 /// check whether the TeX class is available
60 bool isTeXClassAvailable() const { return tex_class_avail_; }
62 LayoutModuleList const & defaultModules() const
63 { return default_modules_; }
65 LayoutModuleList const & providedModules() const
66 { return provided_modules_; }
68 LayoutModuleList const & excludedModules() const
69 { return excluded_modules_; }
72 LayoutFile(LayoutFile const &);
73 void operator=(LayoutFile const &);
74 /// Construct a layout with default values. Actual values loaded later.
75 explicit LayoutFile(std::string const & filename,
76 std::string const & className = std::string(),
77 std::string const & description = std::string(),
78 std::string const & prerequisites = std::string(),
79 std::string const & category = std::string(),
80 bool texclassavail = false);
81 /// The only class that should create a LayoutFile is
82 /// LayoutFileList, which calls the private constructor.
83 friend class LayoutFileList;
84 /// can't create empty LayoutFile
89 /// A list of base document classes (*.layout files).
90 /// This is a singleton class. The sole instance is accessed
91 /// via LayoutFileList::get()
92 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;
102 /// Note that this will assert if we don't have classname, so
103 /// check via haveClass() first.
104 LayoutFile const & operator[](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 & operator[](std::string const & classname);
108 /// Read textclass list. Returns false if this fails.
110 /// Clears the textclass so as to force it to be reloaded
111 void reset(LayoutFileIndex const & tc);
113 /// Add a default textclass with all standard layouts.
114 /// Note that this will over-write any information we may have
115 /// gotten from textclass.lst about this class.
116 LayoutFileIndex addEmptyClass(std::string const & textclass);
118 /// add a textclass from user local directory.
119 /// \return the identifier for the loaded file, or else an
120 /// empty string if no file was loaded.
121 LayoutFileIndex addLocalLayout(std::string const & textclass,
122 std::string const & path,
123 std::string const & oldpath = empty_string());
124 /// a list of the available classes
125 std::vector<LayoutFileIndex> classList() const;
128 bool load(std::string const & name, std::string const & buf_path);
134 typedef std::map<std::string, LayoutFile *> ClassMap;
136 LayoutFileList(LayoutFileList const &);
138 void operator=(LayoutFileList const &);
140 mutable ClassMap classmap_; //FIXME
144 LayoutFileIndex defaultBaseclass();