MLBookProc 1.1
 
Loading...
Searching...
No Matches
CreateCollection Class Reference

The CreateCollection class. More...

#include <CreateCollection.h>

Inheritance diagram for CreateCollection:
Hasher RefreshCollection

Public Member Functions

 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()> pulse
 "Pulse" callback.
 
std::function< void(const double &)> signal_total_bytes
 "Total bytes" callback.
 
std::function< void(const double &progress)> progress
 "Progress" callback.
 

Protected Member Functions

 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

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 CreateCollection class.

This class containes methods for collection database creation.

Constructor & Destructor Documentation

◆ CreateCollection() [1/2]

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.

Parameters
afsmart pointer to AuxFunc object.
collection_pathabsolute path to collection base directory (if it doesnt exsist, MLBookProc will create it).
books_pathabsolute path to books directory.
rar_supportif true, rar archives will be processed, otherwise - not (some rar archives can cause errors).
num_threadslimit of working threads to be used.

◆ CreateCollection() [2/2]

CreateCollection::CreateCollection ( const std::shared_ptr< AuxFunc > & af,
const int & num_threads )
protected

CreateCollection constructor.

Warning
Do not call this constructor yourself!

This constructor is used by RefreshCollection class.

Parameters
afsmart pointer to AuxFunc object.
num_threadslimit of working threads to be used.

Member Function Documentation

◆ closeBaseFile()

void CreateCollection::closeBaseFile ( )
protected

Finishes database writing.

Warning
Do not call this method yourself!

◆ createCollection()

void CreateCollection::createCollection ( )

Starts collection creation.

Note
This method can throw MLException in case of errors.

◆ openBaseFile()

void CreateCollection::openBaseFile ( )
protected

Opens database file for writing.

Warning
Do not call this method yourself!

◆ threadRegulator()

void CreateCollection::threadRegulator ( )
protected

Threads regulator.

Warning
Do not call this method yourself!

◆ write_file_to_base()

void CreateCollection::write_file_to_base ( const FileParseEntry & fe)
protected

Writes file data to database.

Warning
Do not call this method yourself!
Parameters
feFileParseEntry object.

Member Data Documentation

◆ already_hashed

std::vector<std::tuple<std::filesystem::path, std::string> > CreateCollection::already_hashed
protected

Hashed files.

This vector is used by RefreshCollection class to indicate files, has been already hashed.

Warning
Do not call or set this vector yourself!

◆ base_path

std::filesystem::path CreateCollection::base_path
protected

Absolute path to database.

Warning
Do not call or set this variable yourself!

◆ books_path

std::filesystem::path CreateCollection::books_path
protected

Absolute path to books directory.

Warning
Do not call or set this variable yourself!

◆ current_bytes

double CreateCollection::current_bytes = 0.0
protected

Keeps quantity of bytes have been processed.

Warning
Do not call or set this variable yourself!

◆ need_to_parse

std::vector<std::filesystem::path> CreateCollection::need_to_parse
protected

"Need to parse" vector.

This vector is used to indicate files, needed to be parsed.

Warning
Do not call or set this vector yourself!

◆ progress

std::function<void(const double &progress)> CreateCollection::progress

"Progress" callback.

Emitted after each file processing completion. Indicates total quantity of bytes has been processed. Bind your method to it, if you need such information.

◆ pulse

std::function<void()> CreateCollection::pulse

"Pulse" callback.

Emitted while preliminary files collecting to show that process is not frozen. Bind your method to it, if you need such information.

◆ rar_support

bool CreateCollection::rar_support = false
protected

If true, rar archives will be processed, otherwise - not.

Warning
Do not call or set this variable yourself!

◆ signal_total_bytes

std::function<void(const double &)> CreateCollection::signal_total_bytes

"Total bytes" callback.

Emitted after preliminary files collecting completed to indicate total quantity of bytes to be processed. Bind your method to it, if you need such information.