Instance of Activation class is used by evaluator. It provides binding between references used in expressions and actual values.
| 28 | // It provides binding between references used in expressions |
| 29 | // and actual values. |
| 30 | class Activation : public BaseActivation { |
| 31 | public: |
| 32 | Activation() = default; |
| 33 | |
| 34 | // Non-copyable/non-assignable |
| 35 | Activation(const Activation&) = delete; |
| 36 | Activation& operator=(const Activation&) = delete; |
| 37 | |
| 38 | // Move-constructible/move-assignable |
| 39 | Activation(Activation&& other) = default; |
| 40 | Activation& operator=(Activation&& other) = default; |
| 41 | |
| 42 | // BaseActivation |
| 43 | std::vector<const CelFunction*> FindFunctionOverloads( |
| 44 | absl::string_view name) const override; |
| 45 | |
| 46 | absl::optional<CelValue> FindValue(absl::string_view name, |
| 47 | google::protobuf::Arena* arena) const override; |
| 48 | |
| 49 | // Insert a function into the activation (ie a lazily bound function). Returns |
| 50 | // a status if the name and shape of the function matches another one that has |
| 51 | // already been bound. |
| 52 | absl::Status InsertFunction(std::unique_ptr<CelFunction> function); |
| 53 | |
| 54 | // Insert value into Activation. |
| 55 | void InsertValue(absl::string_view name, const CelValue& value); |
| 56 | |
| 57 | // Insert ValueProducer into Activation. |
| 58 | void InsertValueProducer(absl::string_view name, |
| 59 | std::unique_ptr<CelValueProducer> value_producer); |
| 60 | |
| 61 | // Remove functions that have the same name and shape as descriptor. Returns |
| 62 | // true if matching functions were found and removed. |
| 63 | bool RemoveFunctionEntries(const CelFunctionDescriptor& descriptor); |
| 64 | |
| 65 | // Removes value or producer, returns true if entry with the name was found |
| 66 | bool RemoveValueEntry(absl::string_view name); |
| 67 | |
| 68 | // Clears a cached value for a value producer, returns if true if entry was |
| 69 | // found and cleared. |
| 70 | bool ClearValueEntry(absl::string_view name); |
| 71 | |
| 72 | // Clears all cached values for value producers. Returns the number of entries |
| 73 | // cleared. |
| 74 | int ClearCachedValues(); |
| 75 | |
| 76 | // Set missing attribute patterns for evaluation. |
| 77 | // |
| 78 | // If a field access is found to match any of the provided patterns, the |
| 79 | // result is treated as a missing attribute error. |
| 80 | void set_missing_attribute_patterns( |
| 81 | std::vector<CelAttributePattern> missing_attribute_patterns) { |
| 82 | missing_attribute_patterns_ = std::move(missing_attribute_patterns); |
| 83 | } |
| 84 | |
| 85 | const std::vector<CelAttributePattern>& missing_attribute_patterns() |
| 86 | const override { |
| 87 | return missing_attribute_patterns_; |
no outgoing calls