]> git.lyx.org Git - features.git/blob - src/ModuleList.h
75c5854f11f9b02ce73dabc5bccd9d80f845efb6
[features.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 class LyXModule {
27 public:
28         ///
29         LyXModule(std::string n, std::string f, std::string d,
30                   std::vector<std::string> p);
31         /// whether the required packages are available
32         bool isAvailable();
33         /// what appears in the ui
34         std::string name;
35         /// the filename, without any path
36         std::string filename;
37         /// a short description for use in the ui
38         std::string description;
39         /// the LaTeX packages on which this depends, if any (not implemented)
40         std::vector<std::string> packageList;
41 private:
42         ///
43         bool checked;
44         ///
45         bool available;
46 };
47
48 typedef std::vector<LyXModule> LyXModuleList;
49
50 /**
51  *  The ModuleList represents the various LyXModule's that are available at
52  *  present.
53  */
54 class ModuleList {
55 public:
56         ///
57         ModuleList() {}
58         /// reads the modules from a file generated by configure.py
59         bool load();
60         /// add a module to the list
61         void addLayoutModule(std::string const & name,
62                 std::string const & filename, std::string const & description,
63                 std::vector<std::string> const & packages);
64         ///
65         LyXModuleList::const_iterator begin() const;
66         ///
67         LyXModuleList::iterator begin();
68         ///
69         LyXModuleList::const_iterator end() const;
70         ///
71         LyXModuleList::iterator end();
72         ///
73         bool empty() const { return modlist_.empty(); }
74         /// Returns a pointer to the LyXModule with name str.
75         /// Returns a null pointer if no such module is found.
76         LyXModule * operator[](std::string const & str);
77 private:
78         /// noncopyable
79         ModuleList(ModuleList const &);
80         void operator=(ModuleList const &);
81
82         ///
83         std::vector<LyXModule> modlist_;
84 };
85
86 extern ModuleList moduleList;
87 }
88 #endif