]> git.lyx.org Git - lyx.git/blob - src/BaseClassList.h
More work towards type safety regarding TextClass's. A couple bugs have been fixed...
[lyx.git] / src / BaseClassList.h
1 // -*- C++ -*-
2 /**
3  * \file BaseClassList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BASECLASSLIST_H
13 #define BASECLASSLIST_H
14
15 #include "TextClass.h"
16
17 #include "support/strfwd.h"
18
19 #include <vector>
20
21
22 namespace lyx {
23
24 class Layout;
25
26 /// Reads the style files
27 extern bool LyXSetStyle();
28
29
30 /// Index into BaseClassList. Basically a 'strong typedef'.
31 class BaseClassIndex {
32 public:
33         ///
34         typedef std::string base_type;
35         ///
36         BaseClassIndex(base_type t) { data_ = t; }
37         ///
38         operator base_type() const { return data_; }
39         ///
40 private:
41         base_type data_;
42 };
43
44
45 /// A list of base document classes (*.layout files).
46 /// This is a singleton class. The sole instance is accessed
47 /// via BaseClassList::get()
48 class BaseClassList {
49 public:
50         ///
51         BaseClassList() {}
52         /// \return The sole instance of this class.
53         static BaseClassList & get();
54         ///
55         bool empty() const { return classmap_.empty(); }
56         ///
57         bool haveClass(std::string const & classname) const;
58         ///
59         TextClass const & operator[](std::string const & classname) const;
60         /// Read textclass list.  Returns false if this fails.
61         bool read();
62         /// Clears the textclass so as to force it to be reloaded
63         void reset(BaseClassIndex const & tc);
64         /// add a textclass from user local directory.
65         /// \return the identifier for the loaded file, or else an
66         /// empty string if no file was loaded.
67         BaseClassIndex
68                 addTextClass(std::string const & textclass, std::string const & path);
69         /// a list of the available classes
70         std::vector<BaseClassIndex> classList() const;
71         /// 
72         static std::string const localPrefix;
73 private:
74         ///
75         typedef std::map<std::string, TextClass> ClassMap;
76         /// noncopyable
77         BaseClassList(BaseClassList const &);
78         /// nonassignable
79         void operator=(BaseClassList const &);
80         ///
81         mutable ClassMap classmap_; //FIXME
82 };
83
84 ///
85 BaseClassIndex defaultBaseclass();
86
87
88 } // namespace lyx
89
90 #endif