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_; }
44 /// This class amounts to little more than a `strong typedef'.
45 /// A LayoutFile represents the layout information that is
46 /// contained in a *.layout file.
47 class LayoutFile : public TextClass {
49 /// This should never be used, but it has to be provided for
50 /// std::map operator[] to work. Something like:
51 /// mapthingy[stuff] = otherthing
52 /// creates an empty object before doing the assignment.
54 /// check whether the TeX class is available
55 bool isTeXClassAvailable() const { return texClassAvail_; }
57 /// Construct a layout with default values. Actual values loaded later.
58 explicit LayoutFile(std::string const &,
59 std::string const & = std::string(),
60 std::string const & = std::string(),
61 bool texClassAvail = false);
62 /// The only class that should create a LayoutFile is
63 /// BaseClassList, which calls the private constructor.
64 friend class BaseClassList;
68 /// A list of base document classes (*.layout files).
69 /// This is a singleton class. The sole instance is accessed
70 /// via BaseClassList::get()
75 /// \return The sole instance of this class.
76 static BaseClassList & get();
78 bool empty() const { return classmap_.empty(); }
80 bool haveClass(std::string const & classname) const;
82 LayoutFile const & operator[](std::string const & classname) const;
84 LayoutFile & operator[](std::string const & classname);
85 /// Read textclass list. Returns false if this fails.
87 /// Clears the textclass so as to force it to be reloaded
88 void reset(LayoutFileIndex const & tc);
89 /// add a textclass from user local directory.
90 /// \return the identifier for the loaded file, or else an
91 /// empty string if no file was loaded.
93 addLayoutFile(std::string const & textclass, std::string const & path);
94 /// a list of the available classes
95 std::vector<LayoutFileIndex> classList() const;
97 static std::string const localPrefix;
100 typedef std::map<std::string, LayoutFile> ClassMap;
102 BaseClassList(BaseClassList const &);
104 void operator=(BaseClassList const &);
106 mutable ClassMap classmap_; //FIXME
110 LayoutFileIndex defaultBaseclass();