| 103 | |
| 104 | private: |
| 105 | class ValueEntry { |
| 106 | public: |
| 107 | explicit ValueEntry(std::unique_ptr<CelValueProducer> prod) |
| 108 | : value_(), producer_(std::move(prod)) {} |
| 109 | |
| 110 | explicit ValueEntry(const CelValue& value) : value_(value), producer_() {} |
| 111 | |
| 112 | // Retrieve associated CelValue. |
| 113 | // If the value is not set and producer is set, |
| 114 | // obtain and cache value from producer. |
| 115 | absl::optional<CelValue> RetrieveValue(google::protobuf::Arena* arena) const { |
| 116 | if (!value_.has_value()) { |
| 117 | if (producer_) { |
| 118 | value_ = producer_->Produce(arena); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | return value_; |
| 123 | } |
| 124 | |
| 125 | bool ClearValue() { |
| 126 | bool result = value_.has_value(); |
| 127 | value_.reset(); |
| 128 | return result; |
| 129 | } |
| 130 | |
| 131 | bool HasProducer() const { return producer_ != nullptr; } |
| 132 | |
| 133 | private: |
| 134 | mutable absl::optional<CelValue> value_; |
| 135 | std::unique_ptr<CelValueProducer> producer_; |
| 136 | }; |
| 137 | |
| 138 | friend class cel::runtime_internal::ActivationAttributeMatcherAccess; |
| 139 |
no outgoing calls
no test coverage detected