]> git.lyx.org Git - lyx.git/blob - src/BaseClassList.h
Try to make the distinction between base classes and text classes clearer in the...
[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 /// Index into BaseClassList. Basically a 'strong typedef'.
30 class BaseClassIndex {
31 public:
32         ///
33         typedef size_t   base_type;
34         ///
35         BaseClassIndex(base_type t) { data_ = t; }
36         ///
37         operator base_type() const { return data_; }
38         ///
39 private:
40         base_type data_;
41 };
42
43 /// A list of base document classes (*.layout files).
44 class BaseClassList {
45 public:
46         ///
47         BaseClassList() {}
48         ///
49         typedef std::vector<TextClass> ClassList;
50         ///
51         typedef ClassList::const_iterator const_iterator;
52         ///
53         const_iterator begin() const { return classlist_.begin(); }
54         ///
55         const_iterator end() const { return classlist_.end(); }
56         ///
57         bool empty() const { return classlist_.empty(); }
58
59         /// Gets textclass number from name, -1 if textclass name does not exist
60         std::pair<bool, BaseClassIndex> const
61                 numberOfClass(std::string const & textclass) const;
62
63         ///
64         TextClass const & operator[](BaseClassIndex textclass) const;
65
66         /// Read textclass list.  Returns false if this fails.
67         bool read();
68         
69         /// Clears the textclass so as to force it to be reloaded
70         void reset(BaseClassIndex const textclass);
71
72         /// add a textclass from user local directory.
73         /// Return ture/false, and textclass number
74         std::pair<bool, BaseClassIndex> const
75                 addTextClass(std::string const & textclass, std::string const & path);
76
77 private:
78         /// noncopyable
79         BaseClassList(BaseClassList const &);
80         /// nonassignable
81         void operator=(BaseClassList const &);
82
83         ///
84         mutable ClassList classlist_;
85 };
86
87 ///
88 extern BaseClassList baseclasslist;
89 ///
90 BaseClassIndex defaultBaseclass();
91
92
93 } // namespace lyx
94
95 #endif