AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PowerResource.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERRESOURCE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERRESOURCE_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <utility>
23 
25 
26 namespace alexaClientSDK {
27 namespace avsCommon {
28 namespace utils {
29 namespace power {
30 
38 public:
43 
47  static constexpr const char* PREFIX = "ACSDK_";
48 
61  static std::shared_ptr<PowerResource> create(
62  const std::string& identifier,
63  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> powerManager,
66  bool refCounted = true);
67 
73  std::string getId() const;
74 
80  bool isRefCounted() const;
81 
87  bool isFrozen() const;
88 
95 
99  void acquire();
100 
104  void release();
105 
110  void freeze();
111 
115  void thaw();
116 
117 private:
128  const std::string& identifier,
129  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> powerManager,
131  bool refCounted,
132  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface::PowerResourceId> powerResourceId);
133 
135  const std::string m_identifier;
136 
138  const bool m_isRefCounted;
139 
141  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface::PowerResourceId> m_powerResourceId;
142 
144  mutable std::mutex m_mutex;
145 
147  uint64_t m_refCount;
148 
151 
153  bool m_isFrozen;
154 
156  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> m_powerManager;
157 };
158 
159 } // namespace power
160 } // namespace utils
161 } // namespace avsCommon
162 } // namespace alexaClientSDK
163 
164 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERRESOURCE_H_
STANDBY_MED usually means all the hardware components work in the medium standby power levels...
PowerResourceLevel
Definition: PowerResourceManagerInterface.h:49
sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel getLevel() const
::std::string string
Definition: gtest-port.h:1097
static constexpr const char * PREFIX
Definition: PowerResource.h:47
static std::shared_ptr< PowerResource > create(const std::string &identifier, std::shared_ptr< sdkInterfaces::PowerResourceManagerInterface > powerManager, sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel level=sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED, bool refCounted=true)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0