16 #ifndef ACSDK_APLCAPABILITYCOMMON_BASEAPLCAPABILITYAGENT_H_ 17 #define ACSDK_APLCAPABILITYCOMMON_BASEAPLCAPABILITYAGENT_H_ 24 #include <unordered_set> 47 namespace aplCapabilityCommon {
60 ,
public std::enable_shared_from_this<BaseAPLCapabilityAgent> {
75 std::shared_ptr<alexaClientSDK::avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
76 std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder,
77 std::shared_ptr<alexaClientSDK::avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
78 std::shared_ptr<alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
80 std::shared_ptr<alexaClientSDK::aplCapabilityCommonInterfaces::VisualStateProviderInterface>
81 visualStateProvider =
nullptr);
100 std::unordered_set<std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityConfiguration>>
114 unsigned int stateRequestToken)
override;
129 const bool markAsFailed =
true)
override;
161 void setExecutor(
const std::shared_ptr<alexaClientSDK::avsCommon::utils::threading::Executor>& executor);
195 ACTIVITY_RENDER_DOCUMENT,
198 ACTIVITY_RENDER_DOCUMENT_FAIL,
220 virtual std::unordered_set<std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityConfiguration>>
273 std::shared_ptr<alexaClientSDK::avsCommon::utils::threading::Executor>
getExecutor();
281 void removeDirective(std::shared_ptr<DirectiveInfo> info);
288 void handleRenderDocumentDirective(std::shared_ptr<DirectiveInfo> info);
295 void handleShowDocumentDirective(std::shared_ptr<DirectiveInfo> info);
302 void handleExecuteCommandDirective(std::shared_ptr<DirectiveInfo> info);
310 void handleDynamicListDataDirective(std::shared_ptr<DirectiveInfo> info,
const std::string& sourceType);
318 void executeExecuteCommand(std::shared_ptr<DirectiveInfo> info);
327 void executeDataSourceUpdate(std::shared_ptr<DirectiveInfo> info,
const std::string& sourceType);
335 void executeRenderDocument(
336 const std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> info);
346 void executeClearExecuteCommands(
349 const bool markAsFailed =
true);
363 void executeProvideState(
unsigned int stateRequestToken);
368 void executeProactiveStateReport();
379 void executeOnVisualContextAvailable(
387 void addPresentationSessionPayload(rapidjson::Document* document);
401 std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> m_lastDisplayedDirective;
406 std::pair<std::string, std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo>>
407 m_lastExecuteCommandTokenAndDirective;
411 std::shared_ptr<alexaClientSDK::avsCommon::sdkInterfaces::MessageSenderInterface> m_messageSender;
417 std::shared_ptr<alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface> m_contextManager;
420 std::shared_ptr<alexaClientSDK::aplCapabilityCommonInterfaces::VisualStateProviderInterface> m_visualStateProvider;
423 std::queue<std::tuple<std::string, std::string, std::string>> m_events;
442 void endMetricsEvent(
445 const std::chrono::steady_clock::time_point& timestamp);
455 std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
458 std::mutex m_MetricsRecorderMutex;
461 std::map<MetricEvent, std::chrono::steady_clock::time_point> m_currentActiveTimePoints;
467 std::chrono::time_point<std::chrono::steady_clock> m_lastReportTime;
470 std::chrono::milliseconds m_minStateReportInterval{};
473 std::chrono::milliseconds m_stateReportCheckInterval{};
476 bool m_stateReportPending;
482 bool m_documentRendered;
488 std::chrono::steady_clock::time_point m_renderReceivedTime;
497 std::shared_ptr<alexaClientSDK::avsCommon::utils::threading::Executor> m_executor;
503 #endif // ACSDK_APLCAPABILITYCOMMON_BASEAPLCAPABILITYAGENT_H_ const std::string & name() const
Definition: CapabilityAgent.h:47
Definition: APLEventPayload.h:137
virtual bool initialize()
Definition: APLEventPayload.h:86
void doShutdown() override
Directive indicates that index should be updated.
Definition: PresentationSession.h:40
DirectiveType
Concrete Implementation Facing Interfaces.
Definition: BaseAPLCapabilityAgent.h:166
Definition: CapabilityConfigurationInterface.h:32
Definition: BaseAPLCapabilityAgent.h:54
void processRenderDocumentResult(const aplCapabilityCommonInterfaces::PresentationToken &token, const bool result, const std::string &error) override
Definition: NamespaceAndName.h:32
Definition: APLEventPayload.h:178
::std::string string
Definition: gtest-port.h:1097
void preHandleDirective(std::shared_ptr< DirectiveInfo > info) override
Unknown directive received.
ContextRequestError
Definition: ContextRequesterInterface.h:40
void proactiveStateReport() override
unsigned int ContextRequestToken
Alias for the token used to identify a context request.
Definition: ContextRequestToken.h:23
Definition: RequiresShutdown.h:32
void sendRuntimeErrorEvent(const aplCapabilityCommonInterfaces::aplEventPayload::RuntimeError &errors) override
virtual alexaClientSDK::avsCommon::avs::DirectiveHandlerConfiguration getAPLDirectiveConfiguration() const =0
Template Methods to be implemented in Concrete Implementations.
Directive indicates that token should be updated.
void processExecuteCommandsResult(const aplCapabilityCommonInterfaces::PresentationToken &token, aplCapabilityCommonInterfaces::APLCommandExecutionEvent event, const std::string &error) override
void setHandlingCompleted(std::shared_ptr< DirectiveInfo > info)
void handleDirective(std::shared_ptr< DirectiveInfo > info) override
void handleUnknownDirective(std::shared_ptr< DirectiveInfo > info)
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
virtual DirectiveType getDirectiveType(std::shared_ptr< DirectiveInfo > info)=0
Directive contains an APL document to be rendered.
virtual std::unordered_set< std::shared_ptr< alexaClientSDK::avsCommon::avs::CapabilityConfiguration > > getAPLCapabilityConfigurations(const std::string &APLMaxVersion)=0
Generic implementation of NotifierInterface.
Definition: Notifier.h:38
std::string PresentationToken
Alias for the token used by APL directives.
Definition: PresentationToken.h:22
void provideState(const alexaClientSDK::avsCommon::avs::NamespaceAndName &stateProviderName, unsigned int stateRequestToken) override
void onActiveDocumentChanged(const aplCapabilityCommonInterfaces::PresentationToken &token, const alexaClientSDK::aplCapabilityCommonInterfaces::PresentationSession &session) override
void clearExecuteCommands(const aplCapabilityCommonInterfaces::PresentationToken &token=std::string(), const bool markAsFailed=true) override
void onContextFailure(const alexaClientSDK::avsCommon::sdkInterfaces::ContextRequestError error) override
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
void sendDataSourceFetchRequestEvent(const aplCapabilityCommonInterfaces::aplEventPayload::DataSourceFetch &fetchPayload) override
virtual const std::string & getConfigurationRootKey()=0
Timer to schedule task for delayed and periodic execution.
Definition: Timer.h:39
virtual ~BaseAPLCapabilityAgent()=default
MetricActivity
Enumeration of timer metric activity names that could be emitted.
Definition: BaseAPLCapabilityAgent.h:193
std::shared_ptr< alexaClientSDK::avsCommon::utils::threading::Executor > getExecutor()
std::string skillId
SkillId field name.
Definition: BaseAPLCapabilityAgent.h:206
Definition: APLCapabilityAgentInterface.h:35
void onContextAvailable(const std::string &jsonContext) override
Definition: BaseAPLCapabilityAgent.h:204
Directive contains one or multiple APL commands to be executed.
void onVisualContextAvailable(avsCommon::sdkInterfaces::ContextRequestToken requestToken, const aplCapabilityCommonInterfaces::aplEventPayload::VisualContext &context) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void cancelDirective(std::shared_ptr< DirectiveInfo > info) override
void recordRenderComplete(const std::chrono::steady_clock::time_point ×tamp) override
void sendUserEvent(const aplCapabilityCommonInterfaces::aplEventPayload::UserEvent &eventPayload) override
alexaClientSDK::avsCommon::avs::DirectiveHandlerConfiguration getConfiguration() const override
virtual const bool shouldPackPresentationSessionToAvsEvents()=0
std::unordered_set< std::shared_ptr< alexaClientSDK::avsCommon::avs::CapabilityConfiguration > > getCapabilityConfigurations() override
virtual const std::string & getMetricActivityName(MetricActivity activity)=0
Directive indicates that a previously received document should be now displayed.
virtual PresentationSessionFieldNames getPresentationSessionFieldNames()=0
void setExecutor(const std::shared_ptr< alexaClientSDK::avsCommon::utils::threading::Executor > &executor)
Tests Facing interfaces.
Definition: APLEventPayload.h:31
BaseAPLCapabilityAgent(const std::string &avsNamespace, std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionSender, std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder, std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, const std::string &APLMaxVersion, std::shared_ptr< alexaClientSDK::aplCapabilityCommonInterfaces::VisualStateProviderInterface > visualStateProvider=nullptr)
std::string presentationSessionId
Presentation session id field name.
Definition: BaseAPLCapabilityAgent.h:208
APLCommandExecutionEvent
Enumeration of APL Command Execution Events that can be reported to the APL capability agent...
Definition: APLCommandExecutionEvent.h:27
virtual const std::string & getMetricDataPointName(MetricEvent event)=0
void handleDirectiveImmediately(std::shared_ptr< alexaClientSDK::avsCommon::avs::AVSDirective > directive) override
MetricEvent
Enumeration of timer metrics events that could be emitted.
Definition: BaseAPLCapabilityAgent.h:187