blob: 24e85a605271dbe4e37b68fac9c2a41b4ac8f65d [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
17#include "private/asyncdummystorage.hpp"
18#include <sys/eventfd.h>
19#include "private/engine.hpp"
20
21using namespace shareddatalayer;
22
23AsyncDummyStorage::AsyncDummyStorage(std::shared_ptr<Engine> engine):
24 engine(engine)
25{
26}
27
28int AsyncDummyStorage::fd() const
29{
30 return engine->fd();
31}
32
33void AsyncDummyStorage::handleEvents()
34{
35 engine->handleEvents();
36}
37
38void AsyncDummyStorage::postCallback(const Callback& callback)
39{
40 engine->postCallback(callback);
41}
42
43void AsyncDummyStorage::waitReadyAsync(const Namespace&, const ReadyAck& readyAck)
44{
45 postCallback(std::bind(readyAck, std::error_code()));
46}
47
48void AsyncDummyStorage::setAsync(const Namespace&, const DataMap&, const ModifyAck& modifyAck)
49{
50 postCallback(std::bind(modifyAck, std::error_code()));
51}
52
53void AsyncDummyStorage::setIfAsync(const Namespace&, const Key&, const Data&, const Data&, const ModifyIfAck& modifyIfAck)
54{
55 postCallback(std::bind(modifyIfAck, std::error_code(), true));
56}
57
58void AsyncDummyStorage::setIfNotExistsAsync(const Namespace&, const Key&, const Data&, const ModifyIfAck& modifyIfAck)
59{
60 postCallback(std::bind(modifyIfAck, std::error_code(), true));
61}
62
63void AsyncDummyStorage::getAsync(const Namespace&, const Keys&, const GetAck& getAck)
64{
65 postCallback(std::bind(getAck, std::error_code(), DataMap()));
66}
67
68void AsyncDummyStorage::removeAsync(const Namespace&, const Keys&, const ModifyAck& modifyAck)
69{
70 postCallback(std::bind(modifyAck, std::error_code()));
71}
72
73void AsyncDummyStorage::removeIfAsync(const Namespace&, const Key&, const Data&, const ModifyIfAck& modifyIfAck)
74{
75 postCallback(std::bind(modifyIfAck, std::error_code(), true));
76}
77
78void AsyncDummyStorage::findKeysAsync(const Namespace&, const std::string&, const FindKeysAck& findKeysAck)
79{
80 postCallback(std::bind(findKeysAck, std::error_code(), Keys()));
81}
82
83void AsyncDummyStorage::removeAllAsync(const Namespace&, const ModifyAck& modifyAck)
84{
85 postCallback(std::bind(modifyAck, std::error_code()));
86}