xref: /haiku/src/kits/debugger/settings/generic/SettingsDescription.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "SettingsDescription.h"
8 
9 #include "Setting.h"
10 
11 
12 SettingsDescription::SettingsDescription()
13 {
14 }
15 
16 
17 SettingsDescription::~SettingsDescription()
18 {
19 	for (int32 i = 0; Setting* setting = SettingAt(i); i++)
20 		setting->ReleaseReference();
21 }
22 
23 
24 int32
25 SettingsDescription::CountSettings() const
26 {
27 	return fSettings.CountItems();
28 }
29 
30 
31 Setting*
32 SettingsDescription::SettingAt(int32 index) const
33 {
34 	return fSettings.ItemAt(index);
35 }
36 
37 
38 Setting*
39 SettingsDescription::SettingByID(const char* id) const
40 {
41 	for (int32 i = 0; Setting* setting = fSettings.ItemAt(i); i++) {
42 		if (strcmp(setting->ID(), id) == 0)
43 			return setting;
44 	}
45 
46 	return NULL;
47 }
48 
49 
50 bool
51 SettingsDescription::AddSetting(Setting* setting)
52 {
53 	if (!fSettings.AddItem(setting))
54 		return false;
55 
56 	setting->AcquireReference();
57 	return true;
58 }
59