configlet.h

Go to the documentation of this file.
00001 #ifndef CONFIGLET_CLASS
00002 #define CONFIGLET_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : configlet                                                         *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2001-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "data_structure_dll.h"
00019 
00020 #include <basis/istring.h>
00021 #include <basis/object_base.h>
00022 
00023 // forward.
00024 class configurator;
00025 
00027 
00033 class DATA_STRUCTURE_CLASS_STYLE configlet : public virtual object_base
00034 {
00035 public:
00036   configlet(const istring &section, const istring &entry);
00038   configlet(const configlet &to_copy);
00039 
00040   virtual ~configlet();
00041 
00042   IMPLEMENT_CLASS_NAME("configlet");
00043 
00044   configlet &operator =(const configlet &to_copy);
00045 
00046   const istring &section() const;
00048   const istring &entry() const;
00050 
00051   void section(const istring &new_section) const;
00053   void entry(const istring &new_entry) const;
00055 
00056   virtual bool load(configurator &config) = 0;
00058 
00064   virtual bool store(configurator &config) const = 0;
00066 
00067   virtual configlet *duplicate() const = 0;
00069 
00071 private:
00072   istring *_section;  
00073   istring *_entry;  
00074 };
00075 
00077 
00079 
00085 class DATA_STRUCTURE_CLASS_STYLE string_configlet : public configlet
00086 {
00087 public:
00088   string_configlet(const istring &section, const istring &entry,
00089           const istring &current_value = istring::empty_string(),
00090           const istring &default_value = istring::empty_string());
00091   string_configlet(const string_configlet &to_copy);
00092   virtual ~string_configlet();
00093 
00094   string_configlet &operator =(const string_configlet &to_copy);
00095 
00096   const istring &current_value() const;
00097   const istring &default_value() const;
00098 
00099   void current_value(const istring &new_current);
00100   void default_value(const istring &new_default);
00101   
00102   virtual bool load(configurator &config);
00103   virtual bool store(configurator &config) const;
00104 
00105   configlet *duplicate() const;
00106 
00107 private:
00108   istring *_current;
00109   istring *_default;
00110 };
00111 
00113 
00115 
00116 class DATA_STRUCTURE_CLASS_STYLE int_configlet : public configlet
00117 {
00118 public:
00119   int_configlet(const istring &section, const istring &entry,
00120           int current_value = 0, int default_value = 0);
00121   virtual ~int_configlet();
00122 
00123   int current_value() const { return _current; }
00124 
00125   virtual void current_value(int new_current);
00127 
00128   int default_value() const { return _default; }
00129   void default_value(int new_default) { _default = new_default; }
00130 
00131   virtual bool load(configurator &config);
00132   virtual bool store(configurator &config) const;
00133 
00134   configlet *duplicate() const;
00135 
00136 private:
00137   int _current;
00138   int _default;
00139 };
00140 
00142 
00144 
00151 class DATA_STRUCTURE_CLASS_STYLE bounded_int_configlet : public int_configlet
00152 {
00153 public:
00154   bounded_int_configlet(const istring &section, const istring &entry,
00155           int current_value, int default_value, int minimum, int maximum);
00156   virtual ~bounded_int_configlet();
00157 
00158   virtual void current_value(int new_current);
00159 
00160   int minimum() const { return _minimum; }
00161   int maximum() const { return _maximum; }
00162   
00163   void minimum(int new_min) { _minimum = new_min; }
00164   void maximum(int new_max) { _maximum = new_max; }
00165 
00166   configlet *duplicate() const;
00167 
00168 private:
00169   int _minimum;
00170   int _maximum;
00171 };
00172 
00173 #endif
00174 

Generated on Fri Nov 28 04:29:11 2008 for HOOPLE Libraries by  doxygen 1.5.1