1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 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 * http://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 16 #ifndef META_INTERFACE_PROPERTY_MODIFIER_H 17 #define META_INTERFACE_PROPERTY_MODIFIER_H 18 19 #include <meta/base/interface_macros.h> 20 #include <meta/base/namespace.h> 21 #include <meta/base/types.h> 22 #include <meta/interface/intf_function.h> 23 #include <meta/interface/property/intf_property.h> 24 25 META_BEGIN_NAMESPACE() 26 27 enum EvaluationResult : uint8_t { 28 EVAL_CONTINUE = 0, /// Continue evaluation of the stack 29 EVAL_ERROR = 1, /// Error happened 30 EVAL_RETURN = 2, /// Stop stack evaluation and return value 31 EVAL_VALUE_CHANGED = 4, /// This modifier changed the value 32 }; 33 34 inline EvaluationResult operator|(EvaluationResult l, EvaluationResult r) 35 { 36 return EvaluationResult(uint8_t(l) | uint8_t(r)); 37 } 38 39 META_REGISTER_INTERFACE(IModifier, "4a6991b7-c410-4663-99d2-4ff00eb9a9e0") 40 41 class IModifier : public CORE_NS::IInterface { 42 META_INTERFACE(CORE_NS::IInterface, IModifier) 43 public: 44 virtual EvaluationResult ProcessOnGet(IAny& value) = 0; 45 virtual EvaluationResult ProcessOnSet(IAny& value, const IAny& current) = 0; 46 virtual bool IsCompatible(const TypeId& id) const = 0; 47 }; 48 49 META_INTERFACE_TYPE(IModifier); 50 51 META_END_NAMESPACE() 52 53 #endif 54