/proc/self/cwd/runtime/internal/runtime_friend_access.h
Line | Count | Source |
1 | | // Copyright 2023 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef THIRD_PARTY_CEL_CPP_RUNTIME_INTERNAL_RUNTIME_FRIEND_ACCESS_H_ |
16 | | #define THIRD_PARTY_CEL_CPP_RUNTIME_INTERNAL_RUNTIME_FRIEND_ACCESS_H_ |
17 | | |
18 | | #include "common/native_type.h" |
19 | | #include "runtime/runtime.h" |
20 | | #include "runtime/runtime_builder.h" |
21 | | |
22 | | namespace cel::runtime_internal { |
23 | | |
24 | | // Provide accessors for friend-visibility internal runtime details. |
25 | | // |
26 | | // CEL supported runtime extensions need implementation specific details to work |
27 | | // correctly. We restrict access to prevent external usages since we don't |
28 | | // guarantee stability on the implementation details. |
29 | | class RuntimeFriendAccess { |
30 | | public: |
31 | | // Access underlying runtime instance. |
32 | 0 | static Runtime& GetMutableRuntime(RuntimeBuilder& builder) { |
33 | 0 | return builder.runtime(); |
34 | 0 | } |
35 | | |
36 | | // Return the internal type_id for the runtime instance for checked down |
37 | | // casting. |
38 | 0 | static NativeTypeId RuntimeTypeId(Runtime& runtime) { |
39 | 0 | return runtime.GetNativeTypeId(); |
40 | 0 | } |
41 | | }; |
42 | | |
43 | | } // namespace cel::runtime_internal |
44 | | |
45 | | #endif // THIRD_PARTY_CEL_CPP_EXTENSIONS_RUNTIME_EXTENSIONS_FRIEND_ACCESS_H_ |