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 tex_class_avail_; }
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 std::string const & prerequisites = std::string(),
83 bool texclassavail = false);
84 /// The only class that should create a LayoutFile is
85 /// LayoutFileList, which calls the private constructor.
86 friend class LayoutFileList;
87 /// can't create empty LayoutFile
92 /// A list of base document classes (*.layout files).
93 /// This is a singleton class. The sole instance is accessed
94 /// via LayoutFileList::get()
95 class LayoutFileList {
101 /// \return The sole instance of this class.
102 static LayoutFileList & get();
104 bool empty() const { return classmap_.empty(); }
106 bool haveClass(std::string const & classname) const;
107 /// Note that this will assert if we don't have classname, so
108 /// check via haveClass() first.
109 LayoutFile const & operator[](std::string const & classname) const;
110 /// Note that this will assert if we don't have classname, so
111 /// check via haveClass() first.
112 LayoutFile & operator[](std::string const & classname);
113 /// Read textclass list. Returns false if this fails.
115 /// Clears the textclass so as to force it to be reloaded
116 void reset(LayoutFileIndex const & tc);
118 /// add a default textclass with all standard layouts.
119 LayoutFileIndex addEmptyClass(std::string const & textclass);
121 /// add a textclass from user local directory.
122 /// \return the identifier for the loaded file, or else an
123 /// empty string if no file was loaded.
125 addLocalLayout(std::string const & textclass, std::string const & path);
126 /// a list of the available classes
127 std::vector<LayoutFileIndex> classList() const;
130 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();