3 * \file BaseClassList.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
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"
26 /// Reads the style files
27 extern bool LyXSetStyle();
30 /// Index into BaseClassList. Basically a 'strong typedef'.
31 class LayoutFileIndex {
34 typedef std::string base_type;
36 LayoutFileIndex(base_type t) { data_ = t; }
38 operator base_type() const { return data_; }
40 bool empty() const { return data_.empty(); }
45 /// 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.
48 class LayoutFile : public TextClass {
50 /// This should never be used, but it has to be provided for
51 /// std::map operator[] to work. Something like:
52 /// mapthingy[stuff] = otherthing
53 /// creates an empty object before doing the assignment.
55 /// check whether the TeX class is available
56 bool isTeXClassAvailable() const { return texClassAvail_; }
58 /// Construct a layout with default values. Actual values loaded later.
59 explicit LayoutFile(std::string const &,
60 std::string const & = std::string(),
61 std::string const & = std::string(),
62 bool texClassAvail = false);
63 /// The only class that should create a LayoutFile is
64 /// BaseClassList, which calls the private constructor.
65 friend class BaseClassList;
69 /// A list of base document classes (*.layout files).
70 /// This is a singleton class. The sole instance is accessed
71 /// via BaseClassList::get()
76 /// \return The sole instance of this class.
77 static BaseClassList & get();
79 bool empty() const { return classmap_.empty(); }
81 bool haveClass(std::string const & classname) const;
83 LayoutFile const & operator[](std::string const & classname) const;
85 LayoutFile & operator[](std::string const & classname);
86 /// Read textclass list. Returns false if this fails.
88 /// Clears the textclass so as to force it to be reloaded
89 void reset(LayoutFileIndex const & tc);
90 /// add a textclass from user local directory.
91 /// \return the identifier for the loaded file, or else an
92 /// empty string if no file was loaded.
94 addLayoutFile(std::string const & textclass, std::string const & path);
95 /// a list of the available classes
96 std::vector<LayoutFileIndex> classList() const;
98 static std::string const localPrefix;
101 typedef std::map<std::string, LayoutFile> ClassMap;
103 BaseClassList(BaseClassList const &);
105 void operator=(BaseClassList const &);
107 mutable ClassMap classmap_; //FIXME
111 LayoutFileIndex defaultBaseclass();