1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 12:42:11 +00:00
OpenMW/apps/opencs/model/prefs/category.cpp
2022-09-22 21:35:26 +03:00

54 lines
1.0 KiB
C++

#include "category.hpp"
#include <stdexcept>
#include "setting.hpp"
#include "state.hpp"
CSMPrefs::Category::Category(State* parent, const std::string& key)
: mParent(parent)
, mKey(key)
{
}
const std::string& CSMPrefs::Category::getKey() const
{
return mKey;
}
CSMPrefs::State* CSMPrefs::Category::getState() const
{
return mParent;
}
void CSMPrefs::Category::addSetting(Setting* setting)
{
mSettings.push_back(setting);
}
CSMPrefs::Category::Iterator CSMPrefs::Category::begin()
{
return mSettings.begin();
}
CSMPrefs::Category::Iterator CSMPrefs::Category::end()
{
return mSettings.end();
}
CSMPrefs::Setting& CSMPrefs::Category::operator[](const std::string& key)
{
for (Iterator iter = mSettings.begin(); iter != mSettings.end(); ++iter)
if ((*iter)->getKey() == key)
return **iter;
throw std::logic_error("Invalid user setting: " + key);
}
void CSMPrefs::Category::update()
{
for (Iterator iter = mSettings.begin(); iter != mSettings.end(); ++iter)
mParent->update(**iter);
}