• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef META_INTERFACE_IENUM_H
16 #define META_INTERFACE_IENUM_H
17 
18 #include <cstdint>
19 
20 #include <meta/interface/intf_info.h>
21 
22 META_BEGIN_NAMESPACE()
23 
24 enum class EnumType { SINGLE_VALUE, BIT_FIELD };
25 
26 struct EnumValue {
27     BASE_NS::string_view name; /// Name of the value
28     BASE_NS::string_view desc; /// Description of the value
29 };
30 
31 /**
32  * @brief Interface for enum like types
33  */
34 class IEnum : public IInfo {
35     META_INTERFACE(IInfo, IEnum, "bf116c56-a949-45d5-a12a-5394369861fb")
36 public:
37     /// Get which type of enum this is
38     virtual EnumType GetEnumType() const = 0;
39     /// Get array of the possible enum values
40     virtual BASE_NS::array_view<const EnumValue> GetValues() const = 0;
41     /// Get index of the current value, returns -1 for values not returned by GetValues (like bit fields)
42     virtual size_t GetValueIndex() const = 0;
43     /// Set current value based on the index
44     virtual bool SetValueIndex(size_t index) = 0;
45     /// Return true if the value with given index is set
46     virtual bool IsValueSet(size_t index) const = 0;
47     /// Set value (bit) in given index to on or off, works only for bit fields
48     virtual bool FlipValue(size_t index, bool isSet) = 0;
49 };
50 
51 META_END_NAMESPACE()
52 
53 #endif
54