diff --git a/include/library.h b/include/library.h index 795792b33..f1a58f6c5 100644 --- a/include/library.h +++ b/include/library.h @@ -183,6 +183,9 @@ class ConcurrentCache; template class MultiKeyCache; +using LibraryPtr = std::shared_ptr; +using ConstLibraryPtr = std::shared_ptr; + /** * A Library store several books. */ @@ -198,8 +201,8 @@ class Library: public std::enable_shared_from_this Library(); public: - [[nodiscard]] static std::shared_ptr create() { - return std::shared_ptr(new Library()); + [[nodiscard]] static LibraryPtr create() { + return LibraryPtr(new Library()); } ~Library(); @@ -405,6 +408,7 @@ private: //data std::unique_ptr m_bookDB; }; + } #endif diff --git a/include/manager.h b/include/manager.h index 9b13da39c..415db6224 100644 --- a/include/manager.h +++ b/include/manager.h @@ -37,10 +37,10 @@ namespace kiwix class LibraryManipulator { public: // functions - explicit LibraryManipulator(std::shared_ptr library); + explicit LibraryManipulator(LibraryPtr library); virtual ~LibraryManipulator(); - std::shared_ptr getLibrary() const { return library; } + LibraryPtr getLibrary() const { return library; } bool addBookToLibrary(const Book& book); void addBookmarkToLibrary(const Bookmark& bookmark); @@ -52,7 +52,7 @@ class LibraryManipulator virtual void booksWereRemovedFromLibrary(); private: // data - std::shared_ptr library; + LibraryPtr library; }; /** @@ -65,7 +65,7 @@ class Manager public: // functions explicit Manager(LibraryManipulator manipulator); - explicit Manager(std::shared_ptr library); + explicit Manager(LibraryPtr library); /** * Read a `library.xml` and add book in the file to the library. diff --git a/src/manager.cpp b/src/manager.cpp index 9a4f9b28c..ba4d0c75f 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -31,7 +31,7 @@ namespace kiwix // LibraryManipulator //////////////////////////////////////////////////////////////////////////////// -LibraryManipulator::LibraryManipulator(std::shared_ptr library) +LibraryManipulator::LibraryManipulator(LibraryPtr library) : library(library) {} @@ -85,7 +85,7 @@ Manager::Manager(LibraryManipulator manipulator): { } -Manager::Manager(std::shared_ptr library) : +Manager::Manager(LibraryPtr library) : writableLibraryPath(""), manipulator(LibraryManipulator(library)) { diff --git a/src/name_mapper.cpp b/src/name_mapper.cpp index f44227042..bf2a2e4dd 100644 --- a/src/name_mapper.cpp +++ b/src/name_mapper.cpp @@ -63,7 +63,7 @@ std::string HumanReadableNameMapper::getIdForName(const std::string& name) const // UpdatableNameMapper //////////////////////////////////////////////////////////////////////////////// -UpdatableNameMapper::UpdatableNameMapper(std::shared_ptr lib, bool withAlias) +UpdatableNameMapper::UpdatableNameMapper(LibraryPtr lib, bool withAlias) : library(lib) , withAlias(withAlias) { diff --git a/src/server.cpp b/src/server.cpp index 2e258245f..1a4ecfa9e 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -29,7 +29,7 @@ namespace kiwix { -Server::Server(std::shared_ptr library, std::shared_ptr nameMapper) : +Server::Server(LibraryPtr library, std::shared_ptr nameMapper) : mp_library(library), mp_nameMapper(nameMapper), mp_server(nullptr) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 11bdd0971..08d35e702 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -411,7 +411,7 @@ public: }; -InternalServer::InternalServer(std::shared_ptr library, +InternalServer::InternalServer(LibraryPtr library, std::shared_ptr nameMapper, std::string addr, int port, diff --git a/src/server/internalServer.h b/src/server/internalServer.h index e11c690b5..cdd7cebe2 100644 --- a/src/server/internalServer.h +++ b/src/server/internalServer.h @@ -92,7 +92,7 @@ class OPDSDumper; class InternalServer { public: - InternalServer(std::shared_ptr library, + InternalServer(LibraryPtr library, std::shared_ptr nameMapper, std::string addr, int port, @@ -178,7 +178,7 @@ class InternalServer { int m_ipConnectionLimit; struct MHD_Daemon* mp_daemon; - std::shared_ptr mp_library; + LibraryPtr mp_library; std::shared_ptr mp_nameMapper; SearchCache searchCache;