first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / configuration / configuration_list.h
1 #ifndef CONFIGURATION_LIST_CLASS
2 #define CONFIGURATION_LIST_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : configuration_list                                                *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 2001-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include <basis/contracts.h>
19
20 namespace configuration {
21
22 // forward.
23 class cl_figlet_list;
24 class configlet;
25 #include <configuration/configurator.h>
26
27 //! Manages a collection of configlet objects.
28 /*!
29   This class provides the ability to operate on the collection of configlets
30   as a whole.  They can be retrieved from or stored to a configurator object.
31 */
32
33 class configuration_list : public virtual basis::root_object
34 {
35 public:
36   configuration_list();
37   virtual ~configuration_list();
38
39   DEFINE_CLASS_NAME("configuration_list");
40
41   void reset();  //!< removes all items from the list.
42
43   void add(const configlet &new_item);
44     //!< adds another configuration atom into the list.
45
46   const configlet *find(const configlet &to_find) const;
47     //!< locates the actual configlet with the section and entry of "to_find".
48     /*!< note that this might fail if no matching section and entry are found,
49     thus returning NIL.  the returned object is still kept in the list, so
50     do not try to destroy it.  also note that the object passed in must be
51     the same type as the object to be found; otherwise, NIL will be
52     returned. */
53
54   bool zap(const configlet &dead_item);
55     //!< removes a previously added configuration item.
56     /*!< the "dead_item" need only provide the section and entry names. */
57
58   //! reads the values of all the configlets stored in "config" into this.
59   bool load(configurator &config);
60   //! writes the current values of all the configlets in "this" into "config".
61   bool store(configurator &config) const;
62
63 private:
64   cl_figlet_list *_figs;  //!< our list of configlets.
65 };
66
67 } //namespace.
68
69 #endif
70