configurator.h

Go to the documentation of this file.
00001 #ifndef CONFIGURATOR_CLASS
00002 #define CONFIGURATOR_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : configurator                                                      *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$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 // forward.
00021 class string_array;
00022 class string_set;
00023 class string_table;
00024 
00026 
00032 class DATA_STRUCTURE_CLASS_STYLE configurator
00033 {
00034 public:
00035   enum treatment_of_defaults { AUTO_STORE, RETURN_ONLY };
00037 
00041   inline configurator(treatment_of_defaults behavior) : _behavior(behavior) {}
00042   virtual ~configurator();
00043 
00045   inline treatment_of_defaults behavior() const { return _behavior; }
00047   inline void behavior(treatment_of_defaults new_behavior) {
00048     _behavior = (new_behavior == RETURN_ONLY)? RETURN_ONLY : AUTO_STORE;
00049   }
00050 
00051   virtual bool get(const istring &section, const istring &entry,
00052           istring &found) = 0;
00054 
00058   virtual bool put(const istring &section, const istring &entry,
00059           const istring &to_store) = 0;
00061 
00065   bool store(const istring &section, const istring &entry,
00066           const istring &to_store);
00068 
00070 
00072   istring load(const istring &section, const istring &entry,
00073           const istring &default_value);
00074 
00076   bool store(const istring &section, const istring &entry, int value);
00078   int load(const istring &section, const istring &entry, int def_value);
00079 
00080   // the various methods below that operate on sections and entries might not
00081   // be provided by all configurators.  that is why there are empty default
00082   // (or simplistic and slow) implementations provided below.
00083 
00084   virtual void sections(string_array &list);
00086 
00087   void section_set(string_set &list);
00089 
00092   virtual bool delete_entry(const istring & formal(section),
00093           const istring & formal(entry)) { return false; }
00095 
00096   virtual bool delete_section(const istring & formal(section) )
00097           { return false; }
00099 
00100   virtual bool section_exists(const istring &section);
00102 
00105   virtual bool get_section(const istring & formal(section),
00106           string_table & formal(found) ) { return false; }
00108 
00112   virtual bool put_section(const istring & formal(section),
00113           const string_table & formal(to_store) ) { return false; }
00115 
00119 private:
00120   treatment_of_defaults _behavior;  
00121 };
00122 
00123 #endif
00124 

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