1 /* 2 * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_PROPERTY_H 18 19 namespace OHOS::Ace::NG { 20 21 #define DEFINE_NEEDS_SETUP_FLAG_PROPERTY(name, defaultVal, changeFlag) \ 22 public: \ 23 bool Needs##name##Setup() const \ 24 { \ 25 return needs##name##Setup_; \ 26 } \ 27 void UpdateNeeds##name##Setup(const bool value) \ 28 { \ 29 needs##name##Setup_ = value; \ 30 if (value) { \ 31 UpdatePropertyChangeFlag(changeFlag); \ 32 } \ 33 } \ 34 bool CloneNeeds##name##Setup() const \ 35 { \ 36 return needs##name##Setup_; \ 37 } \ 38 private: \ 39 bool needs##name##Setup_ = (defaultVal) 40 41 #define DEFINE_NEEDS_SETUP_FLAG_TRIGGER_PROPERTY(name, type, trigger, changeFlag) \ 42 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(name, type, changeFlag) \ 43 public: \ 44 void On##name##Update(const type& value) \ 45 { \ 46 do { \ 47 UpdateNeeds##trigger##Setup(true); \ 48 } while (false); \ 49 } 50 } // namespace OHOS::Ace::NG 51 52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_PROPERTY_H