1 /*
2  * Copyright (c) 2021-2022 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_BASED_COMPOSED_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASED_COMPOSED_COMPONENT_H
18 
19 #include <string>
20 
21 #include "core/pipeline/base/component.h"
22 
23 namespace OHOS::Ace {
24 
25 using ComposeId = std::string;
26 
27 // A component can compose others components.
28 class ACE_EXPORT BaseComposedComponent : public Component {
29     DECLARE_ACE_TYPE(BaseComposedComponent, Component);
30 
31 public:
BaseComposedComponent(const ComposeId & id,const std::string & name)32     BaseComposedComponent(const ComposeId& id, const std::string& name) : id_(id), name_(name) {}
33     ~BaseComposedComponent() override = default;
34 
GetName()35     const std::string& GetName() const
36     {
37         return name_;
38     }
39 
NeedUpdate()40     bool NeedUpdate() const
41     {
42         return needUpdate_;
43     }
44 
MarkNeedUpdate()45     void MarkNeedUpdate()
46     {
47         needUpdate_ = true;
48     }
49 
ClearNeedUpdate()50     void ClearNeedUpdate()
51     {
52         needUpdate_ = false;
53     }
54 
GetId()55     const ComposeId& GetId() const
56     {
57         return id_;
58     }
59 
60 protected:
61     ComposeId id_;
62 
63 private:
64     std::string name_;
65     bool needUpdate_ = false;
66 };
67 
68 } // namespace OHOS::Ace
69 
70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_COMPOSED_COMPONENT_H
71