CreateCollection(3)
| CreateCollection(3) | Library Functions Manual | CreateCollection(3) |
NAME
CreateCollection - The CreateCollection class.
SYNOPSIS
#include <CreateCollection.h>
Inherited by RefreshCollection.
Public Member Functions
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)
virtual void stopAll ()
Static Public Member Functions
static void saveBase (const std::filesystem::path
&base_path, UDBase &col_base)
Public Attributes
std::function< void(const size_t &files_found)>
signal_files_collecting
std::function< void(double processed, double total)>
signal_parsing_progress
Protected Member Functions
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
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 CreateCollection class.
This class contains methods for collection database creation.
Constructor & Destructor Documentation
CreateCollection::CreateCollection (const std::shared_ptr< MLBookProc > & mlbp, const int & threads_num = int(1))
CreateCollection constructor.
Parameters
threads_num Maximum permitted number of working threads.
Member Function Documentation
void CreateCollection::archiveParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses archive file.
Parameters
file_path Path to file to be parsed.
std::string CreateCollection::bufferHash (const std::string & buf) [protected]
Calcultes hash sum for given buffer.
Parameters
Returns
void CreateCollection::bufHash (UDBElement * file, const std::filesystem::path & file_path, const std::string & buf) [protected]
Calcultes hash sum for given BaseID::File object.
Caller can provide file_path ot buf on his choice.
Parameters
file_path Path to file hash sum to be calculated for.
buf Buffer hash sum to be calculted for.
void CreateCollection::cleanBase (std::vector< UDBElement > & items) [protected]
Removes all BaseID::File objects, not containing BaseID::Book objects.
Parameters
size_t CreateCollection::countFiles (const std::vector< UDBElement > & el_v) [protected]
Counts BaseID::File objects in given vector.
Parameters
Returns
void CreateCollection::createCollection (const std::vector< std::filesystem::path > & files_and_dirs, const std::filesystem::path & base_path)
Creates collection database.
Parameters
base_path Path to result database file.
void CreateCollection::createInpxCollection (const std::filesystem::path & path_to_inpx, const std::filesystem::path & base_path)
Creates database from inpx file.
Parameters
base_path Path to result database file.
void CreateCollection::djvuParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses djvu file.
Parameters
file_path Path to file to be parsed.
void CreateCollection::docParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses doc files.
Parameters
file_path Path to file to be parsed.
void CreateCollection::docxParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses docx files.
Parameters
file_path Path to file to be parsed.
void CreateCollection::epubParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses epub file.
Parameters
file_path Path to file to be parsed.
void CreateCollection::fb2Parsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses fb2 and fbd file.
Parameters
file_path Path to file to be parsed.
std::string CreateCollection::fileHash (const std::filesystem::path & file_path) [protected]
Calculates file hash sum.
Parameters
Returns
void CreateCollection::fileParsing (UDBElement * file) [protected]
Parses given BaseID::File object.
Parameters
void CreateCollection::filesCollecting (const std::vector< std::filesystem::path > & files_and_dirs, UDBase & col_base) [protected]
Collects supported files and creates base template. In most cases you do not need to call this method yourself.
Parameters
col_base Result database.
std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > CreateCollection::getAllFiles (const std::vector< UDBElement > & el_v) [protected]
Collects all BaseID::File objects.
Parameters
Returns
void CreateCollection::mobiParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses mobi files.
Parameters
file_path Path to file to be parsed.
void CreateCollection::odtParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses odt file.
Parameters
file_path Path to file to be parsed.
void CreateCollection::pdfParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses pdf file.
Parameters
file_path Path to file to be parsed.
void CreateCollection::processFiles (const std::vector< UDBElement > & items) [protected]
Processed given items.
Parameters
void CreateCollection::removeDublicates (std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > & files) [protected]
Cleans given vector from repeated BaseID::File objects.
Parameters
void CreateCollection::rtfParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses rtf files.
Parameters
file_path Path to file to be parsed.
void CreateCollection::saveBase (const std::filesystem::path & base_path, UDBase & col_base) [static]
Writes given base to file.
Parameters
col_base Collection database.
virtual void CreateCollection::stopAll () [virtual]
Stops all operations.
Reimplemented in RefreshCollection.
void CreateCollection::txtParsing (UDBElement * file, const std::filesystem::path & file_path) [protected]
Parses txt and md files.
Parameters
file_path Path to file to be parsed.
Member Data Documentation
std::vector<std::tuple<std::filesystem::path, std::string> > CreateCollection::already_hashed [protected]
Vector of files for which hash sums has been calculated erlear (in RefreshCollection methods).
First element of tuple - path to file. Second element - raw hash sum.
Warning
std::vector<std::shared_ptr<ArchiveParser> > CreateCollection::arch_proc [protected]
Vector of active archives parsing processes.
Warning
std::mutex CreateCollection::arch_proc_mtx [protected]
std::mutex locking arch_proc vector.
Warning
BaseID CreateCollection::bid [protected]
BaseID object.
std::atomic<bool> CreateCollection::cancel [protected]
If set to true all processes will be stopped.
Warning
std::shared_ptr<MLBookProc> CreateCollection::mlbp [protected]
Smart pointer to MlBookProc object.
Warning
std::atomic<double> CreateCollection::processed [protected]
Number of processed items.
Warning
std::function<void(const size_t &files_found)> CreateCollection::signal_files_collecting
This callback function will be called during files collecting to indicate progress if set. files_found - total number of found files.
std::function<void(double processed, double total)> CreateCollection::signal_parsing_progress
This callback function will be called during files parsing to indicate progress, if set. processed - number of processed items, total - total number of items to be processed.
std::shared_ptr<std::vector<std::tuple<unsigned, bool> > > CreateCollection::threads_v [protected]
Smart pointer to processors identificators buffer.
First element of tuple - processor number. Second element indicates if processor is busy by any working thread of current collection creation process.
Warning
std::shared_ptr<std::mutex> CreateCollection::threads_v_mtx [protected]
Smart pointer to mutex locking threads_v.
Warning
std::shared_ptr<std::condition_variable> CreateCollection::threads_v_var [protected]
Smart pointer to conditional variable locking threads_v.
Warning
double CreateCollection::total [protected]
Total number of items to be processed.
Warning
Author
Generated automatically by Doxygen for MLBookProc from the source code.
| Version 2.1 | MLBookProc |
