Make the library creatable only within a shared_ptr.

This commit is contained in:
Matthieu Gautier
2023-09-18 17:16:12 +02:00
parent 49e99e7c22
commit c203e07ee9
5 changed files with 96 additions and 85 deletions

View File

@ -176,7 +176,7 @@ class ZimSearcher : public zim::Searcher
/**
* A Library store several books.
*/
class Library
class Library: public std::enable_shared_from_this<Library>
{
// all data fields must be added in LibraryBase
mutable std::mutex m_mutex;
@ -187,8 +187,13 @@ class Library
typedef std::map<std::string, int> AttributeCounts;
typedef std::set<std::string> BookIdSet;
public:
private:
Library();
public:
[[nodiscard]] static std::shared_ptr<Library> create() {
return std::shared_ptr<Library>(new Library());
}
~Library();
/**