CrystalSpace

Public API Reference

csutil/cfgmgr.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2001 by Martin Geisse <[email protected]>
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 __CS_CFGMGR_H__
00020 #define __CS_CFGMGR_H__
00021 
00026 #include "csextern.h"
00027 #include "csutil/array.h"
00028 #include "csutil/refarr.h"
00029 #include "csutil/scf_implementation.h"
00030 #include "iutil/cfgmgr.h"
00031 
00032 
00033 class csConfigManagerIterator;
00034 
00040 class CS_CRYSTALSPACE_EXPORT csConfigManager 
00041   : public scfImplementation2<csConfigManager, 
00042                               iConfigManager,
00043                               scfFakeInterface<iConfigFile> >
00044 {
00045 public:
00046 
00060   csConfigManager(iConfigFile *DynamicDomain = 0, bool Optimize = false);
00062   virtual ~csConfigManager();
00063 
00068   virtual void AddDomain(iConfigFile*, int priority);
00078   virtual iConfigFile* AddDomain(char const* path, iVFS*, int priority);
00086   virtual void RemoveDomain(iConfigFile*);
00088   virtual void RemoveDomain(char const* path);
00093   virtual iConfigFile* LookupDomain(char const* path) const;
00095   virtual void SetDomainPriority(char const* path, int priority);
00100   virtual void SetDomainPriority(iConfigFile*, int priority);
00105   virtual int GetDomainPriority(char const* path) const;
00110   virtual int GetDomainPriority(iConfigFile*) const;
00111 
00117   virtual bool SetDynamicDomain(iConfigFile*);
00123   virtual iConfigFile *GetDynamicDomain() const;
00125   virtual void SetDynamicDomainPriority(int priority);
00127   virtual int GetDynamicDomainPriority() const;
00128 
00130   virtual void FlushRemoved();
00131 
00136   virtual const char* GetFileName () const;
00137 
00142   virtual iVFS* GetVFS () const;
00143 
00150   virtual void SetFileName (const char*, iVFS*);
00151 
00168   virtual bool Load (const char* iFileName, iVFS* = 0, bool Merge = false,
00169     bool NewWins = true);
00170 
00175   virtual bool Save ();
00176 
00183   virtual bool Save (const char *iFileName, iVFS* = 0);
00184 
00186   virtual void Clear ();
00187 
00189   void CleanUp ();
00190 
00197   virtual csPtr<iConfigIterator> Enumerate(const char *Subsection = 0);
00198 
00200   virtual bool KeyExists(const char *Key) const;
00202   virtual bool SubsectionExists(const char *Subsection) const;
00203 
00205   virtual int GetInt(const char *Key, int Def = 0) const;
00207   virtual float GetFloat(const char *Key, float Def = 0.0) const;
00209   virtual const char *GetStr(const char *Key, const char *Def = "") const;
00211   virtual bool GetBool(const char *Key, bool Def = false) const;
00213   virtual const char *GetComment(const char *Key) const;
00214 
00216   virtual void SetStr (const char *Key, const char *Val);
00218   virtual void SetInt (const char *Key, int Value);
00220   virtual void SetFloat (const char *Key, float Value);
00222   virtual void SetBool (const char *Key, bool Value);
00229   virtual bool SetComment (const char *Key, const char *Text);
00231   virtual void DeleteKey(const char *Key);
00233   virtual const char *GetEOFComment() const;
00235   virtual void SetEOFComment(const char *Text);
00236 
00237 private:
00238   friend class csConfigManagerIterator;
00240   bool Optimize;
00242   class csConfigDomain *DynamicDomain;
00244   class csConfigDomain *FirstDomain, *LastDomain;
00246   csRefArray<iConfigFile> Removed;
00248   csArray<iConfigIterator*> Iterators;
00249 
00250   csConfigDomain *FindConfig(iConfigFile *cfg) const;
00251   csConfigDomain *FindConfig(const char *name) const;
00252   void ClearKeyAboveDynamic(const char *Key);
00253   void RemoveIterator(csConfigManagerIterator *it);
00254   void FlushRemoved(size_t n);
00255   size_t FindRemoved(const char *Filename) const;
00256   void RemoveDomain(class csConfigDomain *cfg);
00257 };
00258 
00259 #endif // __CS_CFGMGR_H__

Generated for Crystal Space by doxygen 1.4.7