Main Page   Class Hierarchy   Compound List   File List   Compound Members  

cfgmgr.h

00001 /*
00002     Copyright (C) 2001 by Martin Geisse <mgeisse@gmx.net>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CFGMGR_H__
00020 #define __CFGMGR_H__
00021 
00022 #include "iutil/cfgmgr.h"
00023 #include "csutil/csvector.h"
00024 
00030 class csConfigManager : public iConfigManager
00031 {
00032 public:
00033   SCF_DECLARE_IBASE;
00034 
00048   csConfigManager(iConfigFile *DynamicDomain, bool Optimize);
00050   virtual ~csConfigManager();
00051 
00053   virtual void AddDomain(iConfigFile*, int priority);
00055   virtual iConfigFile *AddDomain(char const* path, iVFS*, int priority);
00057   virtual void RemoveDomain(iConfigFile*);
00059   virtual void RemoveDomain(char const* path);
00061   virtual iConfigFile* LookupDomain(char const* path) const;
00063   virtual void SetDomainPriority(char const* path, int priority);
00065   virtual void SetDomainPriority(iConfigFile*, int priority);
00067   virtual int GetDomainPriority(char const* path) const;
00069   virtual int GetDomainPriority(iConfigFile*) const;
00070 
00075   virtual bool SetDynamicDomain(iConfigFile*);
00077   virtual iConfigFile *GetDynamicDomain() const;
00079   virtual void SetDynamicDomainPriority(int priority);
00081   virtual int GetDynamicDomainPriority() const;
00082 
00084   virtual void FlushRemoved();
00085 
00090   virtual const char* GetFileName () const;
00091 
00096   virtual iVFS* GetVFS () const;
00097 
00102   virtual void SetFileName (const char*, iVFS*);
00103 
00120   virtual bool Load (const char* iFileName, iVFS* = NULL, bool Merge = false,
00121     bool NewWins = true);
00122 
00127   virtual bool Save ();
00128 
00135   virtual bool Save (const char *iFileName, iVFS* = NULL);
00136 
00138   virtual void Clear();
00139 
00146   virtual iConfigIterator *Enumerate(const char *Subsection = NULL);
00147 
00149   virtual bool KeyExists(const char *Key) const;
00151   virtual bool SubsectionExists(const char *Subsection) const;
00152 
00154   virtual int GetInt(const char *Key, int Def = 0) const;
00156   virtual float GetFloat(const char *Key, float Def = 0.0) const;
00158   virtual const char *GetStr(const char *Key, const char *Def = "") const;
00160   virtual bool GetBool(const char *Key, bool Def = false) const;
00162   virtual const char *GetComment(const char *Key) const;
00163 
00165   virtual void SetStr (const char *Key, const char *Val);
00167   virtual void SetInt (const char *Key, int Value);
00169   virtual void SetFloat (const char *Key, float Value);
00171   virtual void SetBool (const char *Key, bool Value);
00178   virtual bool SetComment (const char *Key, const char *Text);
00180   virtual void DeleteKey(const char *Key);
00182   virtual const char *GetEOFComment() const;
00184   virtual void SetEOFComment(const char *Text);
00185 
00186 private:
00187   friend class csConfigManagerIterator;
00188   // optimize mode?
00189   bool Optimize;
00190   // pointer to the dynamic config domain
00191   class csConfigDomain *DynamicDomain;
00192   // list of all domains (including the dynamic domain)
00193   class csConfigDomain *FirstDomain, *LastDomain;
00194   // list of all removed config files (only used in optimize mode)
00195   csVector Removed;
00196   // list of all iterators
00197   csVector Iterators;
00198 
00199   csConfigDomain *FindConfig(iConfigFile *cfg) const;
00200   csConfigDomain *FindConfig(const char *name) const;
00201   void ClearKeyAboveDynamic(const char *Key);
00202   void RemoveIterator(csConfigManagerIterator *it);
00203   void FlushRemoved(int n);
00204   int FindRemoved(const char *Filename) const;
00205   void RemoveDomain(class csConfigDomain *cfg);
00206 };
00207 
00208 #endif // __CFGMGR_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000