AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
EndpointAlexaLauncherHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ACSDK_SAMPLE_ENDPOINT_ENDPOINTALEXALAUNCHERHANDLER_H_
17 #define ACSDK_SAMPLE_ENDPOINT_ENDPOINTALEXALAUNCHERHANDLER_H_
18 
19 #include <list>
20 #include <functional>
21 #include <memory>
22 #include <mutex>
23 #include <string>
24 #include <unordered_map>
25 
30 
31 namespace alexaClientSDK {
32 namespace sampleApplications {
33 namespace common {
34 
40 public:
42  using LaunchHandlerCallback = std::function<void(void)>;
43 
50  static std::shared_ptr<EndpointAlexaLauncherHandler> create(const std::string& endpointName);
51 
55  const acsdkAlexaLauncherInterfaces::TargetState& targetState) override;
57  bool addObserver(
58  const std::weak_ptr<acsdkAlexaLauncherInterfaces::AlexaLauncherObserverInterface>& observer) override;
59  void removeObserver(
60  const std::weak_ptr<acsdkAlexaLauncherInterfaces::AlexaLauncherObserverInterface>& observer) override;
62 
69  bool registerLaunchTargetCallback(const std::string& targetName, LaunchHandlerCallback callback);
70 
76  bool deregisterLaunchTargetCallback(const std::string& targetName);
77 
78 private:
81 
86  EndpointAlexaLauncherHandler(const std::string& endpointName);
87 
93  void notifyObservers(const acsdkAlexaLauncherInterfaces::TargetState& targetState);
94 
100  bool notifyTargetCallback(const std::string& targetName);
101 
103  std::mutex m_mutex;
104 
106  std::string m_endpointName;
107 
109  acsdkAlexaLauncherInterfaces::TargetState m_currentTargetState;
110 
112  std::unordered_map<std::string, LaunchHandlerCallback> m_launcherCallbacks;
113 
115  std::shared_ptr<AlexaLauncherNotifier> m_notifier;
116 };
117 
118 } // namespace common
119 } // namespace sampleApplications
120 } // namespace alexaClientSDK
121 
122 #endif // ACSDK_SAMPLE_ENDPOINT_ENDPOINTALEXALAUNCHERHANDLER_H_
bool registerLaunchTargetCallback(const std::string &targetName, LaunchHandlerCallback callback)
::std::string string
Definition: gtest-port.h:1097
acsdkAlexaLauncherInterfaces::AlexaLauncherInterface::Response launchTarget(const acsdkAlexaLauncherInterfaces::TargetState &targetState) override
bool addObserver(const std::weak_ptr< acsdkAlexaLauncherInterfaces::AlexaLauncherObserverInterface > &observer) override
Definition: AlexaLauncherTargetState.h:27
Generic implementation of NotifierInterface.
Definition: Notifier.h:38
static std::shared_ptr< EndpointAlexaLauncherHandler > create(const std::string &endpointName)
Definition: common.py:1
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
acsdkAlexaLauncherInterfaces::TargetState getLauncherTargetState() override
std::function< void(void)> LaunchHandlerCallback
Alias for a callback function for launching target.
Definition: EndpointAlexaLauncherHandler.h:42
void removeObserver(const std::weak_ptr< acsdkAlexaLauncherInterfaces::AlexaLauncherObserverInterface > &observer) override

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