Add first version
First version of C++ SDL API.
Refer README file for instructions how to generate API documentation.
Current version will find database via environment variables, thus RIC
DBaaS service must be up and running before starting the application
pod which uses SDL C++ API.
Change-Id: Ia3c95ac856b293827b680a9f6451a229f69f35f9
Signed-off-by: Rolf Badorek <rolf.badorek@nokia.com>
diff --git a/include/private/configurationreader.hpp b/include/private/configurationreader.hpp
new file mode 100644
index 0000000..6c175e7
--- /dev/null
+++ b/include/private/configurationreader.hpp
@@ -0,0 +1,76 @@
+/*
+ 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.
+*/
+
+#ifndef SHAREDDATALAYER_CONFIGURATIONREADER_HPP_
+#define SHAREDDATALAYER_CONFIGURATIONREADER_HPP_
+
+#define DB_HOST_ENV_VAR_NAME "DBAAS_SERVICE_HOST"
+#define DB_PORT_ENV_VAR_NAME "DBAAS_SERVICE_PORT"
+
+#include <iosfwd>
+#include <string>
+#include <unordered_map>
+#include <boost/property_tree/ptree.hpp>
+#include <sdl/exception.hpp>
+#include "private/configurationpaths.hpp"
+#include "private/logger.hpp"
+
+namespace shareddatalayer
+{
+ class DatabaseConfiguration;
+ class NamespaceConfigurations;
+ class System;
+
+ class ConfigurationReader
+ {
+ public:
+ explicit ConfigurationReader(std::shared_ptr<Logger> logger);
+
+ ConfigurationReader(const Directories& directories,
+ System& system,
+ std::shared_ptr<Logger> logger);
+
+ ~ConfigurationReader();
+
+ void readDatabaseConfiguration(DatabaseConfiguration& databaseConfiguration);
+
+ void readNamespaceConfigurations(NamespaceConfigurations& namespaceConfigurations);
+
+ /**
+ * Overrides existing json configuration with json format input stream given as
+ * parameter. Does not override existing configration if existing configration
+ * originates from environment variable. Meant for UT usage.
+ */
+ void readConfigurationFromInputStream(const std::istream& input);
+
+ private:
+ const std::string dbHostEnvVariableName;
+ std::string dbHostEnvVariableValue;
+ const std::string dbPortEnvVariableName;
+ std::string dbPortEnvVariableValue;
+ boost::optional<boost::property_tree::ptree> jsonDatabaseConfiguration;
+ std::string sourceForDatabaseConfiguration;
+ std::unordered_map<std::string, std::pair<boost::property_tree::ptree, std::string>> jsonNamespaceConfigurations;
+ std::shared_ptr<Logger> logger;
+
+ void readConfigurationFromDirectories(const Directories& directories);
+
+ template<typename T>
+ void readConfiguration(T& input, const std::string& sourceName);
+ };
+}
+
+#endif