From 39e77f7d7f8a2c9148fb1c064c2e1437ad378ccb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 9 Aug 2006 07:50:49 +0000 Subject: Renamed it, it also is no longer a singleton, although your child class could be. --- src/configmanager.cpp | 63 ----------------------------------------------- src/configmanager.h | 24 ------------------ src/configmanagerbase.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++ src/configmanagerbase.h | 24 ++++++++++++++++++ 4 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 src/configmanager.cpp delete mode 100644 src/configmanager.h create mode 100644 src/configmanagerbase.cpp create mode 100644 src/configmanagerbase.h (limited to 'src') diff --git a/src/configmanager.cpp b/src/configmanager.cpp deleted file mode 100644 index 6c239f8..0000000 --- a/src/configmanager.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include "xmlnode.h" -#include "xmlfilereader.h" -#include "configmanagerbase.h" - -ConfigManagerBase::ConfigManager() -{ -} - -ConfigManagerBase::~ConfigManager() -{ -} - -void ConfigManagerBase::addSearchPath( const std::string &sPath ) -{ - lSearchPath.push_back( sPath ); -} - -void ConfigManagerBase::loadConfig( const char *lpProfile ) -{ - // Try a few locations... - std::list::const_iterator i; - for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ ) - { - if( parseConfig( (*i).c_str(), lpProfile ) ) - { - break; - } - } -} - -bool ConfigManagerBase::parseConfig( const char *lpFileName, const char *lpProfile ) -{ - XmlNode *pRoot, *pCur; - XmlFileReader doc( lpFileName ); - - pRoot = doc.getRoot(); - if( pRoot == NULL ) - { - return false; - } - - if( strcmp("config", pRoot->getName() ) ) - { - return false; - } - - for( int j = 0;; j++ ) - { - pCur = pRoot->getChild( "profile", j ); - if( pCur == NULL ) - return false; - - if( !strcmp( pCur->getProperty("id"), lpProfile ) ) - { - return processProfile( pCur ); - } - } - - return false; -} - diff --git a/src/configmanager.h b/src/configmanager.h deleted file mode 100644 index b60c73a..0000000 --- a/src/configmanager.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CONFIG_MANAGER_BASE_H -#define CONFIG_MANAGER_BASE_H - -#include -#include - -class ConfigManagerBase -{ -public: - ConfigManagerBase(); - ~ConfigManagerBase(); - -public: - void addSearchPath( const std::string &sPath ); - void loadConfig( const char *lpProfile="default" ); - -private: - bool parseConfig( const char *lpFileName, const char *lpProfile ); - virtual bool processProfile( class XmlNode *pBase )=0; - - std::list lSearchPath; -}; - -#endif diff --git a/src/configmanagerbase.cpp b/src/configmanagerbase.cpp new file mode 100644 index 0000000..6c239f8 --- /dev/null +++ b/src/configmanagerbase.cpp @@ -0,0 +1,63 @@ +#include +#include +#include "xmlnode.h" +#include "xmlfilereader.h" +#include "configmanagerbase.h" + +ConfigManagerBase::ConfigManager() +{ +} + +ConfigManagerBase::~ConfigManager() +{ +} + +void ConfigManagerBase::addSearchPath( const std::string &sPath ) +{ + lSearchPath.push_back( sPath ); +} + +void ConfigManagerBase::loadConfig( const char *lpProfile ) +{ + // Try a few locations... + std::list::const_iterator i; + for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ ) + { + if( parseConfig( (*i).c_str(), lpProfile ) ) + { + break; + } + } +} + +bool ConfigManagerBase::parseConfig( const char *lpFileName, const char *lpProfile ) +{ + XmlNode *pRoot, *pCur; + XmlFileReader doc( lpFileName ); + + pRoot = doc.getRoot(); + if( pRoot == NULL ) + { + return false; + } + + if( strcmp("config", pRoot->getName() ) ) + { + return false; + } + + for( int j = 0;; j++ ) + { + pCur = pRoot->getChild( "profile", j ); + if( pCur == NULL ) + return false; + + if( !strcmp( pCur->getProperty("id"), lpProfile ) ) + { + return processProfile( pCur ); + } + } + + return false; +} + diff --git a/src/configmanagerbase.h b/src/configmanagerbase.h new file mode 100644 index 0000000..b60c73a --- /dev/null +++ b/src/configmanagerbase.h @@ -0,0 +1,24 @@ +#ifndef CONFIG_MANAGER_BASE_H +#define CONFIG_MANAGER_BASE_H + +#include +#include + +class ConfigManagerBase +{ +public: + ConfigManagerBase(); + ~ConfigManagerBase(); + +public: + void addSearchPath( const std::string &sPath ); + void loadConfig( const char *lpProfile="default" ); + +private: + bool parseConfig( const char *lpFileName, const char *lpProfile ); + virtual bool processProfile( class XmlNode *pBase )=0; + + std::list lSearchPath; +}; + +#endif -- cgit v1.2.3