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

The RefreshCollection class. More...

#include <RefreshCollection.h>

Inheritance diagram for RefreshCollection:
Collaboration diagram for RefreshCollection:

Public Member Functions

 RefreshCollection (const std::shared_ptr< MLBookProc > &mlbp, const int &threads_num=int(1))
 RefreshCollection constructor.
void refreshCollection (const std::filesystem::path &base_path, const bool &fast_refresh=bool(true))
void addFilesAndDirs (const std::filesystem::path &base_path, const std::vector< std::filesystem::path > &files_and_dirs)
void stopAll () override
Public Member Functions inherited from CreateCollection
 CreateCollection (const std::shared_ptr< MLBookProc > &mlbp, const int &threads_num=int(1))
 CreateCollection constructor.
void createCollection (const std::vector< std::filesystem::path > &files_and_dirs, const std::filesystem::path &base_path)
void createInpxCollection (const std::filesystem::path &path_to_inpx, const std::filesystem::path &base_path)

Public Attributes

std::function< void(double processed, double total)> signal_file_hashed
Public Attributes inherited from CreateCollection
std::function< void(const size_t &files_found)> signal_files_collecting
std::function< void(double processed, double total)> signal_parsing_progress

Additional Inherited Members

Static Public Member Functions inherited from CreateCollection
static void saveBase (const std::filesystem::path &base_path, UDBase &col_base)
Protected Member Functions inherited from CreateCollection
void filesCollecting (const std::vector< std::filesystem::path > &files_and_dirs, UDBase &col_base)
size_t countFiles (const std::vector< UDBElement > &el_v)
std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > getAllFiles (const std::vector< UDBElement > &el_v)
void removeDublicates (std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > &files)
void processFiles (const std::vector< UDBElement > &items)
void fileParsing (UDBElement *file)
void cleanBase (std::vector< UDBElement > &items)
void fb2Parsing (UDBElement *file, const std::filesystem::path &file_path)
void epubParsing (UDBElement *file, const std::filesystem::path &file_path)
void pdfParsing (UDBElement *file, const std::filesystem::path &file_path)
void djvuParsing (UDBElement *file, const std::filesystem::path &file_path)
void odtParsing (UDBElement *file, const std::filesystem::path &file_path)
void txtParsing (UDBElement *file, const std::filesystem::path &file_path)
void docParsing (UDBElement *file, const std::filesystem::path &file_path)
void rtfParsing (UDBElement *file, const std::filesystem::path &file_path)
void docxParsing (UDBElement *file, const std::filesystem::path &file_path)
void mobiParsing (UDBElement *file, const std::filesystem::path &file_path)
void archiveParsing (UDBElement *file, const std::filesystem::path &file_path)
std::string bufferHash (const std::string &buf)
std::string fileHash (const std::filesystem::path &file_path)
void bufHash (UDBElement *file, const std::filesystem::path &file_path, const std::string &buf)
Protected Attributes inherited from CreateCollection
std::shared_ptr< MLBookProc > mlbp
std::shared_ptr< std::vector< std::tuple< unsigned, bool > > > threads_v
std::shared_ptr< std::mutex > threads_v_mtx
std::shared_ptr< std::condition_variable > threads_v_var
std::atomic< bool > cancel
std::vector< std::shared_ptr< ArchiveParser > > arch_proc
std::mutex arch_proc_mtx
std::vector< std::tuple< std::filesystem::path, std::string > > already_hashed
BaseID bid
std::atomic< double > processed
double total

Detailed Description

The RefreshCollection class.

This class contains methods used for collection maintenance.

Constructor & Destructor Documentation

◆ RefreshCollection()

RefreshCollection::RefreshCollection ( const std::shared_ptr< MLBookProc > & mlbp,
const int & threads_num = int(1) )

RefreshCollection constructor.

Parameters
mlbpSmart pointer to MLBookProc object.
threads_numMaximum number of threads to be used in operations.

Member Function Documentation

◆ addFilesAndDirs()

void RefreshCollection::addFilesAndDirs ( const std::filesystem::path & base_path,
const std::vector< std::filesystem::path > & files_and_dirs )

Adds files, symlinks or directories to existing collection.

Parameters
base_pathPath to collection database file.
files_and_dirsList of files, symlinks or directories to be added to collection.

◆ refreshCollection()

void RefreshCollection::refreshCollection ( const std::filesystem::path & base_path,
const bool & fast_refresh = bool(true) )

Refreshes given collection.

Checks files existance and sizes. If size of file is not equal its database entry, file will be reparsed. If fast_refresh set to false, checks all files hash sums, and if file hash sum not equal its database entry, file will be reparsed. If given collection type is 'legacy' or 'inpx', collection will be recreated as 'native'.

Parameters
base_pathPath to collection database file.
fast_refreshIf true, file hash sums will not be checked.

◆ stopAll()

void RefreshCollection::stopAll ( )
overridevirtual

Stops all operations.

Reimplemented from CreateCollection.

Member Data Documentation

◆ signal_file_hashed

std::function<void(double processed, double total)> RefreshCollection::signal_file_hashed

If this callback set, it will be called to indicate files hashing progress.

progress - number of items already hashed, total - total number of items to be hashed.