nis-util  1.0.D108
lib/configuration/item.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License along
00016 // with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_CONFIGURATION_ITEM_H
00020 #define LIB_CONFIGURATION_ITEM_H
00021 
00022 #include <boost/shared_ptr.hpp>
00023 
00024 #include <lib/source_location.h>
00025 
00026 #define ITEM_WARNING "warning"
00027 #define ITEM_NAME_LENGTH_MAXIMUM "name-length-maximum"
00028 
00034 class configuration_item
00035 {
00036 public:
00037     typedef boost::shared_ptr<configuration_item> pointer;
00038 
00042     virtual ~configuration_item();
00043 
00057     enum level_t
00058     {
00063         level_builtin,
00064 
00068         level_etc_nis_util_conf,
00069 
00073         level_home_nis_util_rc,
00074 
00080         level_nis_util_env,
00081 
00099         level_nis_util_prog_env,
00100 
00105         level_command_line_file,
00106 
00111         level_command_line_option
00112     };
00113 
00118     static const char *level_name(level_t value);
00119 
00124     virtual rcstring get_string_value(void) const = 0;
00125 
00130     virtual bool get_bool_value(void) const = 0;
00131 
00136     virtual long get_long_value(void) const = 0;
00137 
00142     const source_location &get_source_location(void) const { return locn; }
00143 
00149     level_t get_level(void) const { return level; }
00150 
00155     rcstring get_name(void) const { return name; }
00156 
00161     void print(void) const;
00162 
00163 protected:
00175     configuration_item(const source_location &locn, level_t level,
00176         const rcstring &name);
00177 
00178 private:
00183     source_location locn;
00184 
00190     level_t level;
00191 
00196     rcstring name;
00197 };
00198 
00199 // vim: set ts=8 sw=4 et :
00200 #endif // LIB_CONFIGURATION_ITEM_H