MLBookProc 1.0
 
Loading...
Searching...
No Matches
BookMarks.h
1/*
2 * Copyright (C) 2024-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
17#ifndef BOOKMARKS_H
18#define BOOKMARKS_H
19
20#include <AuxFunc.h>
21#include <BookBaseEntry.h>
22#include <memory>
23#include <vector>
24
25#ifdef USE_OPENMP
26#include <omp.h>
27#else
28#include <mutex>
29#endif
30
38{
39public:
44 BookMarks(const std::shared_ptr<AuxFunc> &af);
45
49 virtual ~BookMarks();
50
61 int
62 createBookMark(const std::string &col_name, const BookBaseEntry &bbe);
63
69 std::vector<std::tuple<std::string, BookBaseEntry>>
71
78 void
79 removeBookMark(const std::string &col_name, const BookBaseEntry &bbe);
80
81private:
82 void
83 loadBookMarks();
84
85 std::tuple<std::string, BookBaseEntry>
86 parse_entry(const std::string &buf);
87
88 // TODO remove legacy code in next releases
89 std::tuple<std::string, BookBaseEntry>
90 parse_entry_legacy(const std::string &buf);
91
92 bool
93 saveBookMarks();
94
95 std::string
96 form_entry(const std::string &col_name, const BookBaseEntry &bbe);
97
98 std::shared_ptr<AuxFunc> af;
99
100 std::filesystem::path bookmp;
101
102 std::vector<std::tuple<std::string, BookBaseEntry>> bookmarks;
103#ifndef USE_OPENMP
104 std::mutex bookmarksmtx;
105#else
106 omp_lock_t bookmarksmtx;
107#endif
108};
109
110#endif // BOOKMARKS_H
The BookBaseEntry class.
Definition BookBaseEntry.h:30
std::vector< std::tuple< std::string, BookBaseEntry > > getBookMarks()
Returns bookmarks.
virtual ~BookMarks()
BookMarks destructor.
int createBookMark(const std::string &col_name, const BookBaseEntry &bbe)
Creates bookmark.
BookMarks(const std::shared_ptr< AuxFunc > &af)
BookMarks constructor.
void removeBookMark(const std::string &col_name, const BookBaseEntry &bbe)
Removes bookmark.