1 /* 2 * Copyright (c) 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 NETMANAGER_BASE_TSTATSGETIFACESTATS_CONTEXT_H 17 #define NETMANAGER_BASE_TSTATSGETIFACESTATS_CONTEXT_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <string> 22 23 #include <napi/native_api.h> 24 25 #include "base_context.h" 26 #include "net_stats_info.h" 27 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class GetIfaceStatsContext final : public BaseContext { 31 public: 32 GetIfaceStatsContext() = delete; 33 explicit GetIfaceStatsContext(napi_env env, EventManager *manager); 34 35 void SetInterfaceName(std::string interfaceName); 36 void SetStatsInfo(NetStatsInfo statsInfo); 37 void SetStart(uint32_t start); 38 void SetEnd(uint32_t end); 39 std::string GetInterfaceName() const; 40 NetStatsInfo &GetStatsInfo(); 41 uint32_t GetStart() const; 42 uint32_t GetEnd() const; 43 44 void ParseParams(napi_value *params, size_t paramsCount); 45 46 private: 47 std::string interfaceName_; 48 NetStatsInfo statsInfo_; 49 uint32_t start_ = 0; 50 uint32_t end_ = 0; 51 52 private: 53 bool CheckParamsType(napi_value *params, size_t paramsCount); 54 }; 55 } // namespace NetManagerStandard 56 } // namespace OHOS 57 #endif // NETMANAGER_BASE_TSTATSGETIFACESTATS_CONTEXT_H 58