-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The persistent memory logic loop Signed-off-by: J. K. Edwards <joed6834@colorado.edu>
- Loading branch information
1 parent
911d2aa
commit 682ffd2
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef PMLL_H | ||
#define PMLL_H | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <mutex> | ||
|
||
class PMLL { | ||
private: | ||
std::unordered_map<std::string, std::string> memory; // Key-value memory store | ||
std::string memory_file; // File to store persistent memory | ||
std::mutex memory_mutex; // Thread safety | ||
|
||
void loadMemory(); // Load memory from the file | ||
void saveMemory(); // Save memory to the file | ||
|
||
public: | ||
PMLL(const std::string& file_name); // Constructor | ||
~PMLL(); // Destructor | ||
|
||
void addMemory(const std::string& key, const std::string& value); // Add or update memory | ||
std::string getMemory(const std::string& key) const; // Retrieve memory by key | ||
void clearMemory(); // Clear all memory | ||
void displayMemory() const; // Display all memory (debugging) | ||
}; | ||
|
||
#endif // PMLL_H |