Revision: 40708
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40708&view=rev
Author:   davidloman
Date:     2010-09-27 18:47:50 +0000 (Mon, 27 Sep 2010)

Log Message:
-----------
Add value updater for Config system.  Also centralized config map insert/get 
calls and made them thread safe via mutexes

Modified Paths:
--------------
    rt^3/trunk/include/Config.h
    rt^3/trunk/src/utility/Config.cxx

Modified: rt^3/trunk/include/Config.h
===================================================================
--- rt^3/trunk/include/Config.h 2010-09-27 18:35:05 UTC (rev 40707)
+++ rt^3/trunk/include/Config.h 2010-09-27 18:47:50 UTC (rev 40708)
@@ -40,18 +40,20 @@
 
        bool loadFile(QString pathAndFileName);
        QString getConfigValue(QString key);
+       void updateValue(QString key, QString value);
        QList<QString> getAllKeys();
 
 private:
        Config(); //Turn off Default cstr
        Config(const Config& c){}; //Turn off Copy cstr
        Config& operator=(const Config& c){}; //Turn off equal oper
+
        void processLine(QString line);
        void removeAllOccurances(QString* data, QString search,
                        QString replace);
 
-       QMutex lock;
        Logger* log;
+       QMutex mapLock;
        QMap<QString, QString>* configMap;
 
        static Config* pInstance;

Modified: rt^3/trunk/src/utility/Config.cxx
===================================================================
--- rt^3/trunk/src/utility/Config.cxx   2010-09-27 18:35:05 UTC (rev 40707)
+++ rt^3/trunk/src/utility/Config.cxx   2010-09-27 18:47:50 UTC (rev 40708)
@@ -26,6 +26,7 @@
 #include "Config.h"
 #include <QtCore/QFile>
 #include <QtCore/QStringList>
+#include <QtCore/QMutexLocker>
 
 Config* Config::pInstance = NULL;
 
@@ -108,9 +109,7 @@
     QString value = list[1];
 
     //this->log->logINFO("Config", "Key: '" + key + "' Value: '" + value + 
"'");
-
-    this->configMap->insert(key, value);
-
+    this->updateValue(key, value);
 }
 
 void Config::removeAllOccurances(QString* data, QString search, QString 
replace)
@@ -123,12 +122,21 @@
 
 QString Config::getConfigValue(QString key)
 {
+       QMutexLocker(&this->mapLock);
     return this->configMap->value(key, "") + "";
 }
 
+void
+Config::updateValue(QString key, QString value)
+{
+       QMutexLocker(&this->mapLock);
+       this->configMap->insert(key, value);
+}
+
 QList<QString> Config::getAllKeys()
 {
-    return this->configMap->uniqueKeys();
+       QMutexLocker(&this->mapLock);
+       return this->configMap->uniqueKeys();
 }
 
 // Local Variables: ***


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to