AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PostConnectSequencer.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 ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_POSTCONNECTSEQUENCER_H_
17 #define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_POSTCONNECTSEQUENCER_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <set>
22 #include <thread>
23 
28 
31 
32 namespace alexaClientSDK {
33 namespace acl {
34 
39  bool operator()(
40  const std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface>& first,
41  const std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface>& second) const {
42  return first->getOperationPriority() < second->getOperationPriority();
43  }
44 };
45 
50 public:
53  std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface>,
61  static std::shared_ptr<PostConnectSequencer> create(const PostConnectOperationsSet& postConnectOperations);
62 
66  ~PostConnectSequencer() override;
67 
70  bool doPostConnect(
71  std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> postConnectSender,
72  std::shared_ptr<PostConnectObserverInterface> postConnectObserver) override;
73  void onDisconnect() override;
75 private:
81  PostConnectSequencer(const PostConnectOperationsSet& postConnectOperations);
82 
90  void mainLoop(
91  std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> postConnectSender,
92  std::shared_ptr<PostConnectObserverInterface> postConnectObserver);
93 
99  void stop();
100 
104  void resetCurrentOperation();
105 
110  bool isStopping();
111 
113  std::mutex m_mutex;
114 
116  std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface> m_currentPostConnectOperation;
117 
119  bool m_isStopping;
120 
122  PostConnectOperationsSet m_postConnectOperations;
123 
125  std::mutex m_mainLoopThreadMutex;
126 
128  std::thread m_mainLoopThread;
129 
131  std::shared_ptr<avsCommon::utils::power::PowerResource> m_mainLoopPowerResource;
132 };
133 
134 } // namespace acl
135 } // namespace alexaClientSDK
136 
137 #endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_POSTCONNECTSEQUENCER_H_
bool operator()(const std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterface > &first, const std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterface > &second) const
Definition: PostConnectSequencer.h:39
Definition: PostConnectInterface.h:30
Definition: PostConnectSequencer.h:38
std::set< std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterface >, PostConnectOperationPriorityCompare > PostConnectOperationsSet
Alias for the custom post connect operations set where items are grouped based on operation priority...
Definition: PostConnectSequencer.h:54
set
Definition: gmock_class.py:44
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Definition: PostConnectSequencer.h:49

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