34 enum class Item : std::size_t {
35 Oil, Gas, Water, ResV,
44 this->value_.fill(0.0);
47 constexpr bool has(
const Item p)
const
49 const auto i = this->index(p);
51 return (i < Size) && this->mask_[i];
56 return (this->mask_ == vec.mask_)
57 && (this->value_ == vec.value_);
60 double get(
const Item p)
const
63 throw std::invalid_argument {
64 "Request for Unset Item Value for " + this->itemName(p)
68 return this->value_[ this->index(p) ];
73 const auto i = this->index(p);
76 throw std::invalid_argument {
77 "Cannot Assign Item Value for Unsupported Item '"
78 + this->itemName(p) +
'\''
83 this->value_[i] = value;
90 for (
auto i = 0*Size; i < Size; ++i) {
93 this->value_[i] += rhs.value_[i];
100 template <
class MessageBufferType>
101 void write(MessageBufferType& buffer)
const
103 auto maskrep = this->mask_.to_ullong();
104 buffer.write(maskrep);
106 for (
const auto& x : this->value_) {
111 template <
class MessageBufferType>
112 void read(MessageBufferType& buffer)
120 this->mask_ = std::bitset<Size>(mask);
123 for (
auto& x : this->value_) {
129 for (
const auto& item : {Item::Oil, Item::Gas, Item::Water, Item::ResV}) {
131 json_data.add_item(this->itemName(item), this->get(item));
135 template<
class Serializer>
145 val.mask_ = std::bitset<Size>(1234);
146 val.value_ = {1,2,3,4};
152 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
154 std::bitset<Size> mask_{};
155 std::array<double, Size> value_{};
157 constexpr std::size_t index(
const Item p)
const noexcept
159 return static_cast<std::size_t
>(p);
162 std::string itemName(
const Item p)
const
165 case Item::Oil:
return "Oil";
166 case Item::Gas:
return "Gas";
167 case Item::Water:
return "Water";
168 case Item::ResV:
return "ResV";
171 return "Out of bounds (NumItems)";
174 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