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