Google

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 
00143   void CleanUp ();
00144 
00151   virtual iConfigIterator *Enumerate(const char *Subsection = NULL);
00152 
00154   virtual bool KeyExists(const char *Key) const;
00156   virtual bool SubsectionExists(const char *Subsection) const;
00157 
00159   virtual int GetInt(const char *Key, int Def = 0) const;
00161   virtual float GetFloat(const char *Key, float Def = 0.0) const;
00163   virtual const char *GetStr(const char *Key, const char *Def = "") const;
00165   virtual bool GetBool(const char *Key, bool Def = false) const;
00167   virtual const char *GetComment(const char *Key) const;
00168 
00170   virtual void SetStr (const char *Key, const char *Val);
00172   virtual void SetInt (const char *Key, int Value);
00174   virtual void SetFloat (const char *Key, float Value);
00176   virtual void SetBool (const char *Key, bool Value);
00183   virtual bool SetComment (const char *Key, const char *Text);
00185   virtual void DeleteKey(const char *Key);
00187   virtual const char *GetEOFComment() const;
00189   virtual void SetEOFComment(const char *Text);
00190 
00191 private:
00192   friend class csConfigManagerIterator;
00193   // optimize mode?
00194   bool Optimize;
00195   // pointer to the dynamic config domain
00196   class csConfigDomain *DynamicDomain;
00197   // list of all domains (including the dynamic domain)
00198   class csConfigDomain *FirstDomain, *LastDomain;
00199   // list of all removed config files (only used in optimize mode)
00200   csVector Removed;
00201   // list of all iterators
00202   csVector Iterators;
00203 
00204   csConfigDomain *FindConfig(iConfigFile *cfg) const;
00205   csConfigDomain *FindConfig(const char *name) const;
00206   void ClearKeyAboveDynamic(const char *Key);
00207   void RemoveIterator(csConfigManagerIterator *it);
00208   void FlushRemoved(int n);
00209   int FindRemoved(const char *Filename) const;
00210   void RemoveDomain(class csConfigDomain *cfg);
00211 };
00212 
00213 #endif // __CFGMGR_H__

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