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

The RefreshCollection class. More...

#include <RefreshCollection.h>

Inheritance diagram for RefreshCollection:
CreateCollection Hasher

Public Member Functions

 RefreshCollection (const std::shared_ptr< AuxFunc > &af, const std::string &collection_name, const int &num_threads, const bool &remove_empty, const bool &refresh_bookmarks, const bool &fast_refresh, const std::shared_ptr< BookMarks > &bookmarks)
 RefreshCollection constructor.
 
virtual ~RefreshCollection ()
 RefreshCollection destructor.
 
void refreshCollection ()
 Refreshes whole collection.
 
void refreshFile (const BookBaseEntry &bbe)
 Refreshes iformation about particular file.
 
bool editBook (const BookBaseEntry &bbe_old, const BookBaseEntry &bbe_new)
 Replaces information in database.
 
bool refreshBook (const BookBaseEntry &bbe)
 Refreshes information in database about particular book.
 
void set_rar_support (const bool &rar_support)
 Enables support of rar archives.
 
- Public Member Functions inherited from CreateCollection
 CreateCollection (const std::shared_ptr< AuxFunc > &af, const std::filesystem::path &collection_path, const std::filesystem::path &books_path, const bool &rar_support, const int &num_threads)
 CreateCollection constructor.
 
virtual ~CreateCollection ()
 CreateCollection destructor.
 
void createCollection ()
 Starts collection creation.
 
- Public Member Functions inherited from Hasher
 Hasher (const std::shared_ptr< AuxFunc > &af)
 Hasher constructor.
 
std::string buf_hashing (const std::string &buf)
 Creates hash sum for given buffer.
 
std::string file_hashing (const std::filesystem::path &filepath)
 Creates hash sum for given file.
 
void cancelAll ()
 Stops all operations.
 

Public Attributes

std::function< void(const double &total_hash)> total_bytes_to_hash
 "Total bytes to hash" signal.
 
std::function< void(const double &hashed)> bytes_hashed
 "Total bytes hashed" signal.
 
- Public Attributes inherited from CreateCollection
std::function< void()> pulse
 "Pulse" callback.
 
std::function< void(const double &)> signal_total_bytes
 "Total bytes" callback.
 
std::function< void(const double &progress)> progress
 "Progress" callback.
 

Additional Inherited Members

- Protected Member Functions inherited from CreateCollection
 CreateCollection (const std::shared_ptr< AuxFunc > &af, const int &num_threads)
 CreateCollection constructor.
 
void threadRegulator ()
 Threads regulator.
 
void openBaseFile ()
 Opens database file for writing.
 
void closeBaseFile ()
 Finishes database writing.
 
void write_file_to_base (const FileParseEntry &fe)
 Writes file data to database.
 
- Protected Attributes inherited from CreateCollection
std::filesystem::path base_path
 Absolute path to database.
 
std::filesystem::path books_path
 Absolute path to books directory.
 
bool rar_support = false
 If true, rar archives will be processed, otherwise - not.
 
std::vector< std::tuple< std::filesystem::path, std::string > > already_hashed
 Hashed files.
 
std::vector< std::filesystem::path > need_to_parse
 "Need to parse" vector.
 
double current_bytes = 0.0
 Keeps quantity of bytes have been processed.
 
- Protected Attributes inherited from Hasher
bool cancel
 Stops all operations if true.
 
std::function< void()> stop_all_signal
 Stop signal for heir classes.
 

Detailed Description

The RefreshCollection class.

This class contains various methods for collection database refreshing in case of any changes were made to collection files.

Constructor & Destructor Documentation

◆ RefreshCollection()

RefreshCollection::RefreshCollection ( const std::shared_ptr< AuxFunc > & af,
const std::string & collection_name,
const int & num_threads,
const bool & remove_empty,
const bool & refresh_bookmarks,
const bool & fast_refresh,
const std::shared_ptr< BookMarks > & bookmarks )

RefreshCollection constructor.

Note
See also set_rar_support() method.
Parameters
afsmart pointer to AuxFunc object.
collection_namecollection name.
num_threadsnumber of threads to be used (see also CreateCollection::CreateCollection()).
remove_emptyif true, empty directories and files will be removed.
fast_refreshif true, file hashes calculations will not be carried out (hashes of all collection files will be recalculated otherwise).
refresh_bookmarksif true, bookmarks pointing to absent books will be removed.
bookmarkssmart pointer to BookMarks object.

Member Function Documentation

◆ editBook()

bool RefreshCollection::editBook ( const BookBaseEntry & bbe_old,
const BookBaseEntry & bbe_new )

Replaces information in database.

Use this method, if you need to edit database entries manually.

Parameters
bbe_oldexisting BookBaseEntry (see BaseKeeper::searchBook()).
bbe_newBookBaseEntry containing new information.
Returns
Returns true, if operation has been successful.

◆ refreshBook()

bool RefreshCollection::refreshBook ( const BookBaseEntry & bbe)

Refreshes information in database about particular book.

Parameters
bbeBookBaseEntry object (see BaseKeeper::searchBook()).
Returns
Returns true, if operation has been successful.

◆ refreshCollection()

void RefreshCollection::refreshCollection ( )

Refreshes whole collection.

Caries out collection refreshing.

Note
This method can throw MLException in case of errors.

◆ refreshFile()

void RefreshCollection::refreshFile ( const BookBaseEntry & bbe)

Refreshes iformation about particular file.

Parameters
bbeBookBaseEntry object (see BaseKeeper::searchBook()).

◆ set_rar_support()

void RefreshCollection::set_rar_support ( const bool & rar_support)

Enables support of rar archives.

Set rar_support to true, if you need to parse rar archives (see also CreateCollection::CreateCollection()).

Parameters
rar_supportif true, rar archives will be parsed.

Member Data Documentation

◆ bytes_hashed

std::function<void(const double &hashed)> RefreshCollection::bytes_hashed

"Total bytes hashed" signal.

Emitted after file has been hashed, to indicate total quantity of bytes have been hashed. Bind your method to bytes_hashed, if you need such information.

◆ total_bytes_to_hash

std::function<void(const double &total_hash)> RefreshCollection::total_bytes_to_hash

"Total bytes to hash" signal.

Emitted after files for refreshing have been collected, to indicate total quantity bytes to be hashed. Bind your method to total_bytes_to_hash, if you need such information.