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