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_STACK_PROPERTY_H
17 #define META_INTERFACE_STACK_PROPERTY_H
18 
19 #include <meta/base/bit_field.h>
20 #include <meta/base/interface_macros.h>
21 #include <meta/base/namespace.h>
22 #include <meta/base/types.h>
23 #include <meta/interface/intf_value.h>
24 #include <meta/interface/property/intf_modifier.h>
25 
26 META_BEGIN_NAMESPACE()
27 
28 META_REGISTER_INTERFACE(IStackProperty, "aa6ab1db-f971-49fd-a862-05fba1dc5761")
29 
30 class IStackProperty : public CORE_NS::IInterface {
31     META_INTERFACE(CORE_NS::IInterface, IStackProperty)
32 public:
33     // Value functions
34     virtual ReturnError PushValue(const IValue::Ptr& value) = 0;
35     virtual ReturnError PopValue() = 0;
36     virtual IValue::Ptr TopValue() const = 0;
37     virtual ReturnError RemoveValue(const IValue::Ptr& value) = 0;
38     virtual BASE_NS::vector<IValue::Ptr> GetValues(const BASE_NS::array_view<const TypeId>& ids, bool strict) const = 0;
39 
40     // Modifier functions
41     using IndexType = size_t;
42     virtual ReturnError InsertModifier(IndexType pos, const IModifier::Ptr& mod) = 0;
43     virtual IModifier::Ptr RemoveModifier(IndexType pos) = 0;
44     virtual ReturnError RemoveModifier(const IModifier::Ptr& mod) = 0;
45     virtual BASE_NS::vector<IModifier::Ptr> GetModifiers(
46         const BASE_NS::array_view<const TypeId>& ids, bool strict) const = 0;
47 
AddModifier(const IModifier::Ptr & mod)48     ReturnError AddModifier(const IModifier::Ptr& mod)
49     {
50         return InsertModifier(-1, mod);
51     }
52 
53     // Remove all values and modifiers from the stack
54     virtual void RemoveAll() = 0;
55 
56     // Default values
57     virtual AnyReturnValue SetDefaultValue(const IAny& value) = 0;
58     virtual const IAny& GetDefaultValue() const = 0;
59 };
60 
61 REGISTER_CLASS(StackProperty, "14366762-0c46-4225-8bfc-1240aba457c6", ObjectCategoryBits::NO_CATEGORY)
62 
63 META_END_NAMESPACE()
64 
65 #endif
66