• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_HDI_POWER_V1_1_RUNNINGLOCKCOUNTER_H
17 #define OHOS_HDI_POWER_V1_1_RUNNINGLOCKCOUNTER_H
18 
19 #include <cstdint>
20 #include <map>
21 
22 #include "v1_1/running_lock_types.h"
23 
24 namespace OHOS {
25 namespace HDI {
26 namespace Power {
27 namespace V1_1 {
28 class RunningLockCounter {
29 public:
RunningLockCounter(RunningLockType type,const std::string & tag)30     RunningLockCounter(RunningLockType type, const std::string &tag)
31         : type_(type), tag_(tag), counter_(0) {}
32     ~RunningLockCounter() = default;
33     int32_t Increase(const RunningLockInfo &info);
34     int32_t Decrease(const RunningLockInfo &info);
GetCount()35     uint32_t GetCount() const
36     {
37         return counter_;
38     }
GetType()39     RunningLockType GetType() const
40     {
41         return type_;
42     }
43 private:
44     const RunningLockType type_;
45     const std::string tag_;
46     uint32_t counter_;
47     std::map<std::string, RunningLockInfo> runninglockInfos_ {};
48 };
49 } // namespace V1_1
50 } // namespace Power
51 } // namespace HDI
52 } // namespace OHOS
53 
54 #endif // OHOS_HDI_POWER_V1_1_RUNNINGLOCKCOUNTER_H