AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | List of all members
alexaClientSDK::acsdkManufactory::internal::CookBook Class Reference

#include <CookBook.h>

Public Member Functions

 CookBook ()
 
template<typename Type , typename... Dependencies>
CookBookaddUniqueFactory (std::function< std::unique_ptr< Type >(Dependencies...)> factory)
 
template<typename Type , typename... Dependencies>
CookBookaddUniqueFactory (std::unique_ptr< Type >(*factory)(Dependencies...))
 
template<typename Type , typename... Dependencies>
CookBookaddPrimaryFactory (std::function< std::shared_ptr< Type >(Dependencies...)> factory)
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddPrimaryFactory (std::function< Annotated< Annotation, Type >(Dependencies...)> factory)
 
template<typename Type , typename... Dependencies>
CookBookaddPrimaryFactory (std::shared_ptr< Type >(*factory)(Dependencies...))
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddPrimaryFactory (Annotated< Annotation, Type >(*factory)(Dependencies...))
 
template<typename Type , typename... Dependencies>
CookBookaddRequiredFactory (std::function< std::shared_ptr< Type >(Dependencies...)> factory)
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddRequiredFactory (std::function< Annotated< Annotation, Type >(Dependencies...)> factory)
 
template<typename Type , typename... Dependencies>
CookBookaddRequiredFactory (std::shared_ptr< Type >(*factory)(Dependencies...))
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddRequiredFactory (Annotated< Annotation, Type >(*factory)(Dependencies...))
 
template<typename Type , typename... Dependencies>
CookBookaddRetainedFactory (std::function< std::shared_ptr< Type >(Dependencies...)> factory)
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddRetainedFactory (std::function< Annotated< Annotation, Type >(Dependencies...)> factory)
 
template<typename Type , typename... Dependencies>
CookBookaddRetainedFactory (std::shared_ptr< Type >(*factory)(Dependencies...))
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddRetainedFactory (Annotated< Annotation, Type >(*factory)(Dependencies...))
 
template<typename Type , typename... Dependencies>
CookBookaddUnloadableFactory (std::function< std::shared_ptr< Type >(Dependencies...)> factory)
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddUnloadableFactory (std::function< Annotated< Annotation, Type >(Dependencies...)> factory)
 
template<typename Type , typename... Dependencies>
CookBookaddUnloadableFactory (std::shared_ptr< Type >(*factory)(Dependencies...))
 
template<typename Annotation , typename Type , typename... Dependencies>
CookBookaddUnloadableFactory (Annotated< Annotation, Type >(*factory)(Dependencies...))
 
template<typename Type >
CookBookaddInstance (const Type &instance)
 
CookBookaddCookBook (const CookBook &cookBook)
 
bool checkCompleteness ()
 
bool doRequiredGets (RuntimeManufactory &runtimeManufactory)
 
template<typename Type >
std::unique_ptr< Type > createUniquePointer (RuntimeManufactory &runtimeManufactory)
 
template<typename Type >
std::unique_ptr< AbstractPointerCachecreatePointerCache ()
 

Detailed Description

CookBook is a collection of recipes for creating instances.

Constructor & Destructor Documentation

◆ CookBook()

alexaClientSDK::acsdkManufactory::internal::CookBook::CookBook ( )
inline

Constructor.

Member Function Documentation

◆ addCookBook()

CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addCookBook ( const CookBook cookBook)
inline

Merge the contents of a CookBook into this CookBook.

If the incoming contents conflict (e.g. specifies a different factory for the same Type) this CookBook will be marked invalid and will fail all further operations.

Parameters
cookBookThe CookBook to merge into this CookBook.
Returns
This CookBook instance, merged with the contents of cookBook.

◆ addInstance()

template<typename Type >
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addInstance ( const Type &  instance)
inline

Declare support for providing instances of an type from an already existing instance. Such instances are assumed to be "retained" for the lifecycle of this CookBook.

Template Parameters
TypeThe type of interface supported.
Parameters
instanceThe instance to be served up.
Returns
This CookBook instance, with the added factory.

◆ addPrimaryFactory() [1/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addPrimaryFactory ( std::function< std::shared_ptr< Type >(Dependencies...)>  factory)
inline

Add a factory that returns a std::shared_ptr<> to a primary value (i.e. a value that must always be instantiated before all others). If multiple 'primary' factories are added, they will be instantiated in an arbitrary order - other than that required by any dependencies.

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addPrimaryFactory() [2/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addPrimaryFactory ( std::function< Annotated< Annotation, Type >(Dependencies...)>  factory)
inline

Add a factory that returns a Annotated<> pointer to a primary value (i.e. a value that must always be instantiated before all others). If multiple 'primary' factories are added, they will be instantiated in an arbitrary order - other than that required by any dependencies.

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addPrimaryFactory() [3/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addPrimaryFactory ( std::shared_ptr< Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a std::shared_ptr<> to a primary value (i.e. a value that must always be instantiated before all others). If multiple 'primary' factories are added, they will be instantiated in an arbitrary order - other than that required by any dependencies.

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addPrimaryFactory() [4/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addPrimaryFactory ( Annotated< Annotation, Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a Annotated<> pointer to a primary value (i.e. a value that must always be instantiated before all others). If multiple 'primary' factories are added, they will be instantiated in an arbitrary order - other than that required by any dependencies.

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRequiredFactory() [1/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRequiredFactory ( std::function< std::shared_ptr< Type >(Dependencies...)>  factory)
inline

Add a factory that returns a std::shared_ptr<> to a required value (i.e. a value that must always be instantiated).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRequiredFactory() [2/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRequiredFactory ( std::function< Annotated< Annotation, Type >(Dependencies...)>  factory)
inline

Add a factory that returns a Annotated<> pointer to a required value (i.e. a value that must always be instantiated).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRequiredFactory() [3/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRequiredFactory ( std::shared_ptr< Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a std::shared_ptr<> to a required value (i.e. a value that must always be instantiated).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRequiredFactory() [4/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRequiredFactory ( Annotated< Annotation, Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a Annotated<> pointer to a required value (i.e. a value that must always be instantiated).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRetainedFactory() [1/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRetainedFactory ( std::function< std::shared_ptr< Type >(Dependencies...)>  factory)
inline

Add a factory that returns a std::shared_ptr<> to a retained value (i.e. a value that must be retained once instantiated).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRetainedFactory() [2/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRetainedFactory ( std::function< Annotated< Annotation, Type >(Dependencies...)>  factory)
inline

Add a factory that returns a Annotated<> pointer to a retained value (i.e. a value that must be retained once instantiated).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRetainedFactory() [3/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRetainedFactory ( std::shared_ptr< Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a std::shared_ptr<> to a retained value (i.e. a value that must be retained once instantiated).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addRetainedFactory() [4/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addRetainedFactory ( Annotated< Annotation, Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a Annotated<> pointer to a retained value (i.e. a value that must be retained once instantiated).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUniqueFactory() [1/2]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUniqueFactory ( std::function< std::unique_ptr< Type >(Dependencies...)>  factory)
inline

Add a factory that returns a std::unique_ptr value.

Template Parameters
TypeThe full type (including std::unique_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUniqueFactory() [2/2]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUniqueFactory ( std::unique_ptr< Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a std::unique_ptr value.

Template Parameters
TypeThe full type (including std::unique_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUnloadableFactory() [1/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUnloadableFactory ( std::function< std::shared_ptr< Type >(Dependencies...)>  factory)
inline

Add a factory that returns a std::shared_ptr<> to an unloadable value (i.e. a value that may be released when no longer referenced).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUnloadableFactory() [2/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUnloadableFactory ( std::function< Annotated< Annotation, Type >(Dependencies...)>  factory)
inline

Add a factory that returns a Annotated<> pointer to an unloadable value (i.e. a value that may be released when no longer referenced).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUnloadableFactory() [3/4]

template<typename Type , typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUnloadableFactory ( std::shared_ptr< Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a std::shared_ptr<> to an unloadable value (i.e. a value that may be released when no longer referenced).

Template Parameters
TypeThe full type (including std::shared_ptr<>) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ addUnloadableFactory() [4/4]

template<typename Annotation , typename Type, typename... Dependencies>
CookBook & alexaClientSDK::acsdkManufactory::internal::CookBook::addUnloadableFactory ( Annotated< Annotation, Type >(*)(Dependencies...)  factory)
inline

Add a factory that returns a Annotated<> pointer to an unloadable value (i.e. a value that may be released when no longer referenced).

Template Parameters
AnnotationThe type used to differentiate the returned instance of Type.
TypeThe full type (including Annotated) returned by the factory.
DependenciesThe dependencies (arguments) of the factory to be added.
Parameters
factoryThe factory to be added.
Returns
This CookBook.

◆ checkCompleteness()

bool alexaClientSDK::acsdkManufactory::internal::CookBook::checkCompleteness ( )
inline

Verify that this CookBook instance is complete (all Imports are satisfied, there are no cyclic dependencies, and the the CookBook is otherwise valid). If this check fails, this CookBook will be marked invalid.

Returns
Whether this CookBook is valid.

◆ createPointerCache()

template<typename Type >
std::unique_ptr< AbstractPointerCache > alexaClientSDK::acsdkManufactory::internal::CookBook::createPointerCache ( )
inline

Create a PointerCache<Type> for the specified Type.

Template Parameters
TypeThe Type of object to be cached.
Returns
A new PointerCache<Type> instance.

◆ createUniquePointer()

template<typename Type >
std::unique_ptr< Type > alexaClientSDK::acsdkManufactory::internal::CookBook::createUniquePointer ( RuntimeManufactory runtimeManufactory)
inline

Create a new instance Type and return it via std::unique_ptr<>.

Template Parameters
TypeThe type of value to instantiate.
Parameters
runtimeManufactoryThe RuntimeManufactory to use to acquire dependencies of the new instance.
Returns
A std::unique_ptr<Type> to the new instance of Type.

createUniquePointer() returns a void* to a std::unique_ptr<Type> created on the heap. The following ensures that we retain the object, but delete the temporary std::unique_ptr pointed to by the void* before returning a std::unique_ptr to the object.

Cast the void* to a std::unique_ptr<Type>*.

Move the object from the underlying temporary std::unique_ptr on the heap. Now *temporaryPointerToUniquePointerOnHeap no longer owns the object.

Delete the temporary std::unique_ptr created on the heap. Without this, there is a memory leak.

◆ doRequiredGets()

bool alexaClientSDK::acsdkManufactory::internal::CookBook::doRequiredGets ( RuntimeManufactory runtimeManufactory)
inline

Perform get<Type>() for each Required<Type> registered with this CookBook.

Parameters
runtimeManufactoryThe RuntimeManufactory from which to retrieve the Required<Type>s and any of their dependencies.
Returns
Whether all get<Type>() operations were successful.

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

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