]> git.lyx.org Git - features.git/commitdiff
Constify a bunch of stuff that can be const.
authorRichard Heck <rgheck@comcast.net>
Fri, 14 Aug 2009 15:46:10 +0000 (15:46 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 14 Aug 2009 15:46:10 +0000 (15:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31037 a592a061-630c-0410-9148-cb99ea01b6c8

src/ModuleList.cpp
src/ModuleList.h
src/frontends/qt4/GuiDocument.cpp

index 34c47b7cf34c6647ed8ed323efb82392dd3412d4..85066a899e850d3596a2eabe86aacb97ab306d24 100644 (file)
@@ -45,7 +45,7 @@ LyXModule::LyXModule(string const & n, string const & i,
 }
 
 
-bool LyXModule::isAvailable() {
+bool LyXModule::isAvailable() const {
 #ifdef TEX2LYX
        return true;
 #else
@@ -242,15 +242,26 @@ LyXModuleList::iterator ModuleList::end()
 }
 
 
-LyXModule * ModuleList::operator[](string const & str)
+LyXModule const * ModuleList::operator[](string const & str) const
 {
-       LyXModuleList::iterator it = modlist_.begin();
+       LyXModuleList::const_iterator it = modlist_.begin();
        for (; it != modlist_.end(); ++it)
                if (it->getID() == str) {
-                       LyXModule & mod = *it;
+                       LyXModule const & mod = *it;
                        return &mod;
                }
        return 0;
 }
 
+LyXModule * ModuleList::operator[](string const & str)
+{
+       LyXModuleList::iterator it = modlist_.begin();
+       for (; it != modlist_.end(); ++it)
+               if (it->getID() == str) {
+               LyXModule & mod = *it;
+               return &mod;
+               }
+               return 0;
+}
+
 } // namespace lyx
index d79138f213196121683b8d77192955e1e7970f2e..c9a6f1f4d7effbf8068206bd2fd281b02621de60 100644 (file)
@@ -57,7 +57,7 @@ public:
                  std::vector<std::string> const & excludes,
                  std::string const & catgy);
        /// whether the required packages are available
-       bool isAvailable();
+       bool isAvailable() const;
        ///
        std::string const & getName() const { return name_; }
        ///
@@ -102,10 +102,12 @@ private:
        std::vector<std::string> excluded_modules_;
        /// Category, also used in the UI
        std::string category_;
+       // these are mutable because they are used to cache the results
+       // or an otherwise const operation.
        ///
-       bool checked_;
+       mutable bool checked_;
        ///
-       bool available_;
+       mutable bool available_;
 };
 
 typedef std::vector<LyXModule> LyXModuleList;
@@ -132,8 +134,10 @@ public:
        bool empty() const { return modlist_.empty(); }
        /// Returns a pointer to the LyXModule with filename str.
        /// Returns a null pointer if no such module is found.
+       LyXModule const * operator[](std::string const & str) const;
+       /// 
        LyXModule * operator[](std::string const & str);
-private:
+       private:
        /// noncopyable
        ModuleList(ModuleList const &);
        ///
index 39ee411faea829daeba329370a523065e4f05cb7..b62b415c22d48a015703b4ca414371b29f80df3e 100644 (file)
@@ -243,7 +243,7 @@ vector<string> getPackageList(string const & modName)
 
 bool isModuleAvailable(string const & modName)
 {
-       LyXModule * mod = theModuleList[modName];
+       LyXModule const * const mod = theModuleList[modName];
        if (!mod)
                return false;
        return mod->isAvailable();
@@ -2694,7 +2694,7 @@ list<GuiDocument::modInfoStruct> const
        for (; it != end; ++it) {
                modInfoStruct m;
                m.id = *it;
-               LyXModule * mod = theModuleList[*it];
+               LyXModule const * const mod = theModuleList[*it];
                if (mod)
                        // FIXME Unicode
                        m.name = toqstr(translateIfPossible(from_utf8(mod->getName())));