AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::power::PowerMonitor Class Reference

#include <PowerMonitor.h>

Public Member Functions

void activate (std::shared_ptr< sdkInterfaces::PowerResourceManagerInterface > powerManager)
 
bool isActive ()
 
void deactivate ()
 
std::shared_ptr< sdkInterfaces::PowerResourceManagerInterfacegetPowerResourceManager ()
 
std::shared_ptr< PowerResourcegetThreadPowerResourceOrCreate (const std::string &identifier, sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel level=sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED)
 
std::shared_ptr< PowerResourcegetThreadPowerResource ()
 
std::shared_ptr< PowerResourceassignThreadPowerResource (std::shared_ptr< PowerResource > powerResource)
 
std::shared_ptr< PowerResourcecreateLocalPowerResource (const std::string &identifier, sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel level=sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED)
 
void removeThreadPowerResource ()
 

Static Public Member Functions

static std::shared_ptr< PowerMonitorgetInstance ()
 

Detailed Description

A class providing power monitoring capabilities for the SDK. To use this object, activate() must first be called.

This must be activated before any components are created that may have power management logic. For applications that wish to use any of the Power related primitives, this may mean calling activate() outside the SDK.

Member Function Documentation

◆ activate()

void alexaClientSDK::avsCommon::utils::power::PowerMonitor::activate ( std::shared_ptr< sdkInterfaces::PowerResourceManagerInterface powerManager)

Iniitalizes the PowerMonitor with a PowerResourceManagerInterface and activates.

Parameters
powerManagerA PowerResourceManagerInterface instance.

◆ assignThreadPowerResource()

std::shared_ptr<PowerResource> alexaClientSDK::avsCommon::utils::power::PowerMonitor::assignThreadPowerResource ( std::shared_ptr< PowerResource powerResource)

Assigns a previously created PowerResource to a thread. This will not affect the state of the PowerResource. If there is a previously assigned PowerResource this will fail.

Parameters
powerResourceThe PowerResource to assign.
Returns
The assigned PowerResource if successful, else a nullptr.

◆ createLocalPowerResource()

std::shared_ptr<PowerResource> alexaClientSDK::avsCommon::utils::power::PowerMonitor::createLocalPowerResource ( const std::string &  identifier,
sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel  level = sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED 
)

Convenience method for creating a local (non-thread associated) PowerResource using getPowerManager().

Parameters
Theidentifier to create the local PowerResource with.
levelThe PowerResourceLevel to use.
Returns
PowerResource.

◆ deactivate()

void alexaClientSDK::avsCommon::utils::power::PowerMonitor::deactivate ( )

Deactivate the PowerMonitor. This clears the internal map and resets the PowerManagerResourceMangerInterface instance.

Returns
a PowerManagerResourceMangerInterface instance.

◆ getInstance()

static std::shared_ptr<PowerMonitor> alexaClientSDK::avsCommon::utils::power::PowerMonitor::getInstance ( )
static

Returns an instance of PowerMonitor. This is guaranteed to be non-null.

Returns
The singleton instance of PowerMonitor.

◆ getPowerResourceManager()

std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> alexaClientSDK::avsCommon::utils::power::PowerMonitor::getPowerResourceManager ( )

Get the PowerResourceManagerInterface.

Returns
The PowerResourceManagerInterface.

◆ getThreadPowerResource()

std::shared_ptr<PowerResource> alexaClientSDK::avsCommon::utils::power::PowerMonitor::getThreadPowerResource ( )

Get the PowerResource associated with the current thread.

Returns
PowerResource associated with the current thread.

◆ getThreadPowerResourceOrCreate()

std::shared_ptr<PowerResource> alexaClientSDK::avsCommon::utils::power::PowerMonitor::getThreadPowerResourceOrCreate ( const std::string &  identifier,
sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel  level = sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED 
)

Gets the PowerResource associated with the current thread, or create one if none are associated. The same identifier must be used with a particular thread. The creator of the thread PowerResource is responsible for cleaning it up via removeThreadPowerResource(). This should typically be done when the thread exits.

Parameters
identifierThe identifier to create the thread PowerResource if none exists.
levelThe PowerResourceLevel to use on first creation. Otherwise this is ignored.
Returns
PowerResource associated with the current thread.

◆ isActive()

bool alexaClientSDK::avsCommon::utils::power::PowerMonitor::isActive ( )

Whether the PowerMonitor has been activated with an PowerResourceManagerInterface.

Returns
A bool indicating activation state.

◆ removeThreadPowerResource()

void alexaClientSDK::avsCommon::utils::power::PowerMonitor::removeThreadPowerResource ( )

Remove the current PowerResource associated with this thread.


The documentation for this class was generated from the following file:

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