19 #ifndef OPENXCOM_WEIGHTEDOPTIONS_H
20 #define OPENXCOM_WEIGHTEDOPTIONS_H
24 #include <yaml-cpp/yaml.h>
40 const std::string
choose()
const;
42 const std::string
top()
const;
44 void set(
const std::string &
id,
size_t weight);
46 bool empty()
const {
return 0 == _totalWeight; }
48 void clear() { _totalWeight = 0; _choices.clear(); }
50 void load(
const YAML::Node &node);
52 YAML::Node
save()
const;
54 std::map<std::string, size_t> _choices;
WeightedOptions()
Create an empty set.
Definition: WeightedOptions.h:38
void clear()
Remove all entries.
Definition: WeightedOptions.h:48
const std::string top() const
Select the top item.
Definition: WeightedOptions.cpp:55
bool empty() const
Is this empty?
Definition: WeightedOptions.h:46
const std::string choose() const
Select from among the items.
Definition: WeightedOptions.cpp:32
void set(const std::string &id, size_t weight)
Set an option's weight.
Definition: WeightedOptions.cpp:83
Holds pairs of relative weights and IDs.
Definition: WeightedOptions.h:34
YAML::Node save() const
Store our list in YAML.
Definition: WeightedOptions.cpp:126
void load(const YAML::Node &node)
Update our list with data from YAML.
Definition: WeightedOptions.cpp:112