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

The BaseKeeper class. More...

#include <BaseKeeper.h>

Public Member Functions

 BaseKeeper (const std::shared_ptr< AuxFunc > &af)
 BaseKeeper constructor.
virtual ~BaseKeeper ()
 BaseKeeper destructor.
void loadCollection (const std::string &col_name)
 Loads collection database to memory.
std::vector< BookBaseEntrysearchBook (const BookBaseEntry &search, const double &coef_coincedence=double(0.7))
 Searches book in collection.
std::vector< std::string > collectionAuthors ()
 Lists all authors, found in collection.
std::vector< BookBaseEntrybooksWithNotes (const std::vector< NotesBaseEntry > &notes)
 Lists all books of current collection, which have notes.
void stopSearch ()
 Stops all search operations.
void clearBase ()
 Unloads collection base from memory.
std::vector< FileParseEntryget_base_vector ()
 Returns copy of inner database vector.
size_t getBooksQuantity ()
 Returns total quantity of books in loaded collection.

Static Public Member Functions

static std::filesystem::path get_books_path (const std::string &collection_name, const std::shared_ptr< AuxFunc > &af)
 Returns absolute path to directory containing collection books.

Public Attributes

std::function< void(const double &progr, const double &sz)> auth_show_progr
 collectionAuthors() progress callback

Detailed Description

The BaseKeeper class.

This class is intended to keep and operate collections databases. loadCollection() method should be called first.

Constructor & Destructor Documentation

◆ BaseKeeper()

BaseKeeper::BaseKeeper ( const std::shared_ptr< AuxFunc > & af)

BaseKeeper constructor.

Parameters
afsmart pointer to AuxFunc object.

Member Function Documentation

◆ booksWithNotes()

std::vector< BookBaseEntry > BaseKeeper::booksWithNotes ( const std::vector< NotesBaseEntry > & notes)

Lists all books of current collection, which have notes.

Parameters
notesvector of notes (see NotesKeeper class documentation).
Returns
Vector of books with notes.

◆ collectionAuthors()

std::vector< std::string > BaseKeeper::collectionAuthors ( )

Lists all authors, found in collection.

Returns
Vector containing UTF-8 author's names strings.

◆ get_base_vector()

std::vector< FileParseEntry > BaseKeeper::get_base_vector ( )

Returns copy of inner database vector.

Returns
Database vector.

◆ get_books_path()

std::filesystem::path BaseKeeper::get_books_path ( const std::string & collection_name,
const std::shared_ptr< AuxFunc > & af )
static

Returns absolute path to directory containing collection books.

This method can be called without collection loading to memory.

Note
This method can throw std::exception in case of errors.
Parameters
collection_namecollection name.
afsmart pointer to AuxFunc object.
Returns
Absolute path to books directory.

◆ getBooksQuantity()

size_t BaseKeeper::getBooksQuantity ( )

Returns total quantity of books in loaded collection.

Note
If this method is called during collection loading, it will block calling thread execution until collection is loaded.
Returns
Total books quantity in loaded collection.

◆ loadCollection()

void BaseKeeper::loadCollection ( const std::string & col_name)

Loads collection database to memory.

Note
This method can throw std::exception in case of errors.
Parameters
col_namecollection name.

◆ searchBook()

std::vector< BookBaseEntry > BaseKeeper::searchBook ( const BookBaseEntry & search,
const double & coef_coincedence = double(0.7) )

Searches book in collection.

BookBaseEntry object must be provided as search request. It is necessary to fill in any field in the inner BookParseEntry object to receive particular result. Otherwise complete collection book list will be returned.

Parameters
searchBookBaseEntry object. If author search is needed bpe.book_author field must be in the following form: "Surname\7First Name\7Second name".
coef_coincedenceRequired coefficent of coincedence for search result. Allowed values are from 0.0 to 1.0. Default value is 0.7. If value is greater then 1.0, it means "exact match". In that case this method will return only results with the exact match for all search fields (empty search parameters are ignored).
Returns
Vector of BookBaseEntry objects, containing search results.

Member Data Documentation

◆ auth_show_progr

std::function<void(const double &progr, const double &sz)> BaseKeeper::auth_show_progr

collectionAuthors() progress callback

collectionAuthors() method execution can take some time. This callback indicates progress. progr is current progress in conventional units. sz is total quantity of conventional units to be processed.