MLBookProc 1.1
 
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)
 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.
 

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()

static 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 MLException in case of errors.
Parameters
collection_namecollection name.
afsmart pointer to AuxFunc object.
Returns
Absolute path to books directory.

◆ loadCollection()

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

Loads collection database to memory.

Note
This method can throw MLException in case of errors.
Parameters
col_namecollection name.

◆ searchBook()

std::vector< BookBaseEntry > BaseKeeper::searchBook ( const BookBaseEntry & search)

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.
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 conventional units to be processed.