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 SettingsDescription()12SettingsDescription::SettingsDescription() 13 { 14 } 15 16 ~SettingsDescription()17SettingsDescription::~SettingsDescription() 18 { 19 for (int32 i = 0; Setting* setting = SettingAt(i); i++) 20 setting->ReleaseReference(); 21 } 22 23 24 int32 CountSettings() const25SettingsDescription::CountSettings() const 26 { 27 return fSettings.CountItems(); 28 } 29 30 31 Setting* SettingAt(int32 index) const32SettingsDescription::SettingAt(int32 index) const 33 { 34 return fSettings.ItemAt(index); 35 } 36 37 38 Setting* SettingByID(const char * id) const39SettingsDescription::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 AddSetting(Setting * setting)51SettingsDescription::AddSetting(Setting* setting) 52 { 53 if (!fSettings.AddItem(setting)) 54 return false; 55 56 setting->AcquireReference(); 57 return true; 58 } 59