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::set<std::string> const & defaultModules() const { return usemod_; }
69 /// Construct a layout with default values. Actual values loaded later.
70 explicit LayoutFile(std::string const & filename,
71 std::string const & className = std::string(),
72 std::string const & description = std::string(),
73 bool texClassAvail = false);
74 /// The only class that should create a LayoutFile is
75 /// LayoutFileList, which calls the private constructor.
76 friend class LayoutFileList;
77 /// can't create empty LayoutFile
82 /// A list of base document classes (*.layout files).
83 /// This is a singleton class. The sole instance is accessed
84 /// via LayoutFileList::get()
85 class LayoutFileList {
90 /// \return The sole instance of this class.
91 static LayoutFileList & get();
93 bool empty() const { return classmap_.empty(); }
95 bool haveClass(std::string const & classname) const;
97 LayoutFile const & operator[](std::string const & classname) const;
99 LayoutFile & operator[](std::string const & classname);
100 /// Read textclass list. Returns false if this fails.
102 /// Clears the textclass so as to force it to be reloaded
103 void reset(LayoutFileIndex const & tc);
105 /// add a default textclass with all standard layouts.
106 LayoutFileIndex addEmptyClass(std::string const & textclass);
108 /// add a textclass from user local directory.
109 /// \return the identifier for the loaded file, or else an
110 /// empty string if no file was loaded.
112 addLocalLayout(std::string const & textclass, std::string const & path);
113 /// a list of the available classes
114 std::vector<LayoutFileIndex> classList() const;
117 typedef std::map<std::string, LayoutFile *> ClassMap;
119 LayoutFileList(LayoutFileList const &);
121 void operator=(LayoutFileList const &);
123 mutable ClassMap classmap_; //FIXME
127 LayoutFileIndex defaultBaseclass();