Configurator.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  */
00025 
00080 #if !defined(__CONFIGURATOR_H__)
00081 #define __CONFIGURATOR_H__
00082 
00083 #define CFG_MAX_CHILDREN  25
00084 #define CFG_MAX_VALUES    50
00085 
00086 typedef enum
00087 {
00088   c_none,
00089 
00090   // chipsets
00091   c_tsunami,
00092 
00093   // system devices
00094   c_ev68cb,
00095   c_serial,
00096 
00097   // pci devices
00098   c_ali,
00099   c_ali_ide,
00100   c_ali_usb,
00101   c_s3,
00102   c_cirrus,
00103   c_radeon,
00104   c_dec21143,
00105   c_sym53c895,
00106   c_sym53c810,
00107 
00108   // disk devices
00109   c_file,
00110   c_device,
00111   c_ramdisk,
00112 
00113   // gui's
00114   c_sdl,
00115   c_win32,
00116   c_x11
00117 } classid;
00118 
00119 class CConfigurator
00120 {
00121   public:
00122     CConfigurator(class CConfigurator*  parent, char*  name, char*  value,
00123                   char*  text, size_t textlen);
00124     ~       CConfigurator(void);
00125 
00126     char*   strip_string(char* c);
00127     void    add_value(char* n, char* v);
00128 
00129     char*   get_text_value(const char* n) { return get_text_value(n, (char*) 0); };
00130     char*   get_text_value(const char* n, const char* def);
00131 
00132     bool    get_bool_value(const char* n) { return get_bool_value(n, false); };
00133     bool    get_bool_value(const char* n, bool def);
00134 
00135     u64 get_num_value(const char* n, bool decimal_suffixes)
00136     {
00137       return get_num_value(n, decimal_suffixes, 0);
00138     };
00139     u64             get_num_value(const char*  n, bool decimal_suffixes, u64 def);
00140 
00141     classid         get_class_id()  { return myClassId; };
00142     void*           get_device()    { return myDevice; };
00143     int             get_flags()     { return myFlags; };
00144 
00145     char*           get_myName()    { return myName; };
00146     char*           get_myValue()   { return myValue; };
00147     CConfigurator*  get_myParent()  { return pParent; };
00148 
00149     void            initialize();
00150   private:
00151     class CConfigurator*  pParent;
00152     class CConfigurator*  pChildren[CFG_MAX_CHILDREN];
00153     int                   iNumChildren;
00154     char*                 myName;
00155     char*                 myValue;
00156     void*                 myDevice;
00157     classid               myClassId;
00158     int                   myFlags;
00159     int                   iNumValues;
00160     struct SCfg_Value
00161     {
00162       char*   name;
00163       char*   value;
00164     } pValues[CFG_MAX_VALUES];
00165 };
00166 #endif 

SourceForge.net Logo
Project space on SourceForge.net