]> git.lyx.org Git - lyx.git/blob - src/ModuleList.h
2281a5d74c48c8d9e3ec2aef34880e4389d69a92
[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 //FIXME Give us some access functions here.
28 class LyXModule {
29 public:
30         ///
31         LyXModule(std::string const & n, std::string const & f, 
32                   std::string const & d, std::vector<std::string> const & p,
33                   std::vector<std::string> const & r, 
34                   std::vector<std::string> const & e);
35         /// whether the required packages are available
36         bool isAvailable();
37         ///
38         std::string const & getName() const { return name; }
39         ///
40         std::string const & getFilename() const { return filename; }
41         ///
42         std::string const & getDescription() const { return description; }
43         ///
44         std::vector<std::string> const & getPackageList() const
45                 { return packageList; }
46         ///
47         std::vector<std::string> const & getRequiredModules() const 
48                 { return requiredModules; }
49         /// Modules this one excludes: the list should be treated disjunctively
50         std::vector<std::string> const & getExcludedModules() const 
51                 { return excludedModules; }
52         
53 private:
54         /// what appears in the ui
55         std::string name;
56         /// the filename, without any path
57         std::string filename;
58         /// a short description for use in the ui
59         std::string description;
60         /// the LaTeX packages on which this depends, if any
61         std::vector<std::string> packageList;
62         /// Modules this one requires: at least one
63         std::vector<std::string> requiredModules;
64         /// Modules this one excludes: none of these
65         std::vector<std::string> excludedModules;
66         ///
67         bool checked;
68         ///
69         bool available;
70 };
71
72 typedef std::vector<LyXModule> LyXModuleList;
73
74 /**
75  *  The ModuleList represents the various LyXModule's that are available at
76  *  present.
77  */
78 class ModuleList {
79 public:
80         ///
81         ModuleList() {}
82         /// reads the modules from a file generated by configure.py
83         bool load();
84         ///
85         LyXModuleList::const_iterator begin() const;
86         ///
87         LyXModuleList::iterator begin();
88         ///
89         LyXModuleList::const_iterator end() const;
90         ///
91         LyXModuleList::iterator end();
92         ///
93         bool empty() const { return modlist_.empty(); }
94         /// Returns a pointer to the LyXModule with name str.
95         /// Returns a null pointer if no such module is found.
96         LyXModule * operator[](std::string const & str);
97 private:
98         /// noncopyable
99         ModuleList(ModuleList const &);
100         ///
101         void operator=(ModuleList const &);
102         /// add a module to the list
103         void addLayoutModule(std::string const &, std::string const &, 
104                 std::string const &, std::vector<std::string> const &,
105                 std::vector<std::string> const &, std::vector<std::string> const &);
106         ///
107         std::vector<LyXModule> modlist_;
108 };
109
110 extern ModuleList moduleList;
111 }
112 #endif