4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
21 * This class represents a particular LyX "module", which is like a layout
22 * file, except that it does not stand alone. In that sense, it is more like
23 * a LaTeX package, where a layout file corresponds to a LaTeX class. Or, in
24 * LyX's own terms, a module is more like an included file that can be used
25 * with various document classes. The difference is that using a module only
26 * means selecting it in the Document>Settings dialog, whereas including a
27 * layout file means layout file editing.
29 * In general, a given module can be used with any document class. That said,
30 * one module may `require' another, or it may `exclude' some other module.
31 * The requires and excludes are given in comments within the module file,
32 * which must begin roughly so:
33 * #\DeclareLyXModule{Theorems (By Section)}
34 * #\DeclateCategory{Theorems}
36 * #Numbers theorems and the like by section.
38 * #Requires: theorems-std | theorems-ams
39 * #Excludes: theorems-chap
40 * The description is used in the gui to give information to the user. The
41 * Requires, Excludes, and Category lines are read by the configuration script
42 * and written to a file lyxmodules.lst in the user configuration directory.
43 * That file is then read on startup to populate the ModuleList, below.
45 * Modules can also be "provided" or "excluded" by document classes, using
46 * the ProvidesModule and ExcludesModule tags.
52 LyXModule(std::string const & name, std::string const & id,
53 std::string const & description,
54 std::vector<std::string> const & packagelist,
55 std::vector<std::string> const & required,
56 std::vector<std::string> const & excludes,
57 std::string const & catgy, bool const local);
58 /// whether the required packages are available
59 bool isAvailable() const;
60 /// the missing prerequisites, if any
61 std::vector<std::string> prerequisites() const;
63 std::string const & getName() const { return name_; }
65 std::string const & getID() const { return id_; }
67 std::string const & getFilename() const { return filename_; }
69 std::string const & getDescription() const { return description_; }
71 std::vector<std::string> const & getPackageList() const
72 { return package_list_; }
74 std::vector<std::string> const & getRequiredModules() const
75 { return required_modules_; }
76 /// Modules this one excludes: the list should be treated disjunctively
77 std::vector<std::string> const & getExcludedModules() const
78 { return excluded_modules_; }
80 std::string category() const { return category_; }
81 /// Is this a local module (from the user directory)?
82 bool isLocal() const { return local_; }
83 /// \return true if the module is compatible with this one, i.e.,
84 /// it does not exclude us and we do not exclude it.
85 /// this will also return true if modname is unknown and we do not
86 /// exclude it, since in that case we cannot check its exclusions.
87 bool isCompatible(std::string const & modname) const;
89 static bool areCompatible(std::string const & mod1, std::string const & mod2);
91 /// what appears in the ui
93 /// the module's unique identifier
94 /// at present, this is the filename, without the extension
97 std::string filename_;
98 /// a short description for use in the ui
99 std::string description_;
100 /// the LaTeX packages on which this depends, if any
101 std::vector<std::string> package_list_;
102 /// Modules this one requires: at least one
103 std::vector<std::string> required_modules_;
104 /// Modules this one excludes: none of these
105 std::vector<std::string> excluded_modules_;
106 /// Category, also used in the UI
107 std::string category_;
108 // these are mutable because they are used to cache the results
109 // or an otherwise const operation.
111 mutable bool checked_;
113 mutable bool available_;
117 mutable std::vector<std::string> prerequisites_;
120 typedef std::vector<LyXModule> LyXModuleList;
123 * The ModuleList represents the various LyXModule's that are available at
130 /// reads the modules from a file generated by configure.py
133 LyXModuleList::const_iterator begin() const;
135 LyXModuleList::iterator begin();
137 LyXModuleList::const_iterator end() const;
139 LyXModuleList::iterator end();
141 bool empty() const { return modlist_.empty(); }
142 /// Returns a pointer to the LyXModule with filename str.
143 /// Returns a null pointer if no such module is found.
144 LyXModule const * operator[](std::string const & str) const;
146 LyXModule * operator[](std::string const & str);
149 ModuleList(ModuleList const &);
151 void operator=(ModuleList const &);
152 /// add a module to the list
153 void addLayoutModule(std::string const &, std::string const &,
154 std::string const &, std::vector<std::string> const &,
155 std::vector<std::string> const &, std::vector<std::string> const &,
156 std::string const &, bool const);
158 std::vector<LyXModule> modlist_;
161 extern ModuleList theModuleList;