MLBookProc 2.1
Loading...
Searching...
No Matches
BaseKeeper Class Reference

The BaseKeeper class. More...

#include <BaseKeeper.h>

Inheritance diagram for BaseKeeper:
Collaboration diagram for BaseKeeper:

Public Member Functions

 BaseKeeper (const std::shared_ptr< MLBookProc > &mlbp)
 BaseKeeper constructor.
void loadCollection (const std::filesystem::path &base_path)
size_t getBooksQuantity ()
size_t getFilesQuantity ()
UDBase searchBook (const std::vector< UDBElement > &requests, const double &coef_coincedence)
void cancelSearch ()
std::string getCollectionType ()
std::filesystem::path getBooksDirectory ()
void editBookEntry (const UDBElement &book_search_result)
UDBase searchBooksWithNotes (const std::shared_ptr< NotesKeeper > &notes)
UDBase getAllFiles ()
UDBase listAllAuthors ()
void exportBase (const std::filesystem::path &result_path)
std::filesystem::path getCurrentCollectionBasePath ()
void unloadCollection ()

Static Public Member Functions

static UDBElement getBaseAnchorFileName (const std::filesystem::path &base_path)
static void importCollectionBase (const std::filesystem::path &source_base_path, const std::filesystem::path &coll_base_path, const std::filesystem::path &anchor_file)

Detailed Description

The BaseKeeper class.

This class keeps collection database and contains various methods to work with this database.

Constructor & Destructor Documentation

◆ BaseKeeper()

BaseKeeper::BaseKeeper ( const std::shared_ptr< MLBookProc > & mlbp)

BaseKeeper constructor.

Parameters
mlbpSmart pointer to MLBookProc object.

Member Function Documentation

◆ cancelSearch()

void BaseKeeper::cancelSearch ( )

Interrupts all search operations.

◆ editBookEntry()

void BaseKeeper::editBookEntry ( const UDBElement & book_search_result)

Edits book entry in database (book file or book file path will not be modified).

Parameters
book_search_resultUDBElement of BaseID::BookSearchResult type with edited values.

◆ exportBase()

void BaseKeeper::exportBase ( const std::filesystem::path & result_path)

Exports loaded collection database to file. This method should be used if you want share your collection database.

Note
This method can throw std::exception in case of errors.
Parameters
result_pathAbsolute path to file of result.

◆ getAllFiles()

UDBase BaseKeeper::getAllFiles ( )

Returns all collection files.

Note
This method can throw std::exception in case of errors.
Returns
UDBase object containing found BaseID::File objects.

◆ getBaseAnchorFileName()

UDBElement BaseKeeper::getBaseAnchorFileName ( const std::filesystem::path & base_path)
static

This method can be used to obtain anchor base path from file, obtained as a result of exportBase() method.

Parameters
base_pathPath to base file.
Returns
UDBElement of BaseID::AnchorBasePath or BaseID::Error types.

◆ getBooksDirectory()

std::filesystem::path BaseKeeper::getBooksDirectory ( )

Returns books directory. Valid only for 'inpx' and 'legacy' collections.

Note
This method can throw std::exception in case of errors.
Returns
Path to collection books directory.

◆ getBooksQuantity()

size_t BaseKeeper::getBooksQuantity ( )

Returns collection books quantity.

Returns
Books quantity.

◆ getCollectionType()

std::string BaseKeeper::getCollectionType ( )

Returns loaded collection type.

Note
This method can throw std::exception in case of errors.
Returns
UTF-8 collection type string. Possible values: 'native', 'inpx', 'legacy'.

◆ getCurrentCollectionBasePath()

std::filesystem::path BaseKeeper::getCurrentCollectionBasePath ( )

Returns loaded collection database file path.

Returns
Absolute path to loaded collection database file.

◆ getFilesQuantity()

size_t BaseKeeper::getFilesQuantity ( )

Returns collection files quantity.

Returns
Files quantity.

◆ importCollectionBase()

void BaseKeeper::importCollectionBase ( const std::filesystem::path & source_base_path,
const std::filesystem::path & coll_base_path,
const std::filesystem::path & anchor_file )
static

Imports collection database. Valid only for databases obtained by exportBase() method.

Note
This method can throw std::exception in case of errors.
Parameters
source_base_pathPath to base which should be imported.
coll_base_pathPath to base which should be created as a result.
anchor_fileAbsolute path to anchor file, obtained by getBaseAnchorFileName() method.

◆ listAllAuthors()

UDBase BaseKeeper::listAllAuthors ( )

Collects all loaded collection authors.

Returns
UDBase object containing BaseID::AuthorSearchResult objects.

◆ loadCollection()

void BaseKeeper::loadCollection ( const std::filesystem::path & base_path)

Loads collection database to memory.

Note
This method can throw std::exception in case of errors.
Parameters
base_pathPath to collection database file.

◆ searchBook()

UDBase BaseKeeper::searchBook ( const std::vector< UDBElement > & requests,
const double & coef_coincedence )

Searches books in loaded base.

requests vector can contain objects of following types: BaseID::Author, BaseID::BookTitle, BaseID::Sequence, BaseID::Genre.

Note
This method can throw std::exception in case of errors.
Parameters
requestsSearch parameters.
coef_coincedenceCoefficient of coincidence. Should be more than 0 and less than or equal to 1.0.
Returns
UDBase object, containing search results (BaseID::BookSearchResult type) and BaseID::CollectionInfo object.

◆ searchBooksWithNotes()

UDBase BaseKeeper::searchBooksWithNotes ( const std::shared_ptr< NotesKeeper > & notes)

Searches books with notes in loaded collection database.

Note
This method can throw std::exception in case of errors.
Parameters
notesSmart pointer to NotesKeeper object.
Returns
UDBase object containing BaseID::BookSearchResult objects and BaseID::CollectionInfo object.

◆ unloadCollection()

void BaseKeeper::unloadCollection ( )

Clears collection database.