Add first version
[ric-plt/sdl.git] / src / asyncstorage.cpp
diff --git a/src/asyncstorage.cpp b/src/asyncstorage.cpp
new file mode 100644 (file)
index 0000000..3b6fe77
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+   Copyright (c) 2018-2019 Nokia.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+
+#include <boost/optional.hpp>
+#include "config.h"
+#include "private/abort.hpp"
+#include "private/asyncconnection.hpp"
+#include "private/asyncstorageimpl.hpp"
+#include "private/createlogger.hpp"
+#include "private/engineimpl.hpp"
+#include "private/configurationreader.hpp"
+#include "private/databaseconfigurationimpl.hpp"
+#include "private/logger.hpp"
+#if HAVE_REDIS
+#include "private/redis/asyncredisstorage.hpp"
+#include "private/redis/asyncdatabasediscovery.hpp"
+#endif
+
+using namespace shareddatalayer;
+
+namespace
+{
+
+std::unique_ptr<shareddatalayer::AsyncStorage> createInstance(const boost::optional<shareddatalayer::AsyncConnection::PublisherId>& pId)
+{
+    auto engine(std::make_shared<EngineImpl>());
+    auto logger(createLogger(SDL_LOG_PREFIX));
+    /* clang compilation does not support make_unique */
+    return std::unique_ptr<AsyncStorageImpl>(new AsyncStorageImpl(engine, pId, logger));
+}
+
+}
+
+/* clang compilation produces undefined reference linker error without this */
+constexpr char AsyncStorage::SEPARATOR;
+
+std::unique_ptr<AsyncStorage> AsyncStorage::create()
+{
+    return createInstance(boost::none);
+}