15 #ifndef ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTREGISTRATIONMANAGER_H_ 16 #define ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTREGISTRATIONMANAGER_H_ 24 #include <unordered_map> 71 static std::unique_ptr<EndpointRegistrationManager>
create(
72 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> directiveSequencer,
73 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateInterface> capabilitiesDelegate,
83 std::future<RegistrationResult>
registerEndpoint(std::shared_ptr<EndpointInterface> endpoint)
override;
86 const std::shared_ptr<EndpointModificationData>& endpointModificationData)
override;
88 void addObserver(std::shared_ptr<EndpointRegistrationObserverInterface> observer)
override;
89 void removeObserver(
const std::shared_ptr<EndpointRegistrationObserverInterface>& observer)
override;
100 using PendingRegistration = std::pair<std::shared_ptr<EndpointInterface>, std::promise<RegistrationResult>>;
103 using PendingDeregistration = std::pair<std::shared_ptr<EndpointInterface>, std::promise<DeregistrationResult>>;
106 using PendingUpdate = std::pair<std::shared_ptr<EndpointInterface>, std::promise<UpdateResult>>;
121 addedOrUpdatedEndpoints,
123 deletedEndpoints)> callback);
127 void onCapabilitiesStateChange(
130 const std::vector<EndpointIdentifier>& addedOrUpdatedEndpointIds,
131 const std::vector<EndpointIdentifier>& deletedEndpointIds)
override;
137 addedOrUpdatedEndpoints,
151 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> directiveSequencer,
152 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateInterface> capabilitiesDelegate,
160 void executeRegisterEndpoint(
const std::shared_ptr<EndpointInterface>& endpoint);
168 void executeUpdateEndpoint(
169 const std::shared_ptr<EndpointInterface>& endpoint,
170 const std::shared_ptr<EndpointModificationData>& endpointModificationData);
177 void executeDeregisterEndpoint(
const std::shared_ptr<EndpointInterface>& endpoint);
186 bool addCapabilities(
187 const std::shared_ptr<EndpointInterface>& endpoint,
188 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>>* handlersAdded);
199 const std::shared_ptr<EndpointInterface>& endpoint,
202 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>> capability,
203 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>>* handlersAdded);
211 bool addCapabilities(
const std::shared_ptr<EndpointInterface>& endpoint);
220 bool removeCapabilities(
221 const std::shared_ptr<EndpointInterface>& endpoint,
222 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>>* handlersRemoved);
232 bool removeCapability(
233 const std::shared_ptr<EndpointInterface>& endpoint,
236 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>> capability,
237 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerInterface>>* handlersRemoved);
245 bool removeCapabilities(
const std::shared_ptr<EndpointInterface>& endpoint);
254 void updateAddedOrUpdatedEndpoints(
264 void removeDeletedEndpoints(
276 void onCapabilityRegistrationStatusChanged(
281 mutable std::mutex m_observersMutex;
284 std::list<std::shared_ptr<EndpointRegistrationObserverInterface>> m_observers;
287 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> m_directiveSequencer;
290 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateInterface> m_capabilitiesDelegate;
293 mutable std::mutex m_endpointsMutex;
296 std::unordered_map<EndpointIdentifier, std::shared_ptr<EndpointInterface>> m_endpoints;
299 std::unordered_map<EndpointIdentifier, PendingRegistration> m_pendingRegistrations;
302 std::unordered_map<EndpointIdentifier, PendingDeregistration> m_pendingDeregistrations;
305 std::unordered_map<EndpointIdentifier, PendingUpdate> m_pendingUpdates;
312 std::shared_ptr<CapabilityRegistrationProxy> m_capabilityRegistrationProxy;
321 #endif // ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTREGISTRATIONMANAGER_H_
std::future< RegistrationResult > registerEndpoint(std::shared_ptr< EndpointInterface > endpoint) override
Definition: EndpointRegistrationObserverInterface.h:30
void removeObserver(const std::shared_ptr< EndpointRegistrationObserverInterface > &observer) override
std::future< DeregistrationResult > deregisterEndpoint(const EndpointIdentifier &endpointId) override
Definition: EndpointRegistrationManager.h:45
Single-thread executor implementation.
Definition: Executor.h:45
Definition: RequiresShutdown.h:32
void doShutdown() override
Definition: CapabilitiesDelegateObserverInterface.h:29
void waitForPendingRegistrationsToEnqueue()
Definition: EndpointRegistrationManagerInterface.h:39
std::future< UpdateResult > updateEndpoint(const EndpointIdentifier &endpointId, const std::shared_ptr< EndpointModificationData > &endpointModificationData) override
Definition: EndpointModificationData.h:38
State
The enum State describes the state of the CapabilitiesDelegate.
Definition: CapabilitiesDelegateObserverInterface.h:32
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
Definition: CapabilityConfiguration.h:42
State
Definition: State.h:35
avsCommon::sdkInterfaces::endpoints::EndpointIdentifier EndpointIdentifier
Definition: EndpointRegistrationManager.h:51
~EndpointRegistrationManager()
void addObserver(std::shared_ptr< EndpointRegistrationObserverInterface > observer) override
Definition: EndpointInterface.h:38
static std::unique_ptr< EndpointRegistrationManager > create(std::shared_ptr< avsCommon::sdkInterfaces::DirectiveSequencerInterface > directiveSequencer, std::shared_ptr< avsCommon::sdkInterfaces::CapabilitiesDelegateInterface > capabilitiesDelegate, const EndpointIdentifier &defaultEndpointId)