9 #include <boost/functional/hash.hpp>
25 :
Scalar(other), data_(other.data_)
33 : data_(
boost::make_shared<SelectionData>(name))
43 xprintf(
PrgErr,
"Declaration of new name: %s in finished Selection type: %s\n", key.c_str(),
type_name().c_str());
45 data_->add_value(value, key, description);
60 boost::hash_combine(seed,
"Selection");
62 boost::hash_combine(seed,
data_->description_);
64 boost::hash_combine(seed, key.
key_);
66 boost::hash_combine(seed, key.
value);
75 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name() +
" with values: "+
key_list() ));
81 return data_->finished;
86 return data_->type_name_;
91 return data_->type_name_;
106 if (it !=
data_->key_to_index_.end())
107 return (
data_->keys_[it->second].value);
109 throw ExcSelectionKeyNotFound() << EI_KeyName(key) << EI_Selection(*
this);
115 auto it =
data_->value_to_index_.find(val);
116 if (
it !=
data_->value_to_index_.end())
117 return data_->keys_[
it->second].key_;
119 throw ExcSelectionValueNotFound() << EI_Value(val) << EI_Selection(*
this);
127 int value =
it->value;
128 while (
data_->value_to_index_.find(value) !=
data_->value_to_index_.end()) value++;
140 }
catch (ExcSelectionKeyNotFound &e) {
141 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name() +
" with values: "+
key_list() ));
149 for(
unsigned int i=0; i<
size(); i++) os <<
"'" <<
data_->keys_[i].key_ <<
"' ";
164 PrgErr,
"Value %d of new name '%s' conflicts with value %d of previous name '%s' in Selection: '%s'.\n", value, key.c_str(),
keys_[it->second].value,
keys_[it->second].key_.c_str(),
type_name_.c_str());
172 Key tmp_key = { new_idx, key, description, value };
173 keys_.push_back(tmp_key);
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.