Initial patch for RBC BIOS Config Manager

ResetBIOSSettings is not implemented as part of this patch apart from
that GetAttribute, SetAttribute and setters for BaseBIOSTable,
PendingAttributes is implemeted.

Interface:
xyz.openbmc_project.BIOSConfig.Manager
Properties:
.BaseBIOSTable                         property  a{s(sbsssvva(sv))} 1 "testAttributeName" "xyz.openbmc_pr... emits-change writable
.PendingAttributes                     property  a{s(sv)}           2 "test1" "xyz.openbmc_project.BIOSCo... emits-change writable
.ResetBIOSSettings                     property  s                  "xyz.openbmc_project.BIOSConfig.Manag... emits-change writable
Methods:
.GetAttribute                          method    s                  svv                                      -
.SetAttribute                          method    sv                 -                                        -

Tested:
1. Service is working well.
2. All the dbus methods and properties are shown correctly.
3. Unit test done.
    a). Tree
root@intel-obmc:~# busctl tree xyz.openbmc_project.BIOSConfigManager
`-/xyz
  `-/xyz/openbmc_project
    `-/xyz/openbmc_project/bios_config
      `-/xyz/openbmc_project/bios_config/manager
    b). Instrospect
root@intel-obmc:~# busctl introspect xyz.openbmc_project.BIOSConfigManager /xyz/openbmc_project/bios_config/manager
NAME                                   TYPE      SIGNATURE          RESULT/VALUE                             FLAGS
org.freedesktop.DBus.Introspectable    interface -                  -                                        -
.Introspect                            method    -                  s                                        -
org.freedesktop.DBus.Peer              interface -                  -                                        -
.GetMachineId                          method    -                  s                                        -
.Ping                                  method    -                  -                                        -
org.freedesktop.DBus.Properties        interface -                  -                                        -
.Get                                   method    ss                 v                                        -
.GetAll                                method    s                  a{sv}                                    -
.Set                                   method    ssv                -                                        -
.PropertiesChanged                     signal    sa{sv}as           -                                        -
xyz.openbmc_project.BIOSConfig.Manager interface -                  -                                        -
.GetAttribute                          method    s                  svv                                      -
.SetAttribute                          method    sv                 -                                        -
.BaseBIOSTable                         property  a{s(sbsssvva(sv))} 2 "attr0" "xyz.openbmc_project.BIOSCo... emits-change writable
.PendingAttributes                     property  a{s(sv)}           1 "test1" "xyz.openbmc_project.BIOSCo... emits-change writable
.ResetBIOSSettings                     property  s                  "xyz.openbmc_project.BIOSConfig.Manag... emits-change writable
    c). Method: GetAttribute/SetAttribute
root@intel-obmc:~# busctl call  xyz.openbmc_project.BIOSConfigManager /xyz/openbmc_project/bios_config/manager xyz.openbmc_project.BIOSConfig.Manager SetAttribute sv test1 s "value"
root@intel-obmc:~# busctl call  xyz.openbmc_project.BIOSConfigManager /xyz/openbmc_project/bios_config/manager xyz.openbmc_project.BIOSConfig.Manager GetAttribute s test1
svv "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String" x 0 s "value"
    d). Service
root@intel-obmc:~# systemctl status xyz.openbmc_project.biosconfig_manager
* xyz.openbmc_project.biosconfig_manager.service - BIOS Config Manager - For Remote BIOS configuration update
     Loaded: loaded (8;;file://intel-obmc/lib/systemd/system/xyz.openbmc_project.biosconfig_manager.service/lib/systemd/system/xyz.openbmc_project.biosconfig_manager.service8;;; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/xyz.openbmc_project.biosconfig_manager.service.d
             `-8;;file://intel-obmc/etc/systemd/system/xyz.openbmc_project.biosconfig_manager.service.d/watchdog.confwatchdog.conf8;;
     Active: active (running) since Thu 1970-01-01 00:00:56 UTC; 25min ago
   Main PID: 394 (biosconfig-mana)
     CGroup: /system.slice/xyz.openbmc_project.biosconfig_manager.service
             `-394 /usr/bin/biosconfig-manager

Jan 01 00:00:56 intel-obmc systemd[1]: Started BIOS Config Manager - For Remote BIOS configuration update.

Change-Id: I7a7312ffbdf000aab254c77ed5e4f9a8d4ec4d45
Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
diff --git a/include/manager.hpp b/include/manager.hpp
new file mode 100644
index 0000000..702e30f
--- /dev/null
+++ b/include/manager.hpp
@@ -0,0 +1,136 @@
+/*
+// Copyright (c) 2020 Intel Corporation
+//
+// 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.
+*/
+#pragma once
+
+#include <sdbusplus/asio/object_server.hpp>
+#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/BIOSConfig/Manager/server.hpp>
+
+#include <string>
+
+namespace bios_config
+{
+
+static constexpr auto service = "xyz.openbmc_project.BIOSConfigManager";
+static constexpr auto objectPath = "/xyz/openbmc_project/bios_config/manager";
+
+using Base = sdbusplus::xyz::openbmc_project::BIOSConfig::server::Manager;
+
+/** @class Manager
+ *
+ *  @brief Implements the BIOS Manager
+ */
+class Manager : public Base
+{
+  public:
+    using BaseTable = std::map<
+        std::string,
+        std::tuple<AttributeType, bool, std::string, std::string, std::string,
+                   std::variant<int64_t, std::string>,
+                   std::variant<int64_t, std::string>,
+                   std::vector<std::tuple<
+                       BoundType, std::variant<int64_t, std::string>>>>>;
+
+    using PendingAttributes =
+        std::map<std::string,
+                 std::tuple<AttributeType, std::variant<int64_t, std::string>>>;
+
+    using PendingAttribute =
+        std::tuple<AttributeType, std::variant<int64_t, std::string>>;
+
+    using AttributeName = std::string;
+    using AttributeValue = std::variant<int64_t, std::string>;
+    using CurrentValue = std::variant<int64_t, std::string>;
+    using PendingValue = std::variant<int64_t, std::string>;
+    using AttributeDetails =
+        std::tuple<AttributeType, CurrentValue, PendingValue>;
+
+    Manager() = delete;
+    ~Manager() = default;
+    Manager(const Manager&) = delete;
+    Manager& operator=(const Manager&) = delete;
+    Manager(Manager&&) = delete;
+    Manager& operator=(Manager&&) = delete;
+
+    /** @brief Constructs Manager object.
+     *
+     *  @param[in] objectServer  - object server
+     *  @param[in] systemBus - bus connection
+     */
+    Manager(sdbusplus::asio::object_server& objectServer,
+            std::shared_ptr<sdbusplus::asio::connection>& systemBus);
+
+    /** @brief Set the BIOS attribute with a new value, the new value is added
+     *         to the PendingAttribute.
+     *
+     *  @param[in] attribute - attribute name
+     *  @param[in] value - new value for the attribute
+     *
+     *  @return On error, throw exception
+     */
+    void setAttribute(AttributeName attribute, AttributeValue value) override;
+
+    /** @brief Get the details of the BIOS attribute
+     *
+     *  @param[in] attribute - attribute name
+     *
+     *  @return On success, return the attribute details: attribute type,
+     *          current value, pending value. On error, throw exception
+     */
+    AttributeDetails getAttribute(AttributeName attribute) override;
+
+    /** @brief Set the BaseBIOSTable property and clears the PendingAttributes
+     *         property
+     *
+     *  @param[in] value - new BaseBIOSTable
+     *
+     *  @return The new BaseBIOSTable that is applied.
+     */
+    BaseTable baseBIOSTable(BaseTable value) override;
+
+    /** @brief Set the PendingAttributes property, additionally checks if the
+     *         attributes are in the BaseBIOSTable, whether the attributes are
+     *         read only and validate the attribute value based on the
+     *         attribute type. PendingAttributes is cleared if value is empty.
+     *
+     *  @param[in] value - new PendingAttributes to append to the
+     *                     PendingAttributes property
+     *
+     *  @return On success, return the new PendingAttributes property that is
+     *          set.Throw exception if the validation fails.
+     */
+    PendingAttributes pendingAttributes(PendingAttributes value) override;
+
+  private:
+    /** @enum Index into the fields in the BaseBIOSTable
+     */
+    enum class Index : uint8_t
+    {
+        attributeType = 0,
+        readOnly,
+        displayName,
+        description,
+        menuPath,
+        currentValue,
+        defaultValue,
+        options,
+    };
+
+    sdbusplus::asio::object_server& objServer;
+    std::shared_ptr<sdbusplus::asio::connection>& systemBus;
+};
+
+} // namespace bios_config