From fe91611cb1c484429f2fdc958732337a5fc38fa8 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 14 Mar 2016 14:54:37 -0500 Subject: DataManager Updates The goal of this change is to make DataManager use InfoManager to reduce code duplication. Change-Id: Ia4f4c4324453a192995e0f442db0a03628c13e46 --- data.hpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'data.hpp') diff --git a/data.hpp b/data.hpp index 2ec217471..790efc993 100644 --- a/data.hpp +++ b/data.hpp @@ -20,9 +20,8 @@ #define _DATAMANAGER_HPP_HEADER #include -#include -#include #include +#include "infomanager.hpp" using namespace std; @@ -30,30 +29,30 @@ class DataManager { public: static int ResetDefaults(); - static int LoadValues(const string filename); + static int LoadValues(const string& filename); static int Flush(); // Core get routines - static int GetValue(const string varName, string& value); - static int GetValue(const string varName, int& value); - static int GetValue(const string varName, float& value); - static unsigned long long GetValue(const string varName, unsigned long long& value); + static int GetValue(const string& varName, string& value); + static int GetValue(const string& varName, int& value); + static int GetValue(const string& varName, float& value); + static unsigned long long GetValue(const string& varName, unsigned long long& value); // Helper functions - static string GetStrValue(const string varName); - static int GetIntValue(const string varName); + static string GetStrValue(const string& varName); + static int GetIntValue(const string& varName); // Core set routines - static int SetValue(const string varName, string value, int persist = 0); - static int SetValue(const string varName, int value, int persist = 0); - static int SetValue(const string varName, float value, int persist = 0); - static int SetValue(const string varName, unsigned long long value, int persist = 0); - static int SetProgress(float Fraction); - static int ShowProgress(float Portion, float Seconds); + static int SetValue(const string& varName, const string& value, const int persist = 0); + static int SetValue(const string& varName, const int value, const int persist = 0); + static int SetValue(const string& varName, const float value, const int persist = 0); + static int SetValue(const string& varName, const unsigned long long& value, const int persist = 0); + static int SetProgress(const float Fraction); + static int ShowProgress(const float Portion, const float Seconds); static void DumpValues(); static void update_tz_environment_variables(); - static void Vibrate(const string varName); + static void Vibrate(const string& varName); static void SetBackupFolder(); static void SetDefaultValues(); static void Output_Version(void); // Outputs the version to a file in the TWRP folder @@ -63,18 +62,18 @@ public: static string GetSettingsStoragePath(void); protected: - typedef pair TStrIntPair; - typedef pair TNameValuePair; - static map mValues; static string mBackingFile; static int mInitialized; + static InfoManager mPersist; + static InfoManager mData; + static InfoManager mConst; static map mConstValues; protected: static int SaveValues(); - static int GetMagicValue(string varName, string& value); + static int GetMagicValue(const string& varName, string& value); private: static void sanitize_device_id(char* device_id); -- cgit v1.2.3