Not so soon, I guess, since that FIXME was from r6305.
[lyx.git] / src / LayoutFile.h
blobb56da88319d122b4dfe2174195a29dbd120c68fc
1 // -*- C++ -*-
2 /**
3 * \file LayoutFile.h
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>
23 #include <set>
24 #include <string>
25 #include <vector>
28 namespace lyx {
30 class Layout;
32 /// Reads the style files
33 extern bool LyXSetStyle();
36 /// Index into LayoutFileList. Basically a 'strong typedef'.
37 class LayoutFileIndex {
38 public:
39 ///
40 typedef std::string base_type;
41 ///
42 LayoutFileIndex(base_type t) { data_ = t; }
43 ///
44 operator base_type() const { return data_; }
45 ///
46 bool empty() const { return data_.empty(); }
47 private:
48 base_type data_;
51 /// This class amounts to little more than a `strong typedef'.
52 ///
53 /// A LayoutFile represents the layout information that is
54 /// contained in a *.layout file.
55 ///
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.
63 ///
64 class LayoutFile : public TextClass, boost::noncopyable {
65 public:
66 /// check whether the TeX class is available
67 bool isTeXClassAvailable() const { return texClassAvail_; }
68 ///
69 LayoutModuleList const & defaultModules() const
70 { return default_modules_; }
71 ///
72 LayoutModuleList const & providedModules() const
73 { return provided_modules_; }
74 ///
75 LayoutModuleList const & excludedModules() const
76 { return excluded_modules_; }
77 private:
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 bool texClassAvail = false);
83 /// The only class that should create a LayoutFile is
84 /// LayoutFileList, which calls the private constructor.
85 friend class LayoutFileList;
86 /// can't create empty LayoutFile
87 LayoutFile() {};
91 /// A list of base document classes (*.layout files).
92 /// This is a singleton class. The sole instance is accessed
93 /// via LayoutFileList::get()
94 class LayoutFileList {
95 public:
96 ///
97 LayoutFileList() {}
98 ///
99 ~LayoutFileList();
100 /// \return The sole instance of this class.
101 static LayoutFileList & get();
103 bool empty() const { return classmap_.empty(); }
105 bool haveClass(std::string const & classname) const;
106 /// Note that this will assert if we don't have classname, so
107 /// check via haveClass() first.
108 LayoutFile const & operator[](std::string const & classname) const;
109 /// Note that this will assert if we don't have classname, so
110 /// check via haveClass() first.
111 LayoutFile & operator[](std::string const & classname);
112 /// Read textclass list. Returns false if this fails.
113 bool read();
114 /// Clears the textclass so as to force it to be reloaded
115 void reset(LayoutFileIndex const & tc);
117 /// add a default textclass with all standard layouts.
118 LayoutFileIndex addEmptyClass(std::string const & textclass);
120 /// add a textclass from user local directory.
121 /// \return the identifier for the loaded file, or else an
122 /// empty string if no file was loaded.
123 LayoutFileIndex
124 addLocalLayout(std::string const & textclass, std::string const & path);
125 /// a list of the available classes
126 std::vector<LayoutFileIndex> classList() const;
129 bool load(std::string const & name, std::string const & buf_path);
131 private:
133 typedef std::map<std::string, LayoutFile *> ClassMap;
134 /// noncopyable
135 LayoutFileList(LayoutFileList const &);
136 /// nonassignable
137 void operator=(LayoutFileList const &);
139 mutable ClassMap classmap_; //FIXME
143 LayoutFileIndex defaultBaseclass();
146 } // namespace lyx
148 #endif