AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Protected Attributes | List of all members
alexaClientSDK::acsdkManufactory::internal::AbstractRecipe Class Referenceabstract

#include <AbstractRecipe.h>

Collaboration diagram for alexaClientSDK::acsdkManufactory::internal::AbstractRecipe:
Collaboration graph
[legend]

Public Types

enum  RecipeType { FACTORY, FUNCTION, ADD_INSTANCE }
 
enum  CachedInstanceLifecycle {
  INSTANCE, PRIMARY, RETAINED, REQUIRED,
  UNIQUE, UNLOADABLE
}
 
using ProduceInstanceFunction = void *(*)(std::shared_ptr< AbstractRecipe > recipe, RuntimeManufactory &runtimeManufactory, void *cachedValue)
 
using DeleteInstanceFunction = void(*)(void *)
 

Public Member Functions

virtual ~AbstractRecipe ()=default
 
virtual bool isEquivalent (const std::shared_ptr< AbstractRecipe > &recipe) const =0
 
RecipeType getRecipeType () const
 
CachedInstanceLifecycle getLifecycle () const
 
ProduceInstanceFunction getProduceInstanceFunction () const
 
DeleteInstanceFunction getDeleteInstanceFunction () const
 
std::vector< avsCommon::utils::TypeIndex >::const_iterator begin () const
 
std::vector< avsCommon::utils::TypeIndex >::const_iterator end () const
 

Protected Attributes

std::vector< avsCommon::utils::TypeIndexm_dependencies
 Vector enumerating the dependencies of the interface this AbstractRecipe creates. More...
 
ProduceInstanceFunction m_produceFunction
 Function pointer that can produce an instance of this type. More...
 
DeleteInstanceFunction m_deleteFunction
 Function pointer that can delete a cached value of this type. More...
 
RecipeType m_recipeType
 The RecipeType of this recipe. More...
 
CachedInstanceLifecycle m_objectLifecycle
 The CachedInstanceLifecycle of a cached instance of this Type. More...
 

Detailed Description

The abstract class for 'recipes' for creating instances.

Member Typedef Documentation

◆ DeleteInstanceFunction

Alias for a function pointer that deletes an instance.

Parameters
void*The void* to the cached value, if it exists.

◆ ProduceInstanceFunction

using alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::ProduceInstanceFunction = void* (*)(std::shared_ptr<AbstractRecipe> recipe, RuntimeManufactory& runtimeManufactory, void* cachedValue)

Alias for a function pointer that produces an instance. Note that this function may not instantiate a new instance, depending on the lifecycle for the object and the cached value passed to this function.

Parameters
recipeThe AbstractRecipe that can provide the factory or std::function for this type of instance.
runtimeManufactoryThe runtime manufactory that can provide other required instances.
cachedValueThe previously cached instance, if it exists. For example, a type added as a retained factory may have a cached value; in that case, the cached value should be used instead of creating a new instance.
Returns
A void* to either a shared_ptr<Type> or unique_ptr<Type>. The caller is responsible for casting appropriately. Using void* is necessary so that recipes can be Type-unaware, reducing reliance on class templates.

Member Enumeration Documentation

◆ CachedInstanceLifecycle

The desired lifecycle for the instances cached in the manufactory. This is used for comparing equivalence between AbstractRecipes.

Enumerator
INSTANCE 

A recipe added by addInstance will cache the pre-made instance with a std::shared_ptr.

PRIMARY 

A recipe added by addPrimaryFactory will produce an object cached with a std::shared_ptr.

RETAINED 

A recipe added by addRetainedFactory will produce an object cached with a std::shared_ptr.

REQUIRED 

A recipe added by addRequiredFactory will produce an object cached with a std::shared_ptr.

UNIQUE 

A recipe added by addUniqueFactory will produce a new instance every time, and never cache them.

UNLOADABLE 

A recipe added by addUnloadableFactory will produce an object cached with a std::weak_ptr.

◆ RecipeType

The type of this AbstractRecipe. This is used for comparing equivalence between AbstractRecipes.

Enumerator
FACTORY 

A recipe whose means to produce the object is a function pointer.

FUNCTION 

A recipe whose means to produce the object is a std::function.

ADD_INSTANCE 

A recipe whose means to produce the object is a pre-made object.

Constructor & Destructor Documentation

◆ ~AbstractRecipe()

virtual alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::~AbstractRecipe ( )
virtualdefault

Destructor

Member Function Documentation

◆ begin()

std::vector< avsCommon::utils::TypeIndex >::const_iterator alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::begin ( ) const
inline

Get the start of a vector enumerating the dependencies of the interface this Recipe creates.

Returns
The start of a vector enumerating the dependencies of the interface this Recipe creates.

◆ end()

std::vector< avsCommon::utils::TypeIndex >::const_iterator alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::end ( ) const
inline

Get the end of a vector enumerating the dependencies of the interface this Recipe creates.

Returns
The end of a vector enumerating the dependencies of the interface this Recipe creates.

◆ getDeleteInstanceFunction()

AbstractRecipe::DeleteInstanceFunction alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::getDeleteInstanceFunction ( ) const
inline

Get the DeleteInstanceFunction for producing an instance of this type.

Returns
The DeleteInstanceFunction.

◆ getLifecycle()

AbstractRecipe::CachedInstanceLifecycle alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::getLifecycle ( ) const
inline

The object lifecycle of AbstractRecipe.

Returns
The type of this instance of AbstractRecipe.

◆ getProduceInstanceFunction()

AbstractRecipe::ProduceInstanceFunction alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::getProduceInstanceFunction ( ) const
inline

Get the ProduceInstanceFunction for producing an instance of this type.

Returns
The ProduceInstanceFunction.

◆ getRecipeType()

AbstractRecipe::RecipeType alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::getRecipeType ( ) const
inline

The type of this instance of AbstractRecipe.

Returns
The type of this instance of AbstractRecipe.

◆ isEquivalent()

virtual bool alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::isEquivalent ( const std::shared_ptr< AbstractRecipe > &  recipe) const
pure virtual

Is this instance of AbstractRecipe equivalent to the specified recipe.

Parameters
RecipeThe Recipe to compare with.
Returns
Whether this instance of AbstractRecipe equivalent to the specified recipe.

Member Data Documentation

◆ m_deleteFunction

DeleteInstanceFunction alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::m_deleteFunction
protected

Function pointer that can delete a cached value of this type.

◆ m_dependencies

std::vector<avsCommon::utils::TypeIndex> alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::m_dependencies
protected

Vector enumerating the dependencies of the interface this AbstractRecipe creates.

◆ m_objectLifecycle

CachedInstanceLifecycle alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::m_objectLifecycle
protected

The CachedInstanceLifecycle of a cached instance of this Type.

◆ m_produceFunction

ProduceInstanceFunction alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::m_produceFunction
protected

Function pointer that can produce an instance of this type.

◆ m_recipeType

RecipeType alexaClientSDK::acsdkManufactory::internal::AbstractRecipe::m_recipeType
protected

The RecipeType of this recipe.


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