creaImageIO_lib
|
In charge of the synchronization of the database and the disk state. More...
#include <creaImageIOSynchron.h>
Public Member Functions | |
Synchronizer (const std::string &path) | |
Ctor. More... | |
virtual | ~Synchronizer () |
Dtor. More... | |
void | Initialize () |
Initializes the database. More... | |
void | InsertAddOp (const std::string &path, const std::string &recursive, const std::string &nChildren, const std::string &refdb) |
Inserts an add operation to the database. More... | |
void | InsertIgnoreFile (const std::string &addKey, const std::string &path, const std::string &remove, const std::string &time, const std::string &refdb) |
Inserts a file to be ignored. More... | |
void | RemoveEntry (const std::string i_table, const std::string i_key) |
Removes an entry that matches the given parameter. More... | |
void | RemoveEntries (const std::string i_table, const std::string i_attribute, const std::string i_operand, const std::string i_key) |
Removes several entries. More... | |
void | GetFileList (std::vector< AddList > &files, const std::string &refdb) |
Gets the list of AddFiles. More... | |
void | GetIgnoredFiles (const std::string &key, std::vector< std::string > &ignoreList) |
Gets the list of ignored files. More... | |
std::string | GetAttribute (const std::string &attribute, const std::string &table, const std::string &searchParam, const std::string &searchValue, const std::string &refdb) |
Gets the attribute that matches the parameters. More... | |
void | SetAttribute (const std::string &attribute, const std::string &table, const std::string &value, const std::string &searchParam, const std::string &searchValue, const std::string &refdb) |
Sets an attribute to an entry that matches the given parameters. More... | |
void | GetList (const std::string i_db) |
bool | isIndexed (const std::string filename) |
Synchronizer (TreeHandler *th) | |
Ctor. More... | |
~Synchronizer () | |
Dtor. More... | |
void | SetTreeHandler (TreeHandler *handler) |
Sets the tree handler to use in order to synchronize with a given database. More... | |
std::string | Synchronize (bool update) |
bool | FileExists (std::string file) |
Checks if the file given as a parameter exists in the drive. More... | |
void | AttributesMatch (bool update, std::string file, std::stringstream &mess) |
Public Attributes | |
std::map< std::string, bool > | mList |
std::vector< AddList > | mAddList |
The current AddList. More... | |
std::vector< RemoveList > | mIgnoreList |
The current RemoveList. More... | |
Private Member Functions | |
void | CreateDB () |
Creates a new database. More... | |
void | UpdateAddList (const std::string &refdb) |
Updates the AddList. More... | |
void | CleanList (const std::string &refdb) |
Cleans the list in case operations are no longer useful (0 added files) More... | |
void | CleanName (std::string &str) const |
Cleans the name (changes slashes and backslashes according to the system) More... | |
std::vector< std::string > | GetIgnoreList (const std::string &i_key) |
Gets the ignore list. More... | |
const std::string | convert (const std::string &i_word) |
void | SynchronizeFile (bool update, std::string file, std::stringstream &message) |
Synchronizes the given file, doing the action required and returning the result on the string supplied. More... | |
Private Attributes | |
CppSQLite3DB * | mDB |
The DB. More... | |
std::string | pathDB |
Path of the current database. More... | |
TreeHandler * | mHandler |
The tree handler. More... | |
ImageReader | mReader |
The image reader. More... | |
In charge of the synchronization of the database and the disk state.
Synchronizes a given database with disk.
Definition at line 89 of file creaImageIOSynchron.h.
creaImageIO::Synchronizer::Synchronizer | ( | const std::string & | path | ) |
Ctor.
Definition at line 68 of file creaImageIOSynchron.cpp.
References Initialize(), mDB, and pathDB.
|
virtual |
creaImageIO::Synchronizer::Synchronizer | ( | TreeHandler * | th | ) |
creaImageIO::Synchronizer::~Synchronizer | ( | ) |
Dtor.
void creaImageIO::Synchronizer::AttributesMatch | ( | bool | update, |
std::string | file, | ||
std::stringstream & | mess | ||
) |
Checks if the attributes of the node given as a parameter matchwith it correspondent file in disk NB: This method doesn't check the existence of the file, so FileExists should be called before.
Definition at line 114 of file creaImageIOSynchronizer.cpp.
References creaImageIO::tree::Descriptor::BuildAttributeMap(), creaImageIO::TreeHandler::GetAttribute(), creaImageIO::tree::Tree::GetAttributeDescriptorList(), creaImageIO::tree::Tree::GetDescriptor(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), mHandler, mReader, creaImageIO::ImageReader::ReadAttributes(), and creaImageIO::TreeHandler::SetAttribute().
Referenced by SynchronizeFile().
|
private |
Cleans the list in case operations are no longer useful (0 added files)
Definition at line 211 of file creaImageIOSynchron.cpp.
References mAddList, RemoveEntry(), and UpdateAddList().
Referenced by GetFileList().
|
private |
Cleans the name (changes slashes and backslashes according to the system)
Definition at line 135 of file creaImageIOSynchron.cpp.
Referenced by GetAttribute(), InsertAddOp(), InsertIgnoreFile(), and SetAttribute().
|
private |
Definition at line 476 of file creaImageIOSynchron.cpp.
Referenced by GetAttribute(), InsertAddOp(), InsertIgnoreFile(), and SetAttribute().
|
private |
Creates a new database.
Definition at line 108 of file creaImageIOSynchron.cpp.
References mDB, CppSQLite3DB::open(), pathDB, and UPDATESYNCDB.
Referenced by Initialize().
bool creaImageIO::Synchronizer::FileExists | ( | std::string | file | ) |
Checks if the file given as a parameter exists in the drive.
Definition at line 101 of file creaImageIOSynchronizer.cpp.
References GimmickDebugMessage.
Referenced by SynchronizeFile().
std::string creaImageIO::Synchronizer::GetAttribute | ( | const std::string & | attribute, |
const std::string & | table, | ||
const std::string & | searchParam, | ||
const std::string & | searchValue, | ||
const std::string & | refdb | ||
) |
Gets the attribute that matches the parameters.
Definition at line 342 of file creaImageIOSynchron.cpp.
References CleanName(), convert(), CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), CppSQLite3Query::nextRow(), and QUERYSYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectory(), creaImageIO::TreeHandlerImageAdder::AddFiles(), creaImageIO::TreeHandlerImageAdder::CopyFiles(), InsertIgnoreFile(), creaImageIO::TreeHandlerImageAdder::remove(), and creaImageIO::TreeHandlerImageAdder::Synchronize().
void creaImageIO::Synchronizer::GetFileList | ( | std::vector< AddList > & | files, |
const std::string & | refdb | ||
) |
Gets the list of AddFiles.
Definition at line 150 of file creaImageIOSynchron.cpp.
References CleanList(), and mAddList.
Referenced by creaImageIO::TreeHandlerImageAdder::Synchronize().
void creaImageIO::Synchronizer::GetIgnoredFiles | ( | const std::string & | key, |
std::vector< std::string > & | ignoreList | ||
) |
Gets the list of ignored files.
Definition at line 157 of file creaImageIOSynchron.cpp.
References GetIgnoreList().
Referenced by creaImageIO::TreeHandlerImageAdder::Synchronize().
|
private |
Gets the ignore list.
Definition at line 308 of file creaImageIOSynchron.cpp.
References CppSQLite3Query::eof(), mIgnoreList, CppSQLite3Query::nextRow(), QUERYSYNCDB, and creaImageIO::RemoveList::remove.
Referenced by GetIgnoredFiles().
void creaImageIO::Synchronizer::GetList | ( | const std::string | i_db | ) |
Definition at line 417 of file creaImageIOSynchron.cpp.
References CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), mList, CppSQLite3Query::nextRow(), and QUERYSYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectory(), and creaImageIO::TreeHandlerImageAdder::AddFiles().
void creaImageIO::Synchronizer::Initialize | ( | ) |
Initializes the database.
Definition at line 82 of file creaImageIOSynchron.cpp.
References CreateDB(), CppSQLite3Exception::errorCode(), CppSQLite3Exception::errorMessage(), GimmickError, mDB, CppSQLite3DB::open(), and pathDB.
Referenced by Synchronizer().
void creaImageIO::Synchronizer::InsertAddOp | ( | const std::string & | path, |
const std::string & | recursive, | ||
const std::string & | nChildren, | ||
const std::string & | refdb | ||
) |
Inserts an add operation to the database.
Definition at line 237 of file creaImageIOSynchron.cpp.
References CleanName(), convert(), and UPDATESYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectory(), creaImageIO::TreeHandlerImageAdder::AddFiles(), and creaImageIO::TreeHandlerImageAdder::CopyFiles().
void creaImageIO::Synchronizer::InsertIgnoreFile | ( | const std::string & | addKey, |
const std::string & | path, | ||
const std::string & | remove, | ||
const std::string & | time, | ||
const std::string & | refdb | ||
) |
Inserts a file to be ignored.
Definition at line 259 of file creaImageIOSynchron.cpp.
References CleanName(), convert(), GetAttribute(), SetAttribute(), and UPDATESYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectoryRecursor(), creaImageIO::TreeHandlerImageAdder::AddFiles(), creaImageIO::TreeHandlerImageAdder::CopyFiles(), and creaImageIO::TreeHandlerImageAdder::Synchronize().
bool creaImageIO::Synchronizer::isIndexed | ( | const std::string | filename | ) |
Definition at line 460 of file creaImageIOSynchron.cpp.
References mList.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectoryRecursor(), and creaImageIO::TreeHandlerImageAdder::AddFiles().
void creaImageIO::Synchronizer::RemoveEntries | ( | const std::string | i_table, |
const std::string | i_attribute, | ||
const std::string | i_operand, | ||
const std::string | i_key | ||
) |
Removes several entries.
Definition at line 196 of file creaImageIOSynchron.cpp.
References UPDATESYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::DeleteDriveFromOtherDB().
void creaImageIO::Synchronizer::RemoveEntry | ( | const std::string | i_table, |
const std::string | i_key | ||
) |
Removes an entry that matches the given parameter.
Definition at line 182 of file creaImageIOSynchron.cpp.
References UPDATESYNCDB.
Referenced by CleanList().
void creaImageIO::Synchronizer::SetAttribute | ( | const std::string & | attribute, |
const std::string & | table, | ||
const std::string & | value, | ||
const std::string & | searchParam, | ||
const std::string & | searchValue, | ||
const std::string & | refdb | ||
) |
Sets an attribute to an entry that matches the given parameters.
Definition at line 380 of file creaImageIOSynchron.cpp.
References CleanName(), convert(), and UPDATESYNCDB.
Referenced by creaImageIO::TreeHandlerImageAdder::AddDirectory(), creaImageIO::TreeHandlerImageAdder::CopyFiles(), InsertIgnoreFile(), creaImageIO::TreeHandlerImageAdder::remove(), and creaImageIO::TreeHandlerImageAdder::Synchronize().
|
inline |
Sets the tree handler to use in order to synchronize with a given database.
Definition at line 48 of file creaImageIOSynchronizer.h.
References mHandler.
std::string creaImageIO::Synchronizer::Synchronize | ( | bool | update | ) |
Synchronizes the database in the current tree handler with disk by doing the passed action. If it is true, the database will be updated, otherwise a warning message will be returned.
Definition at line 54 of file creaImageIOSynchronizer.cpp.
References creaImageIO::TreeHandler::GetAttribute(), GimmickMessage, mHandler, and SynchronizeFile().
|
private |
Synchronizes the given file, doing the action required and returning the result on the string supplied.
Definition at line 79 of file creaImageIOSynchronizer.cpp.
References AttributesMatch(), creaImageIO::TreeHandler::DeleteTuple(), FileExists(), and mHandler.
Referenced by Synchronize().
|
private |
Updates the AddList.
Definition at line 163 of file creaImageIOSynchron.cpp.
References CppSQLite3Query::eof(), mAddList, CppSQLite3Query::nextRow(), and QUERYSYNCDB.
Referenced by CleanList().
std::vector<AddList> creaImageIO::Synchronizer::mAddList |
The current AddList.
Definition at line 140 of file creaImageIOSynchron.h.
Referenced by CleanList(), GetFileList(), and UpdateAddList().
|
private |
The DB.
Definition at line 146 of file creaImageIOSynchron.h.
Referenced by CreateDB(), Initialize(), Synchronizer(), and ~Synchronizer().
|
private |
The tree handler.
Definition at line 61 of file creaImageIOSynchronizer.h.
Referenced by AttributesMatch(), SetTreeHandler(), Synchronize(), and SynchronizeFile().
std::vector<RemoveList> creaImageIO::Synchronizer::mIgnoreList |
The current RemoveList.
Definition at line 142 of file creaImageIOSynchron.h.
Referenced by GetIgnoreList().
std::map<std::string, bool> creaImageIO::Synchronizer::mList |
Definition at line 138 of file creaImageIOSynchron.h.
Referenced by GetList(), and isIndexed().
|
private |
The image reader.
Definition at line 63 of file creaImageIOSynchronizer.h.
Referenced by AttributesMatch().
|
private |
Path of the current database.
Definition at line 148 of file creaImageIOSynchron.h.
Referenced by CreateDB(), Initialize(), and Synchronizer().