creaImageIO_lib
|
Object which can add images files to a TreeHandler. Is able to parse (recursively) a part of a filesystem to look for known images and load their attributes in order to add the images to a Tree (submission via a TreeHandler::AddBranch) More...
#include <creaImageIOTreeHandlerImageAdder.h>
Classes | |
class | Progress |
Public Types | |
typedef boost::signal< void(Progress &)> | ProgressSignalType |
typedef ProgressSignalType::slot_function_type | ProgressCallbackType |
Public Member Functions | |
TreeHandlerImageAdder (TreeHandler *tree) | |
Ctor. More... | |
~TreeHandlerImageAdder () | |
Dtor. More... | |
void | SetTreeHandler (TreeHandler *tree) |
Sets the TreeHandler. More... | |
void | SetSynchronizer (Synchronizer *s) |
Sets the synchronizer. More... | |
void | SetCurrentDatabase (std::string cur) |
Sets the synchronizer. More... | |
const Progress & | GetProgress () const |
void | ConnectProgressObserver (ProgressCallbackType callback) |
bool | IsHandledFile (const std::string &filename) |
Returns if the file can be read or not. More... | |
void | AddFiles (const std::vector< std::string > &filename) |
Adds a list of files to the TreeHandler. More... | |
void | AddDirectory (const std::string &directory, bool recurse) |
(Recursively) adds the files of a directory to the TreeHandler More... | |
void | RemoveFile (tree::Node *node) |
Removes a file from the databases. More... | |
void | RemoveFiles (const std::vector< tree::Node * > &nodes) |
Removes files from the databases. More... | |
void | remove (tree::Node *i_node) |
std::string | Synchronize (bool repair, bool checkAttributes) |
Synchronizes the DB and disk by repeating the operations the user has done and returns a report. More... | |
void | CheckSyncDirectory (const std::string &dirpath, bool recursive, bool repair, bool checkAttributes, std::vector< std::string > &i_ignorefiles, std::vector< std::string > &attsModified, std::vector< std::string > &newfiles) |
Recursively checks if the directory is synchronized and optionally the state of the attributes. More... | |
void | CopyFiles (const std::vector< std::string > &filenames, const std::string directory) |
Copies the files indicated in the vector and updates all databases. More... | |
void | SaveAs (const std::vector< std::string > &filenames, std::vector< vtkImageData * > i_images) |
Saves as the files indicated in the vector in a specific directory. More... | |
void | FindNode (tree::Node *parent, int level, const std::string &searchParam, const std::string &searchVal, tree::Node *&node) |
Finds the node that matches the specified parameters. More... | |
void | FindNodePartial (tree::Node *parent, int level, const std::string &searchParam, const std::string &searchVal, tree::Node *&node) |
Finds the nodes that partially match the searchVal. More... | |
void | CheckAttributes (bool repair, std::string &file, std::vector< std::string > &attsModified) |
Checks the attributes of the database against the ones in disk. More... | |
void | DeleteDriveFromMainDB (const std::string &drive) |
Deletes the drive with the given name (use for all databases except maintenance and timestamp) More... | |
void | DeleteDriveFromOtherDB (const std::string &drive) |
Deletes the drive with the given name (use for maintenance and timestamp databases) More... | |
void | EditField (tree::Node *node, const std::string &name, const std::string &key, const std::string &val) |
Edits the given field and sets the new parameters. More... | |
void | GetAttributes (const std::vector< std::string > ¶ms, const std::string &filename, std::vector< std::string > &results) |
Returns the demanded attributes for the given file. More... | |
const std::string | isAttributeExist (const std::string i_attr) |
Test if an attribute is referenced for a given treeHandler. More... | |
Private Member Functions | |
void | AddFile (const std::string &filename) |
void | AddDirectoryRecursor (const std::string &directory, bool recurse, const std::string &addKey) |
Recursive method which does the main job for AddDirectory. More... | |
Private Attributes | |
TreeHandler * | mTreeHandler |
Synchronizer * | mSynchronizer |
ImageReader | mReader |
std::string | mCurrentDB |
Progress | mProgress |
ProgressSignalType | mProgressSignal |
Object which can add images files to a TreeHandler. Is able to parse (recursively) a part of a filesystem to look for known images and load their attributes in order to add the images to a Tree (submission via a TreeHandler::AddBranch)
Definition at line 52 of file creaImageIOTreeHandlerImageAdder.h.
typedef ProgressSignalType::slot_function_type creaImageIO::TreeHandlerImageAdder::ProgressCallbackType |
Definition at line 116 of file creaImageIOTreeHandlerImageAdder.h.
typedef boost::signal<void (Progress&)> creaImageIO::TreeHandlerImageAdder::ProgressSignalType |
Definition at line 115 of file creaImageIOTreeHandlerImageAdder.h.
creaImageIO::TreeHandlerImageAdder::TreeHandlerImageAdder | ( | TreeHandler * | tree | ) |
Ctor.
Definition at line 48 of file creaImageIOTreeHandlerImageAdder.cpp.
creaImageIO::TreeHandlerImageAdder::~TreeHandlerImageAdder | ( | ) |
void creaImageIO::TreeHandlerImageAdder::AddDirectory | ( | const std::string & | directory, |
bool | recurse | ||
) |
(Recursively) adds the files of a directory to the TreeHandler
Definition at line 104 of file creaImageIOTreeHandlerImageAdder.cpp.
References AddDirectoryRecursor(), creaImageIO::TreeHandler::BeginTransaction(), creaImageIO::TreeHandler::EndTransaction(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::Synchronizer::GetList(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberAddedFiles(), GetProgress(), GimmickDebugMessage, creaImageIO::Synchronizer::InsertAddOp(), mCurrentDB, mProgress, mSynchronizer, mTreeHandler, creaImageIO::TreeHandlerImageAdder::Progress::Reset(), and creaImageIO::Synchronizer::SetAttribute().
Referenced by creaImageIO::Gimmick::AddDir().
|
private |
Recursive method which does the main job for AddDirectory.
fix warning: unused variable lastModif
Definition at line 277 of file creaImageIOTreeHandlerImageAdder.cpp.
References AddFile(), creaImageIO::TreeHandlerImageAdder::Progress::GetStop(), GimmickDebugMessage, creaImageIO::TreeHandlerImageAdder::Progress::IncNumberHandledFiles(), creaImageIO::TreeHandlerImageAdder::Progress::IncNumberScannedDirs(), creaImageIO::TreeHandlerImageAdder::Progress::IncNumberScannedFiles(), creaImageIO::Synchronizer::InsertIgnoreFile(), IsHandledFile(), creaImageIO::Synchronizer::isIndexed(), mCurrentDB, mProgress, mProgressSignal, and mSynchronizer.
Referenced by AddDirectory().
|
private |
Adds a single file to the TreeHandler WITHOUT testing wether it is handled or not hence you have to call IsHandledFile before using AddFile!
Definition at line 128 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::TreeHandler::AddBranch(), creaImageIO::tree::Descriptor::BuildAttributeMap(), creaImageIO::tree::Tree::GetDescriptor(), creaImageIO::TreeHandler::GetTree(), GimmickDebugMessage, creaImageIO::TreeHandlerImageAdder::Progress::IncNumberAddedFiles(), mProgress, mReader, mTreeHandler, and creaImageIO::ImageReader::ReadAttributes().
Referenced by AddDirectoryRecursor(), AddFiles(), and Synchronize().
void creaImageIO::TreeHandlerImageAdder::AddFiles | ( | const std::vector< std::string > & | filename | ) |
Adds a list of files to the TreeHandler.
Definition at line 73 of file creaImageIOTreeHandlerImageAdder.cpp.
References AddFile(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::Synchronizer::GetList(), creaImageIO::TreeHandlerImageAdder::Progress::GetStop(), creaImageIO::TreeHandlerImageAdder::Progress::IncNumberHandledFiles(), creaImageIO::TreeHandlerImageAdder::Progress::IncNumberScannedFiles(), creaImageIO::Synchronizer::InsertAddOp(), creaImageIO::Synchronizer::InsertIgnoreFile(), IsHandledFile(), creaImageIO::Synchronizer::isIndexed(), mCurrentDB, mProgress, mProgressSignal, mSynchronizer, and creaImageIO::TreeHandlerImageAdder::Progress::Reset().
Referenced by creaImageIO::Gimmick::AddFiles().
void creaImageIO::TreeHandlerImageAdder::CheckAttributes | ( | bool | repair, |
std::string & | file, | ||
std::vector< std::string > & | attsModified | ||
) |
Checks the attributes of the database against the ones in disk.
Definition at line 516 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::tree::Descriptor::BuildAttributeMap(), creaImageIO::TreeHandler::GetAttribute(), creaImageIO::tree::Tree::GetAttributeDescriptorList(), creaImageIO::tree::Tree::GetDescriptor(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), mReader, mTreeHandler, creaImageIO::ImageReader::ReadAttributes(), and creaImageIO::TreeHandler::SetAttribute().
Referenced by CheckSyncDirectory().
void creaImageIO::TreeHandlerImageAdder::CheckSyncDirectory | ( | const std::string & | dirpath, |
bool | recursive, | ||
bool | repair, | ||
bool | checkAttributes, | ||
std::vector< std::string > & | i_ignorefiles, | ||
std::vector< std::string > & | attsModified, | ||
std::vector< std::string > & | newfiles | ||
) |
Recursively checks if the directory is synchronized and optionally the state of the attributes.
Definition at line 337 of file creaImageIOTreeHandlerImageAdder.cpp.
References CheckAttributes(), and IsHandledFile().
Referenced by Synchronize().
void creaImageIO::TreeHandlerImageAdder::ConnectProgressObserver | ( | ProgressCallbackType | callback | ) |
Adds the function f to the list of functions to call when the addition progresses. f is of type ProgressCallbackType which is: void (*ProgressCallbackType)(Progress&) To pass a member function 'f' of an instance 'c' of a class 'C' as callback you have to 'bind' it, i.e. call: ConnectProgressObserver ( boost::bind( &C::f , c, _1 ) );
Definition at line 59 of file creaImageIOTreeHandlerImageAdder.cpp.
References mProgressSignal.
void creaImageIO::TreeHandlerImageAdder::CopyFiles | ( | const std::vector< std::string > & | filenames, |
const std::string | directory | ||
) |
Copies the files indicated in the vector and updates all databases.
Definition at line 597 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::Synchronizer::GetAttribute(), creaImageIO::Synchronizer::InsertAddOp(), creaImageIO::Synchronizer::InsertIgnoreFile(), mCurrentDB, mSynchronizer, mTreeHandler, creaImageIO::Synchronizer::SetAttribute(), and creaImageIO::TreeHandler::SetAttribute().
Referenced by creaImageIO::Gimmick::CopyFiles().
void creaImageIO::TreeHandlerImageAdder::DeleteDriveFromMainDB | ( | const std::string & | drive | ) |
Deletes the drive with the given name (use for all databases except maintenance and timestamp)
Definition at line 666 of file creaImageIOTreeHandlerImageAdder.cpp.
References FindNodePartial(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::TreeHandler::GetTree(), creaImageIO::TreeHandler::LoadChildren(), mTreeHandler, and creaImageIO::TreeHandler::Remove().
Referenced by creaImageIO::Gimmick::DeleteDrive().
void creaImageIO::TreeHandlerImageAdder::DeleteDriveFromOtherDB | ( | const std::string & | drive | ) |
Deletes the drive with the given name (use for maintenance and timestamp databases)
Definition at line 683 of file creaImageIOTreeHandlerImageAdder.cpp.
References mSynchronizer, and creaImageIO::Synchronizer::RemoveEntries().
Referenced by creaImageIO::Gimmick::DeleteDrive().
void creaImageIO::TreeHandlerImageAdder::EditField | ( | tree::Node * | node, |
const std::string & | name, | ||
const std::string & | key, | ||
const std::string & | val | ||
) |
Edits the given field and sets the new parameters.
Definition at line 691 of file creaImageIOTreeHandlerImageAdder.cpp.
References mTreeHandler, creaImageIO::tree::Node::SetAttribute(), and creaImageIO::TreeHandler::SetAttribute().
Referenced by creaImageIO::Gimmick::EditField().
void creaImageIO::TreeHandlerImageAdder::FindNode | ( | tree::Node * | parent, |
int | level, | ||
const std::string & | searchParam, | ||
const std::string & | searchVal, | ||
tree::Node *& | node | ||
) |
Finds the node that matches the specified parameters.
Definition at line 544 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::tree::Node::GetAttribute(), and creaImageIO::tree::Node::GetChildrenList().
Referenced by Synchronize().
void creaImageIO::TreeHandlerImageAdder::FindNodePartial | ( | tree::Node * | parent, |
int | level, | ||
const std::string & | searchParam, | ||
const std::string & | searchVal, | ||
tree::Node *& | node | ||
) |
Finds the nodes that partially match the searchVal.
Definition at line 574 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::tree::Node::GetAttribute(), and creaImageIO::tree::Node::GetChildrenList().
Referenced by DeleteDriveFromMainDB().
void creaImageIO::TreeHandlerImageAdder::GetAttributes | ( | const std::vector< std::string > & | params, |
const std::string & | filename, | ||
std::vector< std::string > & | results | ||
) |
Returns the demanded attributes for the given file.
Definition at line 698 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::TreeHandler::GetAttribute(), and mTreeHandler.
Referenced by creaImageIO::Gimmick::GetAttributes().
|
inline |
Definition at line 111 of file creaImageIOTreeHandlerImageAdder.h.
References mProgress.
Referenced by AddDirectory().
const std::string creaImageIO::TreeHandlerImageAdder::isAttributeExist | ( | const std::string | i_attr | ) |
Test if an attribute is referenced for a given treeHandler.
Definition at line 712 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::TreeHandler::GetTree(), creaImageIO::tree::Tree::isAttributeExist(), and mTreeHandler.
Referenced by creaImageIO::Gimmick::fillVectInfos().
bool creaImageIO::TreeHandlerImageAdder::IsHandledFile | ( | const std::string & | filename | ) |
Returns if the file can be read or not.
Definition at line 66 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::ImageReader::CanRead(), and mReader.
Referenced by AddDirectoryRecursor(), AddFiles(), CheckSyncDirectory(), and Synchronize().
void creaImageIO::TreeHandlerImageAdder::remove | ( | tree::Node * | i_node | ) |
Definition at line 193 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::tree::Node::GetAttribute(), creaImageIO::Synchronizer::GetAttribute(), mCurrentDB, mSynchronizer, and creaImageIO::Synchronizer::SetAttribute().
void creaImageIO::TreeHandlerImageAdder::RemoveFile | ( | tree::Node * | node | ) |
Removes a file from the databases.
Definition at line 159 of file creaImageIOTreeHandlerImageAdder.cpp.
References creaImageIO::tree::Node::GetChildrenList(), creaImageIO::tree::Node::GetNumberOfChildren(), and RemoveFiles().
Referenced by creaImageIO::Gimmick::RemoveFile(), and Synchronize().
void creaImageIO::TreeHandlerImageAdder::RemoveFiles | ( | const std::vector< tree::Node * > & | nodes | ) |
Removes files from the databases.
Definition at line 174 of file creaImageIOTreeHandlerImageAdder.cpp.
Referenced by RemoveFile().
void creaImageIO::TreeHandlerImageAdder::SaveAs | ( | const std::vector< std::string > & | filenames, |
std::vector< vtkImageData * > | i_images | ||
) |
Saves as the files indicated in the vector in a specific directory.
Definition at line 564 of file creaImageIOTreeHandlerImageAdder.cpp.
|
inline |
Sets the synchronizer.
Definition at line 67 of file creaImageIOTreeHandlerImageAdder.h.
References mCurrentDB.
Referenced by creaImageIO::Gimmick::AddDir(), creaImageIO::Gimmick::AddFiles(), creaImageIO::Gimmick::CopyFiles(), creaImageIO::Gimmick::EditField(), creaImageIO::Gimmick::GetAttributes(), creaImageIO::Gimmick::RemoveFile(), and creaImageIO::Gimmick::Synchronize().
|
inline |
Sets the synchronizer.
Definition at line 65 of file creaImageIOTreeHandlerImageAdder.h.
References mSynchronizer.
Referenced by creaImageIO::Gimmick::AddDir(), creaImageIO::Gimmick::AddFiles(), creaImageIO::Gimmick::CopyFiles(), creaImageIO::Gimmick::DeleteDrive(), creaImageIO::Gimmick::GetAttributes(), creaImageIO::Gimmick::RemoveFile(), and creaImageIO::Gimmick::Synchronize().
|
inline |
Sets the TreeHandler.
Definition at line 62 of file creaImageIOTreeHandlerImageAdder.h.
References mTreeHandler.
Referenced by creaImageIO::Gimmick::AddDir(), creaImageIO::Gimmick::AddFiles(), creaImageIO::Gimmick::CopyFiles(), creaImageIO::Gimmick::DeleteDrive(), creaImageIO::Gimmick::EditField(), creaImageIO::Gimmick::fillVectInfos(), creaImageIO::Gimmick::GetAttributes(), and creaImageIO::Gimmick::Synchronize().
std::string creaImageIO::TreeHandlerImageAdder::Synchronize | ( | bool | repair, |
bool | checkAttributes | ||
) |
Synchronizes the DB and disk by repeating the operations the user has done and returns a report.
Definition at line 390 of file creaImageIOTreeHandlerImageAdder.cpp.
References AddFile(), CheckSyncDirectory(), FindNode(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::Synchronizer::GetFileList(), creaImageIO::Synchronizer::GetIgnoredFiles(), creaImageIO::TreeHandler::GetTree(), creaImageIO::Synchronizer::InsertIgnoreFile(), IsHandledFile(), creaImageIO::TreeHandler::LoadChildren(), mCurrentDB, mSynchronizer, mTreeHandler, creaImageIO::TreeHandler::Remove(), RemoveFile(), and creaImageIO::Synchronizer::SetAttribute().
Referenced by creaImageIO::Gimmick::Synchronize().
|
private |
Definition at line 212 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddDirectory(), AddDirectoryRecursor(), AddFiles(), CopyFiles(), remove(), SetCurrentDatabase(), and Synchronize().
|
private |
Definition at line 214 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddDirectory(), AddDirectoryRecursor(), AddFile(), AddFiles(), and GetProgress().
|
private |
Definition at line 215 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddDirectoryRecursor(), AddFiles(), and ConnectProgressObserver().
|
private |
Definition at line 210 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddFile(), CheckAttributes(), and IsHandledFile().
|
private |
Definition at line 209 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddDirectory(), AddDirectoryRecursor(), AddFiles(), CopyFiles(), DeleteDriveFromOtherDB(), remove(), SetSynchronizer(), and Synchronize().
|
private |
Definition at line 208 of file creaImageIOTreeHandlerImageAdder.h.
Referenced by AddDirectory(), AddFile(), CheckAttributes(), CopyFiles(), DeleteDriveFromMainDB(), EditField(), GetAttributes(), isAttributeExist(), SetTreeHandler(), and Synchronize().