AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
alexaClientSDK::acsdkAssets::manager::Requester Class Referenceabstract

#include <Requester.h>

Inheritance diagram for alexaClientSDK::acsdkAssets::manager::Requester:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::acsdkAssets::manager::Requester:
Collaboration graph
[legend]

Public Member Functions

virtual ~Requester ()
 
virtual bool download ()=0
 
size_t deleteAndCleanup ()
 
void handleUpdate (bool accept)
 
std::string name () const
 
const std::shared_ptr< commonInterfaces::ArtifactRequest > & getArtifactRequest () const
 
commonInterfaces::State getState () const
 
std::chrono::milliseconds getLastUsed () const
 
commonInterfaces::Priority getPriority () const
 
bool isDownloaded ()
 
std::string getArtifactPath ()
 
virtual void setPriority (commonInterfaces::Priority newPriority)
 
bool validateWriteRequest (const std::string &name, int newValue) override
 Override of the CommunicationPropertyValidatorInterface. More...
 
std::string functionToBeInvoked (const std::string &Name) override
 Override of the InvokeFunctionInterface. More...
 
- Public Member Functions inherited from alexaClientSDK::acsdkCommunicationInterfaces::CommunicationPropertyValidatorInterface< int >
virtual ~CommunicationPropertyValidatorInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::acsdkCommunicationInterfaces::FunctionInvokerInterface< std::string >
virtual ~FunctionInvokerInterface ()=default
 
virtual std::string functionToBeInvoked (const std::string &name, Types... args)=0
 

Static Public Attributes

static std::chrono::milliseconds START_TIME_OFFSET = milliseconds(0)
 

Protected Member Functions

 Requester (std::shared_ptr< StorageManager > storageManager, std::shared_ptr< commonInterfaces::AmdCommunicationInterface > communicationHandler, std::shared_ptr< RequesterMetadata > metadata, std::string metadataFilePath)
 
bool initializeFromStorage ()
 
bool registerCommunicationHandlerPropsLocked ()
 
void deregisterCommunicationHandlerPropsLocked (std::unique_lock< std::mutex > &lock)
 
void setStateLocked (commonInterfaces::State newState)
 
void updateLastUsedTimestampLocked ()
 
void notifyUpdateIsAvailableLocked (std::unique_lock< std::mutex > &lock)
 
bool handleAcquiredResourceLocked (std::unique_lock< std::mutex > &lock, const std::shared_ptr< Resource > &newResource)
 
void handleDownloadFailureLocked (std::unique_lock< std::mutex > &lock)
 
void handleUpdateLocked (std::unique_lock< std::mutex > &lock, bool accept)
 
virtual size_t deleteAndCleanupLocked (std::unique_lock< std::mutex > &lock)
 

Protected Attributes

const std::shared_ptr< StorageManagerm_storageManager
 
const std::shared_ptr< commonInterfaces::AmdCommunicationInterfacem_communicationHandler
 
const std::shared_ptr< RequesterMetadatam_metadata
 
const std::string m_metadataFilePath
 
std::unique_ptr< StorageManager::ReservationTokenm_storageReservationToken
 
std::shared_ptr< Resourcem_resource
 
std::shared_ptr< Resourcem_pendingUpdate
 
int m_updateNotificationsSent
 
alexaClientSDK::avsCommon::utils::timing::Timer m_timer
 
std::mutex m_eventMutex
 
bool m_communicationHandlerRegistered
 
friend RequesterFactory
 
std::shared_ptr< acsdkCommunicationInterfaces::CommunicationProperty< int > > m_stateProperty
 
std::shared_ptr< acsdkCommunicationInterfaces::CommunicationProperty< int > > m_priorityProperty
 
std::shared_ptr< acsdkCommunicationInterfaces::CommunicationProperty< std::string > > m_updateProperty
 

Detailed Description

This class represents an artifact as it exists on the system or as it is being downloaded. Given an artifact directory, it will maintain a metadata json file that will maintain its state and description on the same path. The artifact will be stored or unzipped inside this directory to handle its update and maintenance.

Constructor & Destructor Documentation

◆ ~Requester()

alexaClientSDK::acsdkAssets::manager::Requester::~Requester ( )
virtual

Ensures that the Communication Handler properties are all cleared away.

◆ Requester()

alexaClientSDK::acsdkAssets::manager::Requester::Requester ( std::shared_ptr< StorageManager storageManager,
std::shared_ptr< commonInterfaces::AmdCommunicationInterface communicationHandler,
std::shared_ptr< RequesterMetadata metadata,
std::string  metadataFilePath 
)
protected

Member Function Documentation

◆ deleteAndCleanup()

size_t alexaClientSDK::acsdkAssets::manager::Requester::deleteAndCleanup ( )
inline

Deletes the artifact and deregisters Communication Handler properties accordingly.

◆ deleteAndCleanupLocked()

size_t alexaClientSDK::acsdkAssets::manager::Requester::deleteAndCleanupLocked ( std::unique_lock< std::mutex > &  lock)
protectedvirtual

Deletes the artifact and deregisters from DAVS Client accordingly.

◆ deregisterCommunicationHandlerPropsLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::deregisterCommunicationHandlerPropsLocked ( std::unique_lock< std::mutex > &  lock)
protected

Deletes the artifact and deregisters communication properties accordingly.

◆ download()

virtual bool alexaClientSDK::acsdkAssets::manager::Requester::download ( )
pure virtual

Issues a download request if not already in progress.

Returns
true if the artifact is already downloaded or can download.

Implemented in alexaClientSDK::acsdkAssets::manager::UrlRequester, and alexaClientSDK::acsdkAssets::manager::DavsRequester.

◆ functionToBeInvoked()

string alexaClientSDK::acsdkAssets::manager::Requester::functionToBeInvoked ( const std::string &  Name)
override

Override of the InvokeFunctionInterface.

◆ getArtifactPath()

string alexaClientSDK::acsdkAssets::manager::Requester::getArtifactPath ( )

Returns the path where the artifact is stored and updates the last used timestamp if the path exists.

Returns
path of the artifact if exists, empty string otherwise.

◆ getArtifactRequest()

const std::shared_ptr<commonInterfaces::ArtifactRequest>& alexaClientSDK::acsdkAssets::manager::Requester::getArtifactRequest ( ) const
inline
Returns
original request which describes this artifact.

◆ getLastUsed()

std::chrono::milliseconds alexaClientSDK::acsdkAssets::manager::Requester::getLastUsed ( ) const
inline
Returns
last time the artifact was created or used.

◆ getPriority()

commonInterfaces::Priority alexaClientSDK::acsdkAssets::manager::Requester::getPriority ( ) const
inline
Returns
the current priority for this artifact.

◆ getState()

commonInterfaces::State alexaClientSDK::acsdkAssets::manager::Requester::getState ( ) const
inline
Returns
the current state for this artifact;

◆ handleAcquiredResourceLocked()

bool alexaClientSDK::acsdkAssets::manager::Requester::handleAcquiredResourceLocked ( std::unique_lock< std::mutex > &  lock,
const std::shared_ptr< Resource > &  newResource 
)
protected

◆ handleDownloadFailureLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::handleDownloadFailureLocked ( std::unique_lock< std::mutex > &  lock)
protected

◆ handleUpdate()

void alexaClientSDK::acsdkAssets::manager::Requester::handleUpdate ( bool  accept)

Handles pendingUpdate resource according to this function call.

Parameters
acceptthe pendingUpdate change or not. If accepted, release the old resource and set the new one. If rejected, then release the pendingUpdate.

◆ handleUpdateLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::handleUpdateLocked ( std::unique_lock< std::mutex > &  lock,
bool  accept 
)
protected

◆ initializeFromStorage()

bool alexaClientSDK::acsdkAssets::manager::Requester::initializeFromStorage ( )
protected

Attempts to fetch the resource from storage manager.

Returns
true if resource is available, false otherwise.

◆ isDownloaded()

bool alexaClientSDK::acsdkAssets::manager::Requester::isDownloaded ( )
inline
Returns
true if the artifact is downloaded on the system.

◆ name()

std::string alexaClientSDK::acsdkAssets::manager::Requester::name ( ) const
inline
Returns
name of this artifact based on the summary.

◆ notifyUpdateIsAvailableLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::notifyUpdateIsAvailableLocked ( std::unique_lock< std::mutex > &  lock)
protected

◆ registerCommunicationHandlerPropsLocked()

bool alexaClientSDK::acsdkAssets::manager::Requester::registerCommunicationHandlerPropsLocked ( )
protected

Registers the Communication Handler properties, if not already registered, for state, priority, and path.

Returns
true if the properties were registered successfully, false otherwise.

◆ setPriority()

void alexaClientSDK::acsdkAssets::manager::Requester::setPriority ( commonInterfaces::Priority  newPriority)
virtual

Sets the priority of this artifact to a new value.

◆ setStateLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::setStateLocked ( commonInterfaces::State  newState)
inlineprotected

Sets the existing state and informs the manager of the new state.

◆ updateLastUsedTimestampLocked()

void alexaClientSDK::acsdkAssets::manager::Requester::updateLastUsedTimestampLocked ( )
protected

Sets the last used timestamp to the current time.

◆ validateWriteRequest()

bool alexaClientSDK::acsdkAssets::manager::Requester::validateWriteRequest ( const std::string &  name,
int  newValue 
)
overridevirtual

Override of the CommunicationPropertyValidatorInterface.

Implements alexaClientSDK::acsdkCommunicationInterfaces::CommunicationPropertyValidatorInterface< int >.

Member Data Documentation

◆ m_communicationHandler

const std::shared_ptr<commonInterfaces::AmdCommunicationInterface> alexaClientSDK::acsdkAssets::manager::Requester::m_communicationHandler
protected

◆ m_communicationHandlerRegistered

bool alexaClientSDK::acsdkAssets::manager::Requester::m_communicationHandlerRegistered
protected

◆ m_eventMutex

std::mutex alexaClientSDK::acsdkAssets::manager::Requester::m_eventMutex
protected

◆ m_metadata

const std::shared_ptr<RequesterMetadata> alexaClientSDK::acsdkAssets::manager::Requester::m_metadata
protected

◆ m_metadataFilePath

const std::string alexaClientSDK::acsdkAssets::manager::Requester::m_metadataFilePath
protected

◆ m_pendingUpdate

std::shared_ptr<Resource> alexaClientSDK::acsdkAssets::manager::Requester::m_pendingUpdate
protected

◆ m_priorityProperty

std::shared_ptr<acsdkCommunicationInterfaces::CommunicationProperty<int> > alexaClientSDK::acsdkAssets::manager::Requester::m_priorityProperty
protected

◆ m_resource

std::shared_ptr<Resource> alexaClientSDK::acsdkAssets::manager::Requester::m_resource
protected

◆ m_stateProperty

std::shared_ptr<acsdkCommunicationInterfaces::CommunicationProperty<int> > alexaClientSDK::acsdkAssets::manager::Requester::m_stateProperty
protected

◆ m_storageManager

const std::shared_ptr<StorageManager> alexaClientSDK::acsdkAssets::manager::Requester::m_storageManager
protected

◆ m_storageReservationToken

std::unique_ptr<StorageManager::ReservationToken> alexaClientSDK::acsdkAssets::manager::Requester::m_storageReservationToken
protected

◆ m_timer

alexaClientSDK::avsCommon::utils::timing::Timer alexaClientSDK::acsdkAssets::manager::Requester::m_timer
protected

◆ m_updateNotificationsSent

int alexaClientSDK::acsdkAssets::manager::Requester::m_updateNotificationsSent
protected

◆ m_updateProperty

std::shared_ptr<acsdkCommunicationInterfaces::CommunicationProperty<std::string> > alexaClientSDK::acsdkAssets::manager::Requester::m_updateProperty
protected

◆ RequesterFactory

friend alexaClientSDK::acsdkAssets::manager::Requester::RequesterFactory
protected

◆ START_TIME_OFFSET

milliseconds alexaClientSDK::acsdkAssets::manager::Requester::START_TIME_OFFSET = milliseconds(0)
static

steady_clock starting offset based off of the previous artifact times.

Note
this is done to get around the issue with changing system_clock times and synchronizations.

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

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