-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathtype_provider.h
More file actions
63 lines (54 loc) · 2.23 KB
/
Copy pathtype_provider.h
File metadata and controls
63 lines (54 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_CEL_CPP_BASE_TYPE_PROVIDER_H_
#define THIRD_PARTY_CEL_CPP_BASE_TYPE_PROVIDER_H_
#include "absl/base/attributes.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "base/handle.h"
#include "base/type.h"
namespace cel {
class TypeFactory;
// Interface for a TypeProvider, allowing host applications to inject
// functionality for operating on custom types in the CEL interpreter.
//
// Type providers are registered with a TypeRegistry. When resolving a type,
// the registry will check if it is a well known type, then check against each
// of the registered providers. If the type can't be resolved, the operation
// will result in an error.
//
// Type provider implementations must be effectively immutable and threadsafe.
// The type registry uses this property to aggressively cache results.
//
// Note: This API is not finalized. Consult the CEL team before introducing new
// implementations.
class TypeProvider {
public:
// Returns a TypeProvider which provides all of CEL's builtin types. It is
// thread safe.
ABSL_ATTRIBUTE_PURE_FUNCTION static TypeProvider& Builtin();
virtual ~TypeProvider() = default;
// Return a Handle handle to a Type for the fully qualified type name, if
// available.
//
// An empty handle is returned if the provider cannot find the requested type.
virtual absl::StatusOr<absl::optional<Handle<Type>>> ProvideType(
TypeFactory&, absl::string_view) const {
return absl::UnimplementedError("ProvideType is not yet implemented");
}
};
} // namespace cel
#endif // THIRD_PARTY_CEL_CPP_BASE_TYPE_PROVIDER_H_