Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 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 | |
Timo Tietavainen | a0745d2 | 2019-11-28 09:55:22 +0200 | [diff] [blame] | 17 | /* |
| 18 | * This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 19 | * platform project (RICP). |
| 20 | */ |
| 21 | |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 22 | #include "private/asyncdummystorage.hpp" |
| 23 | #include <sys/eventfd.h> |
| 24 | #include "private/engine.hpp" |
| 25 | |
| 26 | using namespace shareddatalayer; |
| 27 | |
| 28 | AsyncDummyStorage::AsyncDummyStorage(std::shared_ptr<Engine> engine): |
| 29 | engine(engine) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | int AsyncDummyStorage::fd() const |
| 34 | { |
| 35 | return engine->fd(); |
| 36 | } |
| 37 | |
| 38 | void AsyncDummyStorage::handleEvents() |
| 39 | { |
| 40 | engine->handleEvents(); |
| 41 | } |
| 42 | |
| 43 | void AsyncDummyStorage::postCallback(const Callback& callback) |
| 44 | { |
| 45 | engine->postCallback(callback); |
| 46 | } |
| 47 | |
| 48 | void AsyncDummyStorage::waitReadyAsync(const Namespace&, const ReadyAck& readyAck) |
| 49 | { |
| 50 | postCallback(std::bind(readyAck, std::error_code())); |
| 51 | } |
| 52 | |
| 53 | void AsyncDummyStorage::setAsync(const Namespace&, const DataMap&, const ModifyAck& modifyAck) |
| 54 | { |
| 55 | postCallback(std::bind(modifyAck, std::error_code())); |
| 56 | } |
| 57 | |
| 58 | void AsyncDummyStorage::setIfAsync(const Namespace&, const Key&, const Data&, const Data&, const ModifyIfAck& modifyIfAck) |
| 59 | { |
| 60 | postCallback(std::bind(modifyIfAck, std::error_code(), true)); |
| 61 | } |
| 62 | |
| 63 | void AsyncDummyStorage::setIfNotExistsAsync(const Namespace&, const Key&, const Data&, const ModifyIfAck& modifyIfAck) |
| 64 | { |
| 65 | postCallback(std::bind(modifyIfAck, std::error_code(), true)); |
| 66 | } |
| 67 | |
| 68 | void AsyncDummyStorage::getAsync(const Namespace&, const Keys&, const GetAck& getAck) |
| 69 | { |
| 70 | postCallback(std::bind(getAck, std::error_code(), DataMap())); |
| 71 | } |
| 72 | |
| 73 | void AsyncDummyStorage::removeAsync(const Namespace&, const Keys&, const ModifyAck& modifyAck) |
| 74 | { |
| 75 | postCallback(std::bind(modifyAck, std::error_code())); |
| 76 | } |
| 77 | |
| 78 | void AsyncDummyStorage::removeIfAsync(const Namespace&, const Key&, const Data&, const ModifyIfAck& modifyIfAck) |
| 79 | { |
| 80 | postCallback(std::bind(modifyIfAck, std::error_code(), true)); |
| 81 | } |
| 82 | |
| 83 | void AsyncDummyStorage::findKeysAsync(const Namespace&, const std::string&, const FindKeysAck& findKeysAck) |
| 84 | { |
| 85 | postCallback(std::bind(findKeysAck, std::error_code(), Keys())); |
| 86 | } |
| 87 | |
Petri Ovaska | 63869e1 | 2021-09-17 11:54:21 +0300 | [diff] [blame] | 88 | void AsyncDummyStorage::listKeys(const Namespace&, const std::string&, const FindKeysAck& findKeysAck) |
| 89 | { |
| 90 | postCallback(std::bind(findKeysAck, std::error_code(), Keys())); |
| 91 | } |
| 92 | |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 93 | void AsyncDummyStorage::removeAllAsync(const Namespace&, const ModifyAck& modifyAck) |
| 94 | { |
| 95 | postCallback(std::bind(modifyAck, std::error_code())); |
| 96 | } |