MLBookProc 1.3
Loading...
Searching...
No Matches
NotesKeeper.h
1/*
2 * Copyright (C) 2025 Yury Bobylev <bobilev_yury@mail.ru>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 3.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#ifndef NOTESKEEPER_H
17#define NOTESKEEPER_H
18
19#include <AuxFunc.h>
20#include <NotesBaseEntry.h>
21#include <mutex>
22
33{
34public:
39 NotesKeeper(const std::shared_ptr<AuxFunc> &af);
40
44 virtual ~NotesKeeper();
45
51 void
53
65 void
66 editNote(const NotesBaseEntry &nbe, const std::string &note);
67
79 getNote(const std::string &collection_name,
80 const std::filesystem::path &book_file_full_path,
81 const std::string &book_path);
82
93 std::string
95
102 std::string
104
119 void
121 const std::filesystem::path &reserve_directory,
122 const bool &make_reserve);
123
132 void
133 removeCollection(const std::string &collection_name,
134 const std::filesystem::path &reserve_directory,
135 const bool &make_reserve);
136
146 void
147 refreshCollection(const std::string &collection_name,
148 const std::filesystem::path &reserve_directory,
149 const bool &make_reserve);
150
156 std::vector<NotesBaseEntry>
157 getNotesForCollection(const std::string &collection_name);
158
159private:
160 void
161 parseRawBase(const std::string &raw_base);
162
163 void
164 parseEntry(const std::string &entry);
165
166 void
167 saveBase();
168
169 std::shared_ptr<AuxFunc> af;
170 std::filesystem::path base_directory_path;
171
172 std::vector<NotesBaseEntry> base;
173 std::mutex base_mtx;
174};
175
176#endif // NOTESKEEPER_H
The NotesBaseEntry class.
Definition NotesBaseEntry.h:28
void loadBase()
Loads notes base to memory.
NotesBaseEntry getNote(const std::string &collection_name, const std::filesystem::path &book_file_full_path, const std::string &book_path)
Gets NotesBaseEntry object from base or creats it.
void refreshCollection(const std::string &collection_name, const std::filesystem::path &reserve_directory, const bool &make_reserve)
Compares notes base and collection base and removes notes for absent books.
std::string readNoteText(const NotesBaseEntry &nbe)
Returns note text (if any).
std::string readNote(const NotesBaseEntry &nbe)
Returns content of note file.
void editNote(const NotesBaseEntry &nbe, const std::string &note)
Edits note.
virtual ~NotesKeeper()
NotesKeeper destructor.
void removeCollection(const std::string &collection_name, const std::filesystem::path &reserve_directory, const bool &make_reserve)
Removes notes for all books in particular collection.
std::vector< NotesBaseEntry > getNotesForCollection(const std::string &collection_name)
Returns all notes for particular collection.
void removeNotes(const NotesBaseEntry &nbe, const std::filesystem::path &reserve_directory, const bool &make_reserve)
Removes notes.
NotesKeeper(const std::shared_ptr< AuxFunc > &af)
NotesKeeper constructor.