Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29298/src/classes

Modified Files:
        Profile.cpp ConfigSourcesAll.cpp 
Log Message:
made AllConfigSources a singleton

Index: Profile.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/Profile.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -b -u -2 -r1.163 -r1.164
--- Profile.cpp 4 Jul 2005 20:53:33 -0000       1.163
+++ Profile.cpp 5 Jul 2005 12:34:35 -0000       1.164
@@ -368,5 +368,5 @@
 // ----------------------------------------------------------------------------
 
-// the global object containing all config sources used by Profile
+// the unique AllConfigSources object
 static AllConfigSources *gs_allConfigSources = NULL;
 
@@ -525,5 +525,5 @@
    ASSERT_MSG( !gs_allConfigSources, _T("recreating the configs?") );
 
-   gs_allConfigSources = new AllConfigSources(filename);
+   gs_allConfigSources = AllConfigSources::Init(filename);
 
    Profile *p = ProfileImpl::CreateProfile(_T(""),NULL);
@@ -537,5 +537,5 @@
    if ( gs_allConfigSources )
    {
-      delete gs_allConfigSources;
+      AllConfigSources::Cleanup();
       gs_allConfigSources = NULL;
    }

Index: ConfigSourcesAll.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/ConfigSourcesAll.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -u -2 -r1.1 -r1.2
--- ConfigSourcesAll.cpp        4 Jul 2005 20:53:33 -0000       1.1
+++ ConfigSourcesAll.cpp        5 Jul 2005 12:34:35 -0000       1.2
@@ -27,4 +27,5 @@
 
 #include "ConfigSourcesAll.h"
+#include "ConfigSourceLocal.h"
 #include "ConfigPrivate.h"
 
@@ -295,4 +296,6 @@
 M_LIST(LongList, long);
 
+AllConfigSources *AllConfigSources::ms_theInstance = NULL;
+
 // ----------------------------------------------------------------------------
 // AllConfigSources creation
@@ -365,5 +368,5 @@
          // find the place to insert this config source at
          long prio;
-         if ( !configLocal->Read(valuePrio, &prio) )
+         if ( !configLocal->Read(subkey + valuePrio, &prio) )
          {
             // insert at the end by default
@@ -405,8 +408,18 @@
 {
    const String& key = data.GetKey();
-   ASSERT_MSG( !key.empty() && key[0u] != _T('/'),
-                  _T("invalid key in AllConfigSources::Read()") );
+   ASSERT_MSG( !key.empty(), _T("empty config key") );
+
+   String fullpath;
+   if ( *key.c_str() != _T('/') )
+      fullpath << path << _T('/');
+   fullpath << key;
+
+   ASSERT_MSG( *fullpath.c_str() == _T('/'), _T("config paths must be 
absolute") );
+
+   ASSERT_MSG( fullpath.length() < 3 ||
+                  fullpath[1u] != 'M' ||
+                     fullpath[2u] != _T('/'),
+                        _T("config path must not start with /M") );
 
-   String fullpath = path + _T('/') + key;
    const bool isNumeric = data.GetType() == LookupData::LD_LONG;
 
@@ -447,8 +460,13 @@
    }
 
-   String fullpath = path + _T('/') + data.GetKey();
+   const String key = data.GetKey();
+   String fullpath;
+   if ( *key.c_str() != _T('/') )
+      fullpath << path << _T('/');
+
+   fullpath << key;
+
+   ASSERT_MSG( *fullpath.c_str() == _T('/'), _T("config paths must be 
absolute") );
 
-   ASSERT_MSG( !fullpath.empty() && fullpath[0u] == _T('/'),
-                  _T("config path must always be absolute") );
    ASSERT_MSG( fullpath.length() < 3 ||
                   fullpath[1u] != 'M' ||



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to