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
9 * Full author contact details are available in file CREDITS.
12 #ifndef BASECLASSLIST_H
13 #define BASECLASSLIST_H
15 #include "TextClass.h"
17 #include "support/strfwd.h"
19 #include <boost/noncopyable.hpp>
30 /// Reads the style files
31 extern bool LyXSetStyle();
34 /// Index into LayoutFileList. Basically a 'strong typedef'.
35 class LayoutFileIndex {
38 typedef std::string base_type;
40 LayoutFileIndex(base_type t) { data_ = t; }
42 operator base_type() const { return data_; }
44 bool empty() const { return data_.empty(); }
49 /// This class amounts to little more than a `strong typedef'.
51 /// A LayoutFile represents the layout information that is
52 /// contained in a *.layout file.
54 /// No document- (that is, Buffer-) specific information should
55 /// be placed in these objects. They are used as the basis for
56 /// constructing DocumentClass objects, which are what represent
57 /// the layout information associated with a Buffer. (This is also
58 /// a subclass of TextClass, implemented in TextClass.{h,cpp}.)
59 /// Buffer-specific information should therefore be placed in a
60 /// DocumentClass object.
62 class LayoutFile : public TextClass, boost::noncopyable {
64 /// check whether the TeX class is available
65 bool isTeXClassAvailable() const { return texClassAvail_; }
67 std::list<std::string> const & defaultModules() const
68 { return default_modules_; }
69 std::list<std::string> const & providedModules() const
70 { return provided_modules_; }
71 std::list<std::string> const & excludedModules() const
72 { return excluded_modules_; }
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 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 {
95 /// \return The sole instance of this class.
96 static LayoutFileList & get();
98 bool empty() const { return classmap_.empty(); }
100 bool haveClass(std::string const & classname) const;
102 LayoutFile const & operator[](std::string const & classname) const;
104 LayoutFile & operator[](std::string const & classname);
105 /// Read textclass list. Returns false if this fails.
107 /// Clears the textclass so as to force it to be reloaded
108 void reset(LayoutFileIndex const & tc);
110 /// add a default textclass with all standard layouts.
111 LayoutFileIndex addEmptyClass(std::string const & textclass);
113 /// add a textclass from user local directory.
114 /// \return the identifier for the loaded file, or else an
115 /// empty string if no file was loaded.
117 addLocalLayout(std::string const & textclass, std::string const & path);
118 /// a list of the available classes
119 std::vector<LayoutFileIndex> classList() const;
122 typedef std::map<std::string, LayoutFile *> ClassMap;
124 LayoutFileList(LayoutFileList const &);
126 void operator=(LayoutFileList const &);
128 mutable ClassMap classmap_; //FIXME
132 LayoutFileIndex defaultBaseclass();