-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserialize.hpp
57 lines (46 loc) · 1.32 KB
/
serialize.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <filesystem>
#include <fstream>
#include <set>
#include <string>
namespace phosphor
{
namespace led
{
namespace fs = std::filesystem;
// the set of names of asserted groups, which contains the D-Bus Object path
using SavedGroups = std::set<std::string>;
/** @class Serialize
* @brief Store and restore groups of LEDs
*/
class Serialize
{
public:
Serialize(const fs::path& path) : path(path)
{
restoreGroups();
}
/** @brief Store asserted group names to SAVED_GROUPS_FILE
*
* @param [in] group - name of the group
* @param [in] asserted - asserted state, true or false
*/
void storeGroups(const std::string& group, bool asserted);
/** @brief Is the group in asserted state stored in SAVED_GROUPS_FILE
*
* @param [in] objPath - The D-Bus path that hosts LED group
*
* @return - true: exist, false: does not exist
*/
bool getGroupSavedState(const std::string& objPath) const;
private:
/** @brief restore asserted group names from SAVED_GROUPS_FILE
*/
void restoreGroups();
/** @brief the set of names of asserted groups */
SavedGroups savedGroups;
/** @brief the path of file for storing the names of asserted groups */
fs::path path;
};
} // namespace led
} // namespace phosphor