33 enum class Item : std::size_t {
34 Oil, Gas, Water, ResV,
43 this->value_.fill(0.0);
46 constexpr bool has(
const Item p)
const
48 const auto i = this->index(p);
50 return (i < Size) && this->mask_[i];
55 return (this->mask_ == vec.mask_)
56 && (this->value_ == vec.value_);
59 double get(
const Item p)
const
62 throw std::invalid_argument {
63 "Request for Unset Item Value for " + this->itemName(p)
67 return this->value_[ this->index(p) ];
72 const auto i = this->index(p);
75 throw std::invalid_argument {
76 "Cannot Assign Item Value for Unsupported Item '"
77 + this->itemName(p) +
'\''
82 this->value_[i] = value;
89 for (
auto i = 0*Size; i < Size; ++i) {
92 this->value_[i] += rhs.value_[i];
99 template <
class MessageBufferType>
100 void write(MessageBufferType& buffer)
const
102 auto maskrep = this->mask_.to_ullong();
103 buffer.write(maskrep);
105 for (
const auto& x : this->value_) {
110 template <
class MessageBufferType>
111 void read(MessageBufferType& buffer)
119 this->mask_ = std::bitset<Size>(mask);
122 for (
auto& x : this->value_) {
127 template<
class Serializer>
137 val.mask_ = std::bitset<Size>(1234);
138 val.value_ = {1,2,3,4};
144 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
146 std::bitset<Size> mask_{};
147 std::array<double, Size> value_{};
149 constexpr std::size_t index(
const Item p)
const noexcept
151 return static_cast<std::size_t
>(p);
154 std::string itemName(
const Item p)
const
157 case Item::Oil:
return "Oil";
158 case Item::Gas:
return "Gas";
159 case Item::Water:
return "Water";
160 case Item::ResV:
return "ResV";
163 return "Out of bounds (NumItems)";
166 return "Unknown (" + std::to_string(this->index(p)) +
')';
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30