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

GenericValues.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000-2003, 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 */
00030 
00055 #ifndef _GENERIC_VALUES_
00056 #define _GENERIC_VALUES_
00057 
00058 #include <iostream>    // needed for output stream
00059 
00060 using namespace std;
00061 
00063 enum GenericValueKind
00064 {
00065   GENERIC_VALUE_DOUBLE  = 0,
00066   GENERIC_VALUE_STRING  = 1,
00067   GENERIC_VALUE_BOOLEAN = 2,
00068   GENERIC_VALUE_INTEGER = 3,
00069 };
00070 
00071 /*****************************************************************************/
00072 /********************   CLASS GENERICVALUET   ********************************/
00073 /*****************************************************************************/
00074 
00079 class GenericValueT
00080 {
00081   // private member data
00082 private:
00083 
00084   const char*      m_strName;  
00086   void*            m_vAddress; 
00087   GenericValueKind m_type;     
00090   // public methods
00091 public:
00092 
00093   // constructor for the GenericValueT class
00094   GenericValueT( const char *strName, void *vAddress, GenericValueKind type );
00095 
00096   // destructor for the GenericValueT class
00097   ~GenericValueT( );
00098 
00099   // get methods for private member variables
00100   const char* getName ( );
00101 
00102   // methods to set/get the value of this generic variable
00103   bool  setValue( const char *strValue );
00104   char* getValue(       char *strValue );
00105 
00106   // display method
00107   void show( ostream& out, const char *strSeparator );
00108 };
00109 
00110 /*****************************************************************************/
00111 /*******************   CLASS GENERICVALUES   *********************************/
00112 /*****************************************************************************/
00113 
00124 class GenericValues
00125 {
00126   // private member data
00127 private:
00128 
00129   char  *m_strClassName;    
00132   GenericValueT ** m_values;
00134   int   m_iValuesTotal;     
00136   int   m_iMaxGenericValues;
00140   GenericValueT* getValuePtr( const char *strName                            );
00141 
00142 public:
00143 
00144   // constructor for the GenericValues class
00145   GenericValues           ( char *strName,              int iMaxValues       );
00146 
00147   // destructor for the GenericValues class
00148   virtual ~GenericValues  (                                                  );
00149 
00150   // get methods for private member variables
00151   char* getClassName      (                                                  );
00152   int   getValuesTotal    (                                                  );
00153 
00154   // method for adding a generic value to the collection
00155   bool addSetting( const char *strName, void *vAddress, GenericValueKind t );
00156 
00157   // methods for reading and writing generic values and collections of values
00158   virtual char* getValue  ( const char *strName,       char *strValue        );
00159   virtual bool  setValue  ( const char *strName, const char *strValue        );
00160   virtual bool  readValues( const char *strFile, const char *strSeparator = 0);
00161   virtual bool  saveValues( const char *strFile, const char *strSeparator = 0,
00162                                                        bool bAppend = true   );
00163 
00164   // display method
00165   virtual void  show      ( ostream& out,        const char *strSeparator    );
00166 };
00167 
00168 #endif

Generated on Fri Nov 7 11:45:39 2003 for UvA Trilearn 2003 Base Code by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001