1 /*****************************************************************************\
3 * Name : configuration_list *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2001-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "configlet.h"
16 #include "configuration_list.h"
18 #include <basis/astring.h>
19 #include <structures/amorph.h>
23 using namespace basis;
24 using namespace structures;
26 namespace configuration {
28 class cl_figlet_list : public amorph<configlet> {};
32 configuration_list::configuration_list()
33 : _figs(new cl_figlet_list)
37 configuration_list::~configuration_list()
42 void configuration_list::reset() { _figs->reset(); }
44 void configuration_list::add(const configlet &new_item)
47 _figs->append(new_item.duplicate());
50 const configlet *configuration_list::find(const configlet &to_find) const
52 for (int i = 0; i < _figs->elements(); i++) {
53 configlet &curr = *_figs->borrow(i);
54 if ( (to_find.section() == curr.section())
55 && (to_find.entry() == curr.entry())
56 && (typeid(curr) == typeid(to_find)) ) {
63 bool configuration_list::zap(const configlet &dead_item)
65 for (int i = 0; i < _figs->elements(); i++) {
66 configlet &curr = *_figs->borrow(i);
67 if ( (dead_item.section() == curr.section())
68 && (dead_item.entry() == curr.entry()) ) {
76 bool configuration_list::load(configurator &config)
78 bool to_return = true;
79 for (int i = 0; i < _figs->elements(); i++) {
80 configlet &curr = *_figs->borrow(i);
81 if (!curr.load(config)) to_return = false; // any failure is bad.
86 bool configuration_list::store(configurator &config) const
88 bool to_return = true;
89 for (int i = 0; i < _figs->elements(); i++) {
90 configlet &curr = *_figs->borrow(i);
91 if (!curr.store(config)) to_return = false; // any failure is bad.