Pass in the version purpose.

Since this will handle both the host and the bmc images,
need to be able to pass in the version purpose.

Change-Id: If09b3b81d9dc6166c61a4780ddaed7e1bdc021d0
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/version.cpp b/version.cpp
index 9c86756..4260a89 100644
--- a/version.cpp
+++ b/version.cpp
@@ -15,10 +15,11 @@
 
 using namespace phosphor::logging;
 
-std::string Version::getVersion(const std::string& manifestFilePath)
+std::string Version::getValue(const std::string& manifestFilePath,
+                              std::string key)
 {
-    constexpr auto versionKey = "version=";
-    constexpr auto versionKeySize = strlen(versionKey);
+    key = key + "=";
+    auto keySize = key.length();
 
     if (manifestFilePath.empty())
     {
@@ -26,7 +27,7 @@
         throw std::runtime_error("MANIFESTFilePath is empty");
     }
 
-    std::string version{};
+    std::string value{};
     std::ifstream efile;
     std::string line;
     efile.exceptions(std::ifstream::failbit
@@ -39,9 +40,9 @@
         efile.open(manifestFilePath);
         while (getline(efile, line))
         {
-            if (line.compare(0, versionKeySize, versionKey) == 0)
+            if (line.compare(0, keySize, key) == 0)
             {
-                version = line.substr(versionKeySize);
+                value = line.substr(keySize);
                 break;
             }
         }
@@ -49,10 +50,10 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Error in reading Host MANIFEST file");
+        log<level::ERR>("Error in reading MANIFEST file");
     }
 
-    return version;
+    return value;
 }
 
 std::string Version::getId(const std::string& version)
@@ -61,8 +62,8 @@
 
     if (version.empty())
     {
-        log<level::ERR>("Error Host version is empty");
-        throw std::runtime_error("Host version is empty");
+        log<level::ERR>("Error version is empty");
+        throw std::runtime_error("Version is empty");
     }
 
     // Only want 8 hex digits.
diff --git a/version.hpp b/version.hpp
index 6c45e0a..cd52fa0 100755
--- a/version.hpp
+++ b/version.hpp
@@ -23,16 +23,19 @@
     public:
         /** @brief Constructs Version Software Manager
          *
-         * @param[in] bus       - The Dbus bus object
-         * @param[in] objPath   - The Dbus object path
-         * @param[in] versionId - The Host version identifier
+         * @param[in] bus            - The Dbus bus object
+         * @param[in] objPath        - The Dbus object path
+         * @param[in] versionId      - The version identifier
+         * @param[in] versionPurpose - The version purpose
          */
         Version(sdbusplus::bus::bus& bus,
                 const std::string& objPath,
-                const std::string& versionId) : VersionInherit(
+                const std::string& versionId,
+                VersionPurpose versionPurpose) : VersionInherit(
                     bus, (objPath).c_str(), true)
         {
             // Set properties.
+            purpose(versionPurpose);
             version(versionId);
 
             // Emit deferred signal.
@@ -40,18 +43,20 @@
         }
 
         /**
-         * @brief Get the code version identifier.
+         * @brief Read the manifest file to get the value of the key.
          *
-         * @return The version identifier.
+         * @return The value of the key.
          **/
-        static std::string getVersion(const std::string& manifestFilePath);
+        static std::string getValue(const std::string& manifestFilePath,
+                                    std::string key);
 
         /**
-         * @brief Get the Host Version id.
+         * @brief Get the Version id.
          *
          * @return The id.
          **/
         static std::string getId(const std::string& version);
+
 };
 
 } // namespace manager