Add extra line about src files are part of RIC platform project
[ric-plt/sdl.git] / include / private / asyncstorageimpl.hpp
1 /*
2    Copyright (c) 2018-2019 Nokia.
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    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 */
16
17 /*
18  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19  * platform project (RICP).
20 */
21
22 #ifndef SHAREDDATALAYER_REDIS_ASYNCSTORAGEIMPL_HPP_
23 #define SHAREDDATALAYER_REDIS_ASYNCSTORAGEIMPL_HPP_
24
25 #include <functional>
26 #include <sdl/asyncstorage.hpp>
27 #include <sdl/publisherid.hpp>
28 #include "private/configurationreader.hpp"
29 #include "private/databaseconfigurationimpl.hpp"
30 #include "private/logger.hpp"
31 #include "private/namespaceconfigurationsimpl.hpp"
32 #include "private/redis/asyncdatabasediscovery.hpp"
33
34 namespace shareddatalayer
35 {
36     class Engine;
37
38     class AsyncStorageImpl: public AsyncStorage
39     {
40     public:
41         using AsyncDatabaseDiscoveryCreator = std::function<std::shared_ptr<redis::AsyncDatabaseDiscovery>(std::shared_ptr<Engine> engine,
42                                                                                                            const DatabaseConfiguration& databaseConfiguration,
43                                                                                                            std::shared_ptr<Logger> logger)>;
44
45         AsyncStorageImpl(const AsyncStorageImpl&) = delete;
46
47         AsyncStorageImpl& operator = (const AsyncStorageImpl&) = delete;
48
49         AsyncStorageImpl(AsyncStorageImpl&&) = delete;
50
51         AsyncStorageImpl& operator = (AsyncStorageImpl&&) = delete;
52
53         AsyncStorageImpl(std::shared_ptr<Engine> engine,
54                          const boost::optional<PublisherId>& pId,
55                          std::shared_ptr<Logger> logger);
56
57         // Meant for UT
58         AsyncStorageImpl(std::shared_ptr<Engine> engine,
59                          const boost::optional<PublisherId>& pId,
60                          std::shared_ptr<DatabaseConfiguration> databaseConfiguration,
61                          std::shared_ptr<NamespaceConfigurations> namespaceConfigurations,
62                          std::shared_ptr<Logger> logger,
63                          const AsyncDatabaseDiscoveryCreator& asyncDatabaseDiscoveryCreator);
64
65         int fd() const override;
66
67         void handleEvents() override;
68
69         void waitReadyAsync(const Namespace& ns, const ReadyAck& readyAck) override;
70
71         void setAsync(const Namespace& ns, const DataMap& dataMap, const ModifyAck& modifyAck) override;
72
73         void setIfAsync(const Namespace& ns, const Key& key, const Data& oldData, const Data& newData, const ModifyIfAck& modifyIfAck) override;
74
75         void setIfNotExistsAsync(const Namespace& ns, const Key& key, const Data& data, const ModifyIfAck& modifyIfAck) override;
76
77         void getAsync(const Namespace& ns, const Keys& keys, const GetAck& getAck) override;
78
79         void removeAsync(const Namespace& ns, const Keys& keys, const ModifyAck& modifyAck) override;
80
81         void removeIfAsync(const Namespace& ns, const Key& key, const Data& data, const ModifyIfAck& modifyIfAck) override;
82
83         void findKeysAsync(const Namespace& ns, const std::string& keyPrefix, const FindKeysAck& findKeysAck) override;
84
85         void removeAllAsync(const Namespace& ns, const ModifyAck& modifyAck) override;
86
87         //public for UT
88         AsyncStorage& getOperationHandler(const std::string& ns);
89     private:
90         std::shared_ptr<Engine> engine;
91         std::shared_ptr<DatabaseConfiguration> databaseConfiguration;
92         std::shared_ptr<NamespaceConfigurations> namespaceConfigurations;
93         const boost::optional<PublisherId> publisherId;
94         std::shared_ptr<Logger> logger;
95         AsyncDatabaseDiscoveryCreator asyncDatabaseDiscoveryCreator;
96
97         AsyncStorage& getRedisHandler();
98         AsyncStorage& getDummyHandler();
99     };
100 }
101
102 #endif