creaImageIO_lib
|
#include <creaImageIOGimmick.h>
Public Types | |
typedef TreeHandlerImageAdder::Progress | AddProgress |
typedef TreeHandlerImageAdder::ProgressCallbackType | AddProgressCallbackType |
typedef std::map< std::string, TreeHandler * > | TreeHandlerMapType |
Type of map from TreeHandler name to TreeHandler*. More... | |
typedef std::map< std::string, TreeHandler * > ::const_iterator | ItTreeHandlerMap |
Public Member Functions | |
Gimmick () | |
Ctor. More... | |
~Gimmick () | |
Dtor. More... | |
void | ConnectAddProgressObserver (AddProgressCallbackType callback) |
const AddProgress & | GetAddProgress () const |
void | Initialize () |
Initializes with default values (read/creates databases, etc.) More... | |
void | Initialize (const std::string namedescp, const std::string namedb="Local Database") |
Initializes with the local database descriptor in the path given (read/creates databases, etc.) More... | |
void | Finalize () |
Finalize (closes databases, etc.) More... | |
TreeHandlerMapType & | GetTreeHandlerMap () |
Returns the TreeHandlerMap (ref) More... | |
const TreeHandlerMapType & | GetTreeHandlerMap () const |
Returns the TreeHandlerMap (const ref) More... | |
void | AddFiles (const std::string &handler, const std::vector< std::string > &filenames) |
Add the files to the given TreeHandler. More... | |
void | AddDir (const std::string &handler, const std::string &path, bool recurse) |
Add a dir to the given TreeHandler. More... | |
void | RemoveFile (const std::string &d, tree::Node *filename) |
Removes a file from the given TreeHandler. More... | |
void | DeleteDrive (const std::string &drive) |
Deletes the given drive name from the databases. More... | |
void | CopyFiles (const std::vector< std::string > &filenames, const std::string &d) |
Copies the files into the local directory. More... | |
std::string | Synchronize (const std::string &d, bool repair, bool checkAttributes) |
void | Print (const std::string &handler) |
Prints the tree handled by the handler. More... | |
SQLiteTreeHandler * | createDB (const std::string &i_name, const std::string &i_locDesc, const std::string &i_locDB) |
create a DB from a given descriptor file and for a specific location More... | |
void | addDB (const std::string &i_nameDB, const std::string &i_locationDB) |
add an existent DB More... | |
TreeHandler * | GetTreeHandler (const std::string &name) const |
Returns the TreeHandler with a given name. More... | |
SQLiteTreeHandler * | GetLocalDatabase () |
const SQLiteTreeHandler * | GetLocalDatabase () const |
void | GetSetting (const std::string &name, std::string &value) |
Returns the given setting value for the given setting parameter. More... | |
void | UpdateSetting (const std::string &name, const std::string &value) |
Updates the settings file. More... | |
void | addDBSettings () |
add DB from Settings file More... | |
void | EditField (tree::Node *node, const std::string &d, const std::string &name, const std::string &key, const std::string &val) |
Edits the field described by the name and key provided with the value given. More... | |
void | GetAttributes (const std::string &d, const std::string &filename, const std::vector< std::string > ¶ms, std::vector< std::string > &results) |
Returns the attributes in results described in params. More... | |
void | GetAttributes (const std::string filename, std::map< std::string, std::string > &i_res, OutputAttr i_attr) |
get Values for given attributes More... | |
const std::string & | GetHomeDirectory () |
const std::string & | GetUserSettingsDirectory () |
void | CreateUserSettingsDirectory () |
const std::string & | GetLocalDatabasePath () |
void | fillVectInfos (std::vector< std::string > i_attr, OutputAttr &infos) |
Decide if attributes are available through database. More... | |
const std::string | getSummary () |
Get Add Opertaion summary. More... | |
Static Public Member Functions | |
static void | SetMessageLevel (int level) |
Sets level for messages "Gimmick!". More... | |
static void | SetDebugMessageLevel (int level) |
Sets level for debug messages "Gimmick! DEBUG". More... | |
Private Attributes | |
SQLiteTreeHandler * | mLocalDatabase |
TreeHandlerMapType | mTreeHandlerMap |
Synchronizer * | mSynchronizer |
std::string | mCurrentDirectory |
std::string | mHomeDirectory |
std::string | mUserSettingsDirectory |
std::string | mLocalDatabasePath |
Settings * | mSettings |
TreeHandlerImageAdder | mImageAdder |
std::string | mLocalDBName |
std::string | mLocalDescpName |
Definition at line 117 of file creaImageIOGimmick.h.
Definition at line 126 of file creaImageIOGimmick.h.
Definition at line 127 of file creaImageIOGimmick.h.
typedef std::map<std::string, TreeHandler*>::const_iterator creaImageIO::Gimmick::ItTreeHandlerMap |
Definition at line 159 of file creaImageIOGimmick.h.
typedef std::map<std::string, TreeHandler*> creaImageIO::Gimmick::TreeHandlerMapType |
Type of map from TreeHandler name to TreeHandler*.
Definition at line 157 of file creaImageIOGimmick.h.
creaImageIO::Gimmick::Gimmick | ( | ) |
Ctor.
Definition at line 51 of file creaImageIOGimmick.cpp.
References mLocalDBName, mLocalDescpName, mSettings, mSynchronizer, and creaImageIO::RegisterGimmickMessageTypes().
creaImageIO::Gimmick::~Gimmick | ( | ) |
Dtor.
Definition at line 64 of file creaImageIOGimmick.cpp.
References mSettings, mSynchronizer, and creaImageIO::Settings::writeSettingsFile().
void creaImageIO::Gimmick::addDB | ( | const std::string & | i_nameDB, |
const std::string & | i_locationDB | ||
) |
add an existent DB
Definition at line 121 of file creaImageIOGimmick.cpp.
References creaImageIO::Settings::addDB(), mSettings, and mTreeHandlerMap.
Referenced by addDBSettings().
void creaImageIO::Gimmick::addDBSettings | ( | ) |
add DB from Settings file
Definition at line 520 of file creaImageIOGimmick.cpp.
References addDB(), creaImageIO::Settings::getValue(), mSettings, and SETTINGS_DBPATH.
Referenced by Initialize().
void creaImageIO::Gimmick::AddDir | ( | const std::string & | handler, |
const std::string & | path, | ||
bool | recurse | ||
) |
Add a dir to the given TreeHandler.
Add a dir to the local database.
Definition at line 380 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::AddDirectory(), GetTreeHandler(), GimmickMessage, mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
Referenced by main().
void creaImageIO::Gimmick::AddFiles | ( | const std::string & | handler, |
const std::vector< std::string > & | filenames | ||
) |
Add the files to the given TreeHandler.
Add the files to the tree handler.
Definition at line 366 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::AddFiles(), GetTreeHandler(), GimmickMessage, mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
Referenced by main().
|
inline |
Adds the function f to the list of functions to call when addition operations progres. f is of type AddProgressCallbackType which is: void (*AddProgressCallbackType)(AddProgress&) To pass a member function 'f' of an instance 'c' of a class 'C' as callback you have to 'bind' it, i.e. call: ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
Definition at line 136 of file creaImageIOGimmick.h.
void creaImageIO::Gimmick::CopyFiles | ( | const std::vector< std::string > & | filenames, |
const std::string & | d | ||
) |
Copies the files into the local directory.
Definition at line 408 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::CopyFiles(), GetTreeHandler(), creaImageIO::Settings::getValue(), mImageAdder, mSettings, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), SETTINGS_COPY_PATH, and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
Referenced by main().
SQLiteTreeHandler * creaImageIO::Gimmick::createDB | ( | const std::string & | i_name, |
const std::string & | i_locDesc, | ||
const std::string & | i_locDB | ||
) |
create a DB from a given descriptor file and for a specific location
Open and test it
Definition at line 139 of file creaImageIOGimmick.cpp.
References creaImageIO::SQLiteTreeHandler::Create(), creaImageIO::tree::Descriptor::createDescriptorfromFile(), creaImageIO::tree::Tree::GetDescriptor(), creaImageIO::TreeHandler::GetTree(), GimmickDebugMessage, GimmickError, GimmickMessage, creaImageIO::SQLiteTreeHandler::Open(), and creaImageIO::SQLiteTreeHandler::SetAttribute().
Referenced by Initialize().
void creaImageIO::Gimmick::CreateUserSettingsDirectory | ( | ) |
Definition at line 248 of file creaImageIOGimmick.cpp.
References GetUserSettingsDirectory(), GimmickError, GimmickMessage, INVALID_FILE_SEPARATOR, mLocalDescpName, PATH_MAX, and VALID_FILE_SEPARATOR.
Referenced by Initialize().
void creaImageIO::Gimmick::DeleteDrive | ( | const std::string & | drive | ) |
Deletes the given drive name from the databases.
Definition at line 492 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::DeleteDriveFromMainDB(), creaImageIO::TreeHandlerImageAdder::DeleteDriveFromOtherDB(), mImageAdder, mSynchronizer, mTreeHandlerMap, creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
void creaImageIO::Gimmick::EditField | ( | tree::Node * | node, |
const std::string & | d, | ||
const std::string & | name, | ||
const std::string & | key, | ||
const std::string & | val | ||
) |
Edits the field described by the name and key provided with the value given.
Definition at line 506 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::EditField(), GetTreeHandler(), mImageAdder, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
void creaImageIO::Gimmick::fillVectInfos | ( | std::vector< std::string > | i_attr, |
OutputAttr & | infos | ||
) |
Decide if attributes are available through database.
Definition at line 553 of file creaImageIOGimmick.cpp.
References creaImageIO::OutputAttr::db, GetTreeHandler(), creaImageIO::OutputAttr::inside, creaImageIO::TreeHandlerImageAdder::isAttributeExist(), mImageAdder, creaImageIO::OutputAttr::outside, and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
void creaImageIO::Gimmick::Finalize | ( | ) |
Finalize (closes databases, etc.)
Definition at line 174 of file creaImageIOGimmick.cpp.
References mTreeHandlerMap.
Referenced by main().
|
inline |
Definition at line 140 of file creaImageIOGimmick.h.
Referenced by getSummary().
void creaImageIO::Gimmick::GetAttributes | ( | const std::string & | d, |
const std::string & | filename, | ||
const std::vector< std::string > & | params, | ||
std::vector< std::string > & | results | ||
) |
Returns the attributes in results described in params.
Definition at line 444 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandlerImageAdder::GetAttributes(), GetTreeHandler(), mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().
void creaImageIO::Gimmick::GetAttributes | ( | const std::string | filename, |
std::map< std::string, std::string > & | i_res, | ||
OutputAttr | i_attr | ||
) |
get Values for given attributes
Definition at line 460 of file creaImageIOGimmick.cpp.
References creaImageIO::OutputAttr::db, creaImageIO::TreeHandler::getAllAttributes(), GetTreeHandler(), and creaImageIO::OutputAttr::inside.
const std::string & creaImageIO::Gimmick::GetHomeDirectory | ( | ) |
Definition at line 201 of file creaImageIOGimmick.cpp.
References mHomeDirectory.
Referenced by GetUserSettingsDirectory(), and Initialize().
|
inline |
Definition at line 207 of file creaImageIOGimmick.h.
|
inline |
Definition at line 209 of file creaImageIOGimmick.h.
const std::string & creaImageIO::Gimmick::GetLocalDatabasePath | ( | ) |
Definition at line 230 of file creaImageIOGimmick.cpp.
References GetUserSettingsDirectory(), INVALID_FILE_SEPARATOR, mLocalDatabasePath, mLocalDBName, and VALID_FILE_SEPARATOR.
Referenced by Initialize().
void creaImageIO::Gimmick::GetSetting | ( | const std::string & | name, |
std::string & | value | ||
) |
Returns the given setting value for the given setting parameter.
Definition at line 436 of file creaImageIOGimmick.cpp.
References creaImageIO::Settings::getValue(), and mSettings.
const std::string creaImageIO::Gimmick::getSummary | ( | ) |
Get Add Opertaion summary.
Definition at line 572 of file creaImageIOGimmick.cpp.
References GetAddProgress(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberAddedFiles(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberHandledFiles(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberScannedDirs(), and creaImageIO::TreeHandlerImageAdder::Progress::GetNumberScannedFiles().
TreeHandler * creaImageIO::Gimmick::GetTreeHandler | ( | const std::string & | name | ) | const |
Returns the TreeHandler with a given name.
Returns the tree handler with the given name.
Definition at line 353 of file creaImageIOGimmick.cpp.
References GetTreeHandlerMap(), and GimmickError.
Referenced by AddDir(), AddFiles(), CopyFiles(), EditField(), fillVectInfos(), GetAttributes(), main(), Print(), and Synchronize().
|
inline |
Returns the TreeHandlerMap (ref)
Definition at line 162 of file creaImageIOGimmick.h.
Referenced by GetTreeHandler().
|
inline |
const std::string & creaImageIO::Gimmick::GetUserSettingsDirectory | ( | ) |
Definition at line 214 of file creaImageIOGimmick.cpp.
References GetHomeDirectory(), INVALID_FILE_SEPARATOR, mUserSettingsDirectory, and VALID_FILE_SEPARATOR.
Referenced by CreateUserSettingsDirectory(), GetLocalDatabasePath(), and Initialize().
void creaImageIO::Gimmick::Initialize | ( | ) |
Initializes with default values (read/creates databases, etc.)
Definition at line 88 of file creaImageIOGimmick.cpp.
References addDBSettings(), createDB(), CreateUserSettingsDirectory(), GetHomeDirectory(), GetLocalDatabasePath(), GetUserSettingsDirectory(), INVALID_FILE_SEPARATOR, mCurrentDirectory, mLocalDatabase, mLocalDBName, mLocalDescpName, mSettings, mSynchronizer, mTreeHandlerMap, and VALID_FILE_SEPARATOR.
Referenced by Initialize(), and main().
void creaImageIO::Gimmick::Initialize | ( | const std::string | namedescp, |
const std::string | namedb = "Local Database" |
||
) |
Initializes with the local database descriptor in the path given (read/creates databases, etc.)
Definition at line 80 of file creaImageIOGimmick.cpp.
References Initialize(), mLocalDBName, and mLocalDescpName.
void creaImageIO::Gimmick::Print | ( | const std::string & | handler | ) |
Prints the tree handled by the handler.
Definition at line 430 of file creaImageIOGimmick.cpp.
References creaImageIO::TreeHandler::GetTree(), GetTreeHandler(), and creaImageIO::tree::Tree::Print().
Referenced by main().
void creaImageIO::Gimmick::RemoveFile | ( | const std::string & | d, |
tree::Node * | filename | ||
) |
Removes a file from the given TreeHandler.
Definition at line 396 of file creaImageIOGimmick.cpp.
References mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::RemoveFile(), creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), and creaImageIO::TreeHandlerImageAdder::SetSynchronizer().
|
static |
Sets level for debug messages "Gimmick! DEBUG".
Sets message level.
Definition at line 345 of file creaImageIOGimmick.cpp.
References creaImageIO::SetGimmickDebugMessageLevel().
Referenced by main().
|
static |
Sets level for messages "Gimmick!".
Sets message level.
Definition at line 337 of file creaImageIOGimmick.cpp.
References creaImageIO::SetGimmickMessageLevel().
Referenced by main().
std::string creaImageIO::Gimmick::Synchronize | ( | const std::string & | d, |
bool | repair, | ||
bool | checkAttributes | ||
) |
Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise only a warning sign will be issued
Definition at line 419 of file creaImageIOGimmick.cpp.
References GetTreeHandler(), mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), creaImageIO::TreeHandlerImageAdder::SetTreeHandler(), and creaImageIO::TreeHandlerImageAdder::Synchronize().
Referenced by main().
void creaImageIO::Gimmick::UpdateSetting | ( | const std::string & | name, |
const std::string & | value | ||
) |
Updates the settings file.
Definition at line 485 of file creaImageIOGimmick.cpp.
References mSettings, creaImageIO::Settings::updateSetting(), and creaImageIO::Settings::writeSettingsFile().
|
private |
Definition at line 248 of file creaImageIOGimmick.h.
Referenced by Initialize().
|
private |
Definition at line 249 of file creaImageIOGimmick.h.
Referenced by GetHomeDirectory().
|
private |
Definition at line 253 of file creaImageIOGimmick.h.
Referenced by AddDir(), AddFiles(), CopyFiles(), DeleteDrive(), EditField(), fillVectInfos(), GetAttributes(), RemoveFile(), and Synchronize().
|
private |
Definition at line 244 of file creaImageIOGimmick.h.
Referenced by Initialize().
|
private |
Definition at line 251 of file creaImageIOGimmick.h.
Referenced by GetLocalDatabasePath().
|
private |
Definition at line 254 of file creaImageIOGimmick.h.
Referenced by GetLocalDatabasePath(), Gimmick(), and Initialize().
|
private |
Definition at line 255 of file creaImageIOGimmick.h.
Referenced by CreateUserSettingsDirectory(), Gimmick(), and Initialize().
|
private |
Definition at line 252 of file creaImageIOGimmick.h.
Referenced by addDB(), addDBSettings(), CopyFiles(), GetSetting(), Gimmick(), Initialize(), UpdateSetting(), and ~Gimmick().
|
private |
Definition at line 246 of file creaImageIOGimmick.h.
Referenced by AddDir(), AddFiles(), CopyFiles(), DeleteDrive(), GetAttributes(), Gimmick(), Initialize(), RemoveFile(), Synchronize(), and ~Gimmick().
|
private |
Definition at line 245 of file creaImageIOGimmick.h.
Referenced by addDB(), DeleteDrive(), Finalize(), and Initialize().
|
private |
Definition at line 250 of file creaImageIOGimmick.h.
Referenced by GetUserSettingsDirectory().