20 #include <boost/functional/hash.hpp> 42 :
data_(std::make_shared<SelectionData>(name))
52 data_->add_value(value, key, description);
74 boost::hash_combine(seed,
"Selection");
76 boost::hash_combine(seed,
data_->description_);
78 boost::hash_combine(seed, key.
key_);
80 boost::hash_combine(seed, key.
value);
93 return data_->closed_;
97 return data_->type_name_;
112 if (it !=
data_->key_to_index_.end())
113 return (
data_->keys_[it->second].value);
115 throw ExcSelectionKeyNotFound() << EI_KeyName(key) << EI_Selection(*
this);
121 auto it =
data_->value_to_index_.find(val);
122 if (
it !=
data_->value_to_index_.end())
123 return data_->keys_[
it->second].key_;
125 throw ExcSelectionValueNotFound() << EI_Value(val) << EI_Selection(*
this);
133 int value =
it->value;
134 while (
data_->value_to_index_.find(value) !=
data_->value_to_index_.end()) value++;
145 for(
unsigned int i=0; i<
size(); i++) os <<
"'" <<
data_->keys_[i].key_ <<
"' ";
153 return std::make_pair( std::make_shared<Selection>(*
this),
ParameterMap() );
160 ASSERT(key_to_index_.find(key_h) == key_to_index_.end())(key)(
type_name_).error(
"Key already exists in Selection.");
162 const std::string &existing_key = keys_[it->second].key_;
164 .error(
"Value of new key conflicts with value of existing key in Selection");
166 unsigned int new_idx = key_to_index_.size();
167 key_to_index_.insert(std::make_pair(key_h, new_idx));
168 value_to_index_.insert(std::make_pair(value, new_idx));
170 Key tmp_key = { new_idx, key, description, value };
171 keys_.push_back(tmp_key);
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
std::string type_name_(double)