AlexaClientSDK  1.23.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PowerResourceManagerInterface.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_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_POWERRESOURCEMANAGERINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_POWERRESOURCEMANAGERINTERFACE_H_
18 
19 #include <chrono>
20 #include <memory>
21 #include <ostream>
22 #include <string>
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace sdkInterfaces {
27 
38 public:
48  enum class PowerResourceLevel {
49  // A STANDBY level means hardware components are in standby mode, they are suitable
50  // for background activities.
51  // STANDBY_LOW usually means all the hardware components work in the lowest standby power levels
52  STANDBY_LOW = 0,
53  // STANDBY_MED usually means all the hardware components work in the medium standby power levels
55  // STANDBY_HIGH usually means all the hardware components work in the highest standby power levels
57  // An ACTIVE level means hardware components are in active mode, they are suitable
58  // for foreground activities.
59  // ACTIVE_LOW usually means all the hardware components work in the lowest active power levels
60  ACTIVE_LOW,
61  // ACTIVE_LOW usually means all the hardware components work in the medium active power levels
62  ACTIVE_MED,
63  // ACTIVE_HIGH usually means all the hardware components work in the highest active power levels
65  };
66 
70  virtual ~PowerResourceManagerInterface() = default;
71 
77  virtual void acquirePowerResource(
78  const std::string& component,
80 
85  virtual void releasePowerResource(const std::string& component) = 0;
86 
92  virtual bool isPowerResourceAcquired(const std::string& component) = 0;
93 
98  virtual std::chrono::milliseconds getTimeSinceLastResumeMS();
99 
112  public:
115  std::string getResourceId() const {
116  return m_resourceId;
117  }
119  PowerResourceId(const std::string& resourceId) : m_resourceId(resourceId) {
120  }
121 
122  private:
124  const std::string m_resourceId;
125  };
126 
134  virtual std::shared_ptr<PowerResourceId> create(
135  const std::string& resourceId,
136  bool isRefCounted = true,
138 
145  virtual bool acquire(
146  const std::shared_ptr<PowerResourceId>& id,
147  const std::chrono::milliseconds autoReleaseTimeout = std::chrono::milliseconds::zero()) = 0;
148 
154  virtual bool release(const std::shared_ptr<PowerResourceId>& id) = 0;
155 
161  virtual bool close(const std::shared_ptr<PowerResourceId>& id) = 0;
162 };
163 
170  return std::chrono::milliseconds(0);
171 }
172 
180  switch (level) {
182  return "STANDBY_LOW";
184  return "STANDBY_MED";
186  return "STANDBY_HIGH";
188  return "ACTIVE_LOW";
190  return "ACTIVE_MED";
192  return "ACTIVE_HIGH";
193  }
194 
195  return "UNKNOWN";
196 }
197 
206 inline std::ostream& operator<<(std::ostream& stream, PowerResourceManagerInterface::PowerResourceLevel level) {
207  return stream << powerResourceLevelToString(level);
208 }
209 
210 } // namespace sdkInterfaces
211 } // namespace avsCommon
212 } // namespace alexaClientSDK
213 
214 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_POWERRESOURCEMANAGERINTERFACE_H_
PowerResourceLevel
Definition: PowerResourceManagerInterface.h:48
virtual void acquirePowerResource(const std::string &component, const PowerResourceLevel level=PowerResourceLevel::STANDBY_MED)=0
std::ostream & operator<<(std::ostream &stream, const AudioInputProcessorObserverInterface::State &state)
Definition: AudioInputProcessorObserverInterface.h:86
virtual bool isPowerResourceAcquired(const std::string &component)=0
virtual void releasePowerResource(const std::string &component)=0
std::string powerResourceLevelToString(PowerResourceManagerInterface::PowerResourceLevel level)
Definition: PowerResourceManagerInterface.h:179
virtual std::shared_ptr< PowerResourceId > create(const std::string &resourceId, bool isRefCounted=true, const PowerResourceLevel level=PowerResourceLevel::STANDBY_MED)=0
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::string getResourceId() const
Definition: PowerResourceManagerInterface.h:115
virtual bool release(const std::shared_ptr< PowerResourceId > &id)=0
virtual bool close(const std::shared_ptr< PowerResourceId > &id)=0
PowerResourceId(const std::string &resourceId)
Constructor.
Definition: PowerResourceManagerInterface.h:119
virtual bool acquire(const std::shared_ptr< PowerResourceId > &id, const std::chrono::milliseconds autoReleaseTimeout=std::chrono::milliseconds::zero())=0
virtual std::chrono::milliseconds getTimeSinceLastResumeMS()
Definition: PowerResourceManagerInterface.h:169

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