Main Page   Class Hierarchy   Compound List   File List   Compound Members  

resConfigRegistry.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2003 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #ifndef freecloth_resmgt_resConfigRegistry_h
00020 #define freecloth_resmgt_resConfigRegistry_h
00021 
00022 #ifndef freecloth_resmgt_package_h
00023 #include <freecloth/resmgt/package.h>
00024 #endif
00025 
00026 #ifndef freecloth_resmgt_rcBase_h
00027 #include <freecloth/resmgt/rcBase.h>
00028 #endif
00029 
00030 #ifndef freecloth_base_baTime_h
00031 #include <freecloth/base/baTime.h>
00032 #endif
00033 
00034 FREECLOTH_NAMESPACE_START
00035 
00036 ////////////////////////////////////////////////////////////////////////////////
00037 // FORWARD DECLARATIONS
00038 
00039 template <class T> class RCShdPtr;
00040 
00041 ////////////////////////////////////////////////////////////////////////////////
00042 /*!
00043  * \class ResConfigRegistryW freecloth/resmgt/resConfigRegistryW
00044  * \brief Interface for configuration writing.
00045  *
00046  * ResConfig objects save their contents using this object, which should store
00047  * in a manner than can be restored by ResConfigRegistryR.
00048  */
00049 class ResConfigRegistryW : public RCBase
00050 {
00051 public:
00052     //----- static member functions -----
00053 
00054     //! Implemented in derived class' source.
00055     // FIXME: implement this as an OS-dependent factory/abstract factory setup
00056     static RCShdPtr<ResConfigRegistryW> create( const String& groupName );
00057 
00058     //----- member functions -----
00059 
00060     virtual ~ResConfigRegistryW();
00061 
00062     virtual void writeString(
00063         const String& key,
00064         const String&
00065     ) = 0;
00066     virtual void writeUInt32(
00067         const String& key,
00068         UInt32
00069     );
00070     virtual void writeFloat(
00071         const String& key,
00072         Float
00073     );
00074     template <class T>
00075     void writeFloats(
00076         const String& key,
00077         const T&
00078     );
00079 
00080     virtual void writeEnum(
00081         const String& key,
00082         UInt32
00083     );
00084     virtual void writeBool(
00085         const String& key,
00086         bool
00087     );
00088     virtual void writeTimeDuration(
00089         const String& key,
00090         BaTime::Duration
00091     );
00092 };
00093 
00094 ////////////////////////////////////////////////////////////////////////////////
00095 /*!
00096  * \class ResConfigRegistryR freecloth/resmgt/resConfigRegistryR
00097  * \brief Interface for configuration reading.
00098  *
00099  * ResConfig objects load their contents using this object, which should
00100  * retrieve from the format stored by ResConfigRegistryW.
00101  */
00102 class ResConfigRegistryR : public RCBase {
00103 
00104 public:
00105     //----- static member functions -----
00106 
00107     //! Implemented in derived class' source.
00108     static RCShdPtr<ResConfigRegistryR> create( const String& groupName );
00109 
00110     //----- member functions -----
00111 
00112     virtual ~ResConfigRegistryR();
00113 
00114     virtual bool hasKey( const String& key ) const = 0;
00115 
00116     virtual String readString(
00117         const String& key,
00118         const String& def = ""
00119     ) const = 0;
00120     virtual UInt32 readUInt32(
00121         const String& key,
00122         UInt32 def = 0
00123     ) const;
00124     virtual Float readFloat(
00125         const String& key,
00126         Float def = 0.f
00127     ) const;
00128 #if HAVE_MEMBER_TEMPLATES
00129     template <class T>
00130     void readFloats(
00131         const String& key,
00132         T&,
00133         const T& def = T()
00134     );
00135 #endif
00136 
00137     //! No default to prevent accidental misuse
00138     UInt32 readEnum(
00139         const String& key,
00140         UInt32 nbEntries,
00141         UInt32 def
00142     ) const;
00143     bool readBool(
00144         const String& key,
00145         bool def = false
00146     ) const;
00147     BaTime::Duration readTimeDuration(
00148         const String& key,
00149         BaTime::Duration def = 0
00150     ) const;
00151 };
00152 
00153 FREECLOTH_NAMESPACE_END
00154 #endif

Generated on Fri May 2 13:04:25 2003 for Freecloth by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002