]> git.lyx.org Git - lyx.git/blob - src/ModuleList.h
* Call metrics of the parameters with the correct font in MathMacros, for example
[lyx.git] / src / ModuleList.h
1 // -*- C++ -*-
2 /**
3  * \file ModuleList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Richard Heck
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MODULELIST_H
13 #define MODULELIST_H
14
15 #include <map>
16 #include <string>
17 #include <vector>
18
19 namespace lyx {
20         
21 /**
22  *  This struct represents a particular LyX "module", which is a like a layout
23  *  file, except that it does not stand alone. In that sense, it is more like 
24  *  a LaTeX package, where a layout file corresponds to a LaTeX class.
25  */
26
27 class LyXModule {
28 public:
29         ///
30         LyXModule(std::string const & n, std::string const & i, 
31                   std::string const & d, std::vector<std::string> const & p,
32                   std::vector<std::string> const & r, 
33                   std::vector<std::string> const & e);
34         /// whether the required packages are available
35         bool isAvailable();
36         ///
37         std::string const & getName() const { return name; }
38         ///
39         std::string const & getID() const { return id; }
40         ///
41         std::string const & getFilename() const { return filename; }
42         ///
43         std::string const & getDescription() const { return description; }
44         ///
45         std::vector<std::string> const & getPackageList() const
46                 { return packageList; }
47         ///
48         std::vector<std::string> const & getRequiredModules() const 
49                 { return requiredModules; }
50         /// Modules this one excludes: the list should be treated disjunctively
51         std::vector<std::string> const & getExcludedModules() const 
52                 { return excludedModules; }
53         /// \return true if the module is compatible with this one, i.e.,
54         /// it does not exclude us and we do not exclude it.
55         /// this will also return true if modName is unknown and we do not
56         /// exclude it, since in that case we cannot check its exclusions.
57         bool isCompatible(std::string const & modName) const;
58         ///
59         static bool areCompatible(std::string const & mod1, std::string const & mod2);
60 private:
61         /// what appears in the ui
62         std::string name;
63         /// the module's unique identifier
64         /// at present, this is the filename, without the extension
65         std::string id;
66         /// the filename
67         std::string filename;
68         /// a short description for use in the ui
69         std::string description;
70         /// the LaTeX packages on which this depends, if any
71         std::vector<std::string> packageList;
72         /// Modules this one requires: at least one
73         std::vector<std::string> requiredModules;
74         /// Modules this one excludes: none of these
75         std::vector<std::string> excludedModules;
76         ///
77         bool checked;
78         ///
79         bool available;
80 };
81
82 typedef std::vector<LyXModule> LyXModuleList;
83
84 /**
85  *  The ModuleList represents the various LyXModule's that are available at
86  *  present.
87  */
88 class ModuleList {
89 public:
90         ///
91         ModuleList() {}
92         /// reads the modules from a file generated by configure.py
93         bool load();
94         ///
95         LyXModuleList::const_iterator begin() const;
96         ///
97         LyXModuleList::iterator begin();
98         ///
99         LyXModuleList::const_iterator end() const;
100         ///
101         LyXModuleList::iterator end();
102         ///
103         bool empty() const { return modlist_.empty(); }
104         /// Returns a pointer to the LyXModule with filename str.
105         /// Returns a null pointer if no such module is found.
106         LyXModule * operator[](std::string const & str);
107 private:
108         /// noncopyable
109         ModuleList(ModuleList const &);
110         ///
111         void operator=(ModuleList const &);
112         /// add a module to the list
113         void addLayoutModule(std::string const &, std::string const &, 
114                 std::string const &, std::vector<std::string> const &,
115                 std::vector<std::string> const &, std::vector<std::string> const &);
116         ///
117         std::vector<LyXModule> modlist_;
118 };
119
120 extern ModuleList moduleList;
121 }
122 #endif