Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

GenericValues.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000-2002, Jelle Kok, University of Amsterdam
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without 
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice, this 
00009 list of conditions and the following disclaimer. 
00010 
00011 2. Redistributions in binary form must reproduce the above copyright notice, 
00012 this list of conditions and the following disclaimer in the documentation 
00013 and/or other materials provided with the distribution. 
00014 
00015 3. Neither the name of the University of Amsterdam nor the names of its 
00016 contributors may be used to endorse or promote products derived from this 
00017 software without specific prior written permission. 
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
00023 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00024 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00025 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00026 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
00027 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00028 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00054 #ifndef _GENERIC_VALUES_
00055 #define _GENERIC_VALUES_
00056 
00057 #include <ostream.h>    // needed for output stream
00058 
00060 enum GenericValueKind
00061 {
00062   GENERIC_VALUE_DOUBLE  = 0,
00063   GENERIC_VALUE_STRING  = 1,
00064   GENERIC_VALUE_BOOLEAN = 2,
00065   GENERIC_VALUE_INTEGER = 3,
00066 };
00067 
00068 /******************************************************************************/
00069 /********************   CLASS GENERICVALUET   *********************************/
00070 /******************************************************************************/
00071 
00076 class GenericValueT
00077 {
00078   // private member data
00079 private:
00080 
00081   const char*      m_strName;  
00083   void*            m_vAddress; 
00084   GenericValueKind m_type;     
00087   // public methods
00088 public:
00089 
00090   // constructor for the GenericValueT class
00091   GenericValueT( const char *strName, void *vAddress, GenericValueKind type );
00092 
00093   // destructor for the GenericValueT class
00094   ~GenericValueT( );
00095 
00096   // get methods for private member variables
00097   const char* getName ( );
00098 
00099   // methods to set/get the value of this generic variable
00100   bool  setValue( const char *strValue );
00101   char* getValue(       char *strValue );
00102 
00103   // display method
00104   void show( ostream& out, const char *strSeparator );
00105 };
00106 
00107 /******************************************************************************/
00108 /********************   CLASS GENERICVALUES   *********************************/
00109 /******************************************************************************/
00110 
00120 class GenericValues
00121 {
00122   // private member data
00123 private:
00124 
00125   char  *m_strClassName;    
00128   GenericValueT ** m_values;
00130   int   m_iValuesTotal;     
00132   int   m_iMaxGenericValues;
00136   GenericValueT* getValuePtr( const char *strName                             );
00137 
00138 public:
00139 
00140   // constructor for the GenericValues class
00141   GenericValues           ( char *strName,              int iMaxValues        );
00142 
00143   // destructor for the GenericValues class
00144   virtual ~GenericValues  (                                                   );
00145 
00146   // get methods for private member variables
00147   char* getClassName      (                                                   );
00148   int   getValuesTotal    (                                                   );
00149 
00150   // method for adding a generic value to the collection
00151   bool addSetting( const char *strName, void *vAddress, GenericValueKind t );
00152 
00153   // methods for reading and writing generic values and collections of values
00154   virtual char* getValue  ( const char *strName,       char *strValue         );
00155   virtual bool  setValue  ( const char *strName, const char *strValue         );
00156   virtual bool  readValues( const char *strFile, const char *strSeparator = 0 );
00157   virtual bool  saveValues( const char *strFile, const char *strSeparator = 0,
00158                                                        bool bAppend = true    );
00159 
00160   // display method
00161   virtual void  show      ( ostream& out,        const char *strSeparator     );
00162 };
00163 
00164 #endif

Generated on Tue Jul 2 10:18:51 2002 for UvA Trilearn 2002 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001