MLBookProc 1.1
 
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
22#ifdef USE_OPENMP
23#include <omp.h>
24#else
25#include <mutex>
26#endif
27
38{
39public:
44 NotesKeeper(const std::shared_ptr<AuxFunc> &af);
45
49 virtual ~NotesKeeper();
50
56 void
58
70 void
71 editNote(const NotesBaseEntry &nbe, const std::string &note);
72
84 getNote(const std::string &collection_name,
85 const std::filesystem::path &book_file_full_path,
86 const std::string &book_path);
87
98 std::string
100
107 std::string
109
124 void
126 const std::filesystem::path &reserve_directory,
127 const bool &make_reserve);
128
137 void
138 removeCollection(const std::string &collection_name,
139 const std::filesystem::path &reserve_directory,
140 const bool &make_reserve);
141
151 void
152 refreshCollection(const std::string &collection_name,
153 const std::filesystem::path &reserve_directory,
154 const bool &make_reserve);
155
161 std::vector<NotesBaseEntry>
162 getNotesForCollection(const std::string &collection_name);
163
164private:
165 void
166 parseRawBase(const std::string &raw_base);
167
168 void
169 parseEntry(const std::string &entry);
170
171 void
172 saveBase();
173
174 std::shared_ptr<AuxFunc> af;
175 std::filesystem::path base_directory_path;
176
177 std::vector<NotesBaseEntry> base;
178#ifndef USE_OPENMP
179 std::mutex base_mtx;
180#else
181 omp_lock_t base_mtx;
182#endif
183};
184
185#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.