whitespace.
[lyx.git] / src / LayoutModuleList.h
blob2d93bff9a1763497d8060c468e705f5b532a5341
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.
7 * \author Richard Heck
9 * Full author contact details are available in file CREDITS.
12 #ifndef LAYOUTMODULELIST_H
13 #define LAYOUTMODULELIST_H
15 #include <list>
16 #include <string>
18 namespace lyx {
20 class LayoutFile;
22 class LayoutModuleList {
23 public:
24 ///
25 typedef std::list<std::string>::const_iterator const_iterator;
26 ///
27 typedef std::list<std::string>::iterator iterator;
28 ///
29 iterator begin() { return lml_.begin(); }
30 ///
31 iterator end() { return lml_.end(); }
32 ///
33 const_iterator begin() const { return lml_.begin(); }
34 ///
35 const_iterator end() const { return lml_.end(); }
36 ///
37 void clear() { lml_.clear(); }
38 ///
39 bool empty() const { return lml_.empty(); }
40 ///
41 iterator erase(iterator pos) { return lml_.erase(pos); }
42 ///
43 iterator insert(iterator pos, std::string const & str)
44 { return lml_.insert(pos, str); }
45 ///
46 void push_back(std::string const & str) { lml_.push_back(str); }
47 ///
48 size_t size() const { return lml_.size(); }
49 /// This is needed in GuiDocument. It seems better than an
50 /// implicit conversion.
51 std::list<std::string> const & list() const { return lml_; }
52 /// Checks to make sure module's requriements are satisfied, that it does
53 /// not conflict with already-present modules, isn't already loaded, etc.
54 bool moduleCanBeAdded(std::string const & modName,
55 LayoutFile const * const lay) const;
56 /// If the user changes the base class for a given document, then the
57 /// associated module list has to be updated. This just calls
58 /// (i) removeBadModules()
59 /// (ii) addDefaultModules()
60 /// (iii) checkModuleConsistency()
61 /// in that order, for which see below.
62 /// \param lay The new base class.
63 /// \param removedModules Modules the user explicitly removed and so
64 /// which should not be included.
65 /// \return true if no changes had to be made, false if some did have
66 /// to be made.
67 bool adaptToBaseClass(LayoutFile const * const lay,
68 std::list<std::string> const & removedModules);
69 private:
70 /// Removes modules excluded by, provided by, etc, the base class.
71 /// \param lay The document class against which to check.
72 /// \return true, if modules were consistent, false if changes had
73 /// to be made.
74 bool removeBadModules(LayoutFile const * const lay);
75 /// Adds default modules, if they're addable.
76 /// \param lay The base class from which to get default modules.
77 /// \param removedModules Modules the user has explicitly removed.
78 void addDefaultModules(LayoutFile const * const lay,
79 std::list<std::string> removedModules);
80 /// Checks for consistency among modules: makes sure requirements
81 /// are met, no modules exclude one another, etc, and resolves any
82 /// such conflicts, leaving us with a consistent collection.
83 /// \param lay The base class against which to check.
84 /// \return true if modules were consistent, false if changes had
85 /// to be made.
86 bool checkModuleConsistency(LayoutFile const * const lay);
87 ///
88 std::list<std::string> lml_;
91 #endif