AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
GenericInventory.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 ACSDKASSETMANAGERCLIENT_GENERICINVENTORY_H_
17 #define ACSDKASSETMANAGERCLIENT_GENERICINVENTORY_H_
18 
19 #include <set>
20 #include <unordered_map>
21 #include <unordered_set>
22 
25 
26 namespace alexaClientSDK {
27 namespace acsdkAssets {
28 namespace client {
29 
30 using Setting = std::set<std::string>;
31 using SettingsMap = std::unordered_map<std::string, Setting>;
32 
40  : public std::enable_shared_from_this<GenericInventory>
42 public:
43  ~GenericInventory() override;
44 
45  inline const char* getName() const {
46  return m_name.data();
47  }
48 
58  std::shared_ptr<clientInterfaces::ArtifactWrapperInterface> prepareForSettingChange(const SettingsMap& newSettings);
59 
67  bool commitChange();
68 
72  void cancelChange();
73 
78 
83 
87  bool isSettingReady(const SettingsMap& setting);
88 
89 protected:
97  std::string name,
98  std::shared_ptr<clientInterfaces::ArtifactWrapperFactoryInterface> artifactWrapperFactory);
99 
106  virtual std::shared_ptr<commonInterfaces::ArtifactRequest> createRequest(const SettingsMap& settings) = 0;
107 
114  virtual bool applyChangesLocked(const std::string& path) = 0;
115 
119  void cancelChangeLocked();
120 
122  inline bool validateUpdate(
123  const std::shared_ptr<commonInterfaces::ArtifactRequest>& request,
124  const std::string& newPath) override {
125  return m_activeArtifact != nullptr && m_activeArtifact->getRequest() == request && applyChangesLocked(newPath);
126  }
127 
128 private:
129  const std::string m_name;
130  const std::shared_ptr<clientInterfaces::ArtifactWrapperFactoryInterface> m_artifactWrapperFactory;
131 
132  std::shared_ptr<clientInterfaces::ArtifactWrapperInterface> m_activeArtifact;
133  std::shared_ptr<clientInterfaces::ArtifactWrapperInterface> m_pendingArtifact;
134 
135  std::mutex m_eventMutex;
136 };
137 
138 } // namespace client
139 } // namespace acsdkAssets
140 } // namespace alexaClientSDK
141 
142 #endif // ACSDKASSETMANAGERCLIENT_GENERICINVENTORY_H_
virtual std::shared_ptr< commonInterfaces::ArtifactRequest > createRequest(const SettingsMap &settings)=0
::std::string string
Definition: gtest-port.h:1097
bool validateUpdate(const std::shared_ptr< commonInterfaces::ArtifactRequest > &request, const std::string &newPath) override
Definition: GenericInventory.h:122
std::unordered_map< std::string, Setting > SettingsMap
Definition: GenericInventory.h:31
const char * getName() const
Definition: GenericInventory.h:45
bool isSettingReady(const SettingsMap &setting)
std::set< std::string > Setting
Definition: GenericInventory.h:30
void setCurrentActivePriority(commonInterfaces::Priority priority)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
GenericInventory(std::string name, std::shared_ptr< clientInterfaces::ArtifactWrapperFactoryInterface > artifactWrapperFactory)
std::shared_ptr< clientInterfaces::ArtifactWrapperInterface > prepareForSettingChange(const SettingsMap &newSettings)
virtual bool applyChangesLocked(const std::string &path)=0

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