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 NET_CAPS_H
17 #define NET_CAPS_H
18 
19 #include <set>
20 #include <string>
21 
22 #include "net_all_capabilities.h"
23 
24 namespace OHOS {
25 namespace NetManagerStandard {
26 class NetCaps {
27 public:
28     NetCaps() = default;
29     ~NetCaps() = default;
30     explicit NetCaps(const std::set<NetCap> &caps);
31 
32     bool operator==(const NetCaps &netCaps) const;
33 
34     /**
35      * Determine if a NetCap is valid or not
36      *
37      * @param cap NetCap to check
38      * @return bool cap is valid or not
39      */
40     bool IsValidNetCap(NetCap cap);
41 
42     /**
43      * Insert a NetCap
44      *
45      * @param cap A NetCap to insert
46      */
47     void InsertNetCap(NetCap cap);
48 
49     /**
50      * Remove a NetCap
51      *
52      * @param cap Netcap to remove
53      */
54     void RemoveNetCap(NetCap cap);
55 
56     /**
57      * Determine NetCap exist or not
58      *
59      * @param cap Netcap to check
60      * @return bool cap exist or not
61      */
62     bool HasNetCap(NetCap cap) const;
63 
64     /**
65      * Determine NetCaps exist or not
66      *
67      * @param cap Netcaps to check
68      * @return bool NetCaps exist or not
69      */
70     bool HasNetCaps(const std::set<NetCap> &caps) const;
71 
72     /**
73      * Restorage all Netcap to a std::set<NetCap>
74      *
75      * @return std::set<NetCap> with all Netcap
76      */
77     std::set<NetCap> ToSet() const;
78 
79 private:
80     uint32_t caps_{0};
81 };
82 } // namespace NetManagerStandard
83 } // namespace OHOS
84 #endif // NET_CAPS_H