creaImageIO_lib
creaImageIO::Gimmick Class Reference

#include <creaImageIOGimmick.h>

Collaboration diagram for creaImageIO::Gimmick:

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 AddProgressGetAddProgress () 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...
 
TreeHandlerMapTypeGetTreeHandlerMap ()
 Returns the TreeHandlerMap (ref) More...
 
const TreeHandlerMapTypeGetTreeHandlerMap () 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...
 
SQLiteTreeHandlercreateDB (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...
 
TreeHandlerGetTreeHandler (const std::string &name) const
 Returns the TreeHandler with a given name. More...
 
SQLiteTreeHandlerGetLocalDatabase ()
 
const SQLiteTreeHandlerGetLocalDatabase () 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 > &params, 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

SQLiteTreeHandlermLocalDatabase
 
TreeHandlerMapType mTreeHandlerMap
 
SynchronizermSynchronizer
 
std::string mCurrentDirectory
 
std::string mHomeDirectory
 
std::string mUserSettingsDirectory
 
std::string mLocalDatabasePath
 
SettingsmSettings
 
TreeHandlerImageAdder mImageAdder
 
std::string mLocalDBName
 
std::string mLocalDescpName
 

Detailed Description

Definition at line 117 of file creaImageIOGimmick.h.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

creaImageIO::Gimmick::Gimmick ( )

Ctor.

Definition at line 51 of file creaImageIOGimmick.cpp.

References mLocalDBName, mLocalDescpName, mSettings, mSynchronizer, and creaImageIO::RegisterGimmickMessageTypes().

52  : mImageAdder(0)
53  {
55  mSettings=0;
56  mSynchronizer=0;
57  mLocalDescpName = "localdatabase_Descriptor.dscp";
58  mLocalDBName = "Local database";
59  }

Here is the call graph for this function:

creaImageIO::Gimmick::~Gimmick ( )

Dtor.

Definition at line 64 of file creaImageIOGimmick.cpp.

References mSettings, mSynchronizer, and creaImageIO::Settings::writeSettingsFile().

65  {
66 
67  if(mSettings!=0)
68  {
70  delete mSettings;
71  }
72  if(mSynchronizer!=0)
73  {
74  delete mSynchronizer;
75  }
76  }

Here is the call graph for this function:

Member Function Documentation

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().

123  {
124  if(mTreeHandlerMap.find(i_name) == mTreeHandlerMap.end())
125  {
126  mTreeHandlerMap[i_name] = new SQLiteTreeHandler(i_location);
127  mTreeHandlerMap[i_name]->Open(true);
128  mSettings->addDB(i_location);
129  }
130  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

521  {
522 
523  std::string pathSettings = mSettings->getValue(SETTINGS_DBPATH);
524 
525  // split to find all paths
526  std::vector<std::string> paths;
527  std::string separator = ";";
528  std::string::size_type last_pos = pathSettings.find_first_not_of(separator);
529  //find first separator
530  std::string::size_type pos = pathSettings.find_first_of(separator, last_pos);
531  while(std::string::npos != pos || std::string::npos != last_pos)
532  {
533  paths.push_back(pathSettings.substr(last_pos, pos - last_pos));
534  last_pos = pathSettings.find_first_not_of(separator, pos);
535  pos = pathSettings.find_first_of(separator, last_pos);
536  }
537 
538  std::vector<std::string>::iterator it_path = paths.begin();
539  for(; it_path != paths.end(); ++it_path)
540  {
541  pos = it_path->find_last_of("\\");
542  last_pos = it_path->find_last_of(".");
543  std::string name = it_path->substr(pos +1, last_pos -pos-1 );
544  addDB(name, it_path->c_str());
545  }
546  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

382  {
383  GimmickMessage(2,"Adding dir '"<<f<<"' to '"<<d<<"' recurse:"
384  <<recurse<<std::endl);
385 
386  TreeHandler * handler=GetTreeHandler(d);
388  mImageAdder.SetTreeHandler(handler);
390  mImageAdder.AddDirectory(f,recurse);
391  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

368  {
369  GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
370 
374  mImageAdder.AddFiles(filenames);
375  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::Gimmick::ConnectAddProgressObserver ( AddProgressCallbackType  callback)
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.

137  { mImageAdder.ConnectProgressObserver(callback); }
void creaImageIO::Gimmick::CopyFiles ( const std::vector< std::string > &  filenames,
const std::string &  d 
)
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().

142  {
143  SQLiteTreeHandler* sqlTreeH( new SQLiteTreeHandler(i_locDB) );
144  // Create or open local database
145  if (! boost::filesystem::exists(i_locDB) )
146  {
147  std::string mess = "Local database '";
148  mess += i_locDB;
149  mess += "' does not exist : creating it";
150  GimmickMessage(1,mess<<std::endl);
151 
152  // CREATING DB STRUCTURE
153  sqlTreeH->GetTree().GetDescriptor().createDescriptorfromFile(i_locDesc);
154  if ( ! sqlTreeH->Create(true) )
155  {
156  GimmickError("ERROR CREATING '"<<i_locDB<<"'");
157  }
158  sqlTreeH->SetAttribute(0,"Name",i_name);
159  }
160  else
161  {
163 
164  GimmickDebugMessage(1,"Opening local database '" <<i_locDB<< "' " << std::endl);
165  if ( !sqlTreeH->Open(true) )
166  {
167  GimmickError("ERROR OPENING '"<<i_locDB<<"'");
168  }
169  }
170  return sqlTreeH;
171  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

249  {
250 
251  // std::string st("C:/Documents and Settings/cervenansky/.gimmick/");
252  // boost::algorithm::replace_all( st,
253  // INVALID_FILE_SEPARATOR ,
254  // VALID_FILE_SEPARATOR);
255  //const boost::filesystem::path mpath(st);
256 //C:\Documents and Settings\cervenansky\.gimmick");
257  //if ( !boost::filesystem::exists( path ) ) return ;
258  // boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
259  // for ( boost::filesystem::directory_iterator itr( path ); itr != end_itr; ++itr )
260  // {
262  // if ( boost::filesystem::is_directory(itr->status()) )
263  // return;
264  // }
265 
266  //JCP settings dir 02/10/2009
267  const std::string settingsdirectory = GetUserSettingsDirectory();
268  //boost::algorithm::replace_all( mUserSettingsDirectory,
269  // INVALID_FILE_SEPARATOR ,
270  // VALID_FILE_SEPARATOR);
271 ;//("E:\frederic");
272  //("C:\\Documents and Settings\\cervenansky\\.gimmick\\"); // settingsdirectory );
273  bool isdir = false;
274  isdir = boost::filesystem::is_directory(settingsdirectory); // settingsdirectory );
275  if (! isdir )
276  {
277  GimmickMessage(1,"Directory '"<<GetUserSettingsDirectory()<<"' "
278  << "does not exist : creating it"<<std::endl);
279 
280  if ( ! boost::filesystem::create_directory( GetUserSettingsDirectory() ) )
281  {
282  GimmickError("ERROR CREATING '"<<GetUserSettingsDirectory()<<"'");
283  }
284  }
285 
286  std::string setDir=GetUserSettingsDirectory();
287  boost::algorithm::replace_all( setDir,
290  setDir+="share/";
291  boost::filesystem::create_directory( setDir );
292  setDir+="creaImageIO/";
293  boost::filesystem::create_directory( setDir );
294  setDir+=mLocalDescpName;
295 
296  if(!boost::filesystem::is_regular(setDir))
297  {
298  char name[PATH_MAX];
299  crea::System::GetAppPath(name,PATH_MAX);
300  std::cout<<name<<std::endl;
301 
302  std::string path=name;
303  path=path.substr(0,path.size()-1);
304  path=path.substr(0,path.find_last_of("/"));
305  //Creating directories
306 
307 // The following stuff works on Linux, NOT CHECKED on Windows // JPR
308 
309 #if defined(_WIN32)
310  path+="/bin/share/creaImageIO/";
311 #endif
312 
313 #if defined (LINUX)
314  path+="/../share/creaImageIO/";
315 #endif
316 #if defined(__APPLE__)
317  path+="/../../../../share/creaImageIO/";
318 #endif
319 
320 
321 path+= mLocalDescpName;
322 
323  std::cout <<"From: " << path <<std::endl;
324  std::cout <<"To: " << setDir <<std::endl;
325  boost::algorithm::replace_all( path,
328  boost::filesystem::copy_file(path,setDir);
329  }
330 
331  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

493  {
494  for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin();
495  it!= mTreeHandlerMap.end();
496  ++it)
497  {
498  mImageAdder.SetTreeHandler(it->second);
500  }
503  }

Here is the call graph for this function:

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().

507  {
508  TreeHandler * handler=GetTreeHandler(d);
510  mImageAdder.SetTreeHandler(handler);
511  mImageAdder.EditField(node,name,key,val);
512  }

Here is the call graph for this function:

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().

554 {
555  //test if a tag is present in Database descriptor
556  TreeHandler * handler=GetTreeHandler(infos.db);
557  mImageAdder.SetTreeHandler(handler);
558  std::vector<std::string>::const_iterator it = i_attr.begin();
559  for (;it != i_attr.end(); it++)
560  {
561  if( mImageAdder.isAttributeExist((*it)) != "" ) // in DB
562  {
563  infos.inside.push_back((*it));
564  }
565  else
566  {
567  infos.outside.push_back((*it)); // Need to scan again the files
568  }
569  }
570 }

Here is the call graph for this function:

void creaImageIO::Gimmick::Finalize ( )

Finalize (closes databases, etc.)

Definition at line 174 of file creaImageIOGimmick.cpp.

References mTreeHandlerMap.

Referenced by main().

175  {
176  if(mTreeHandlerMap.size() >0)
177  {
178  // delete SQLiteTreeHandler Object
179  for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin();
180  it!= mTreeHandlerMap.end();
181  ++it)
182  {
183  delete it->second;
184  }
185  }
186  }

Here is the caller graph for this function:

const AddProgress& creaImageIO::Gimmick::GetAddProgress ( ) const
inline

Definition at line 140 of file creaImageIOGimmick.h.

Referenced by getSummary().

140 { return mImageAdder.GetProgress(); }

Here is the caller graph for this function:

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().

448  {
449  TreeHandler * handler=GetTreeHandler(d);
451  mImageAdder.SetTreeHandler(handler);
453  mImageAdder.GetAttributes(params, filename, results);
454  }

Here is the call graph for this function:

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.

461  {
462  if (i_attr.inside.size() > 0)
463  {
464  std::map<std::string, std::string> map_attr;
465  TreeHandler * handler=GetTreeHandler(i_attr.db);
466  handler->getAllAttributes(filename, map_attr);
467  if(i_attr.inside.front() == "ALL") // we take all values
468  {
469  std::map<std::string, std::string>::iterator it = map_attr.begin();
470  for(; it != map_attr.end(); it++)
471  i_res[it->first] = it->second;
472  }
473  else
474  {
475  std::vector<std::string>::iterator it = i_attr.inside.begin();
476  for(; it != i_attr.inside.end(); it++)
477  i_res[(*it)] = map_attr[(*it)];
478  }
479  }
480  }

Here is the call graph for this function:

const std::string & creaImageIO::Gimmick::GetHomeDirectory ( )

Definition at line 201 of file creaImageIOGimmick.cpp.

References mHomeDirectory.

Referenced by GetUserSettingsDirectory(), and Initialize().

202  {
203  if (mHomeDirectory.size()==0)
204  {
205 #if defined(__GNUC__)
206  mHomeDirectory = getenv("HOME");
207 #elif defined(_WIN32)
208  mHomeDirectory = getenv("USERPROFILE");
209 #endif
210  }
211  return mHomeDirectory;
212  }

Here is the caller graph for this function:

SQLiteTreeHandler* creaImageIO::Gimmick::GetLocalDatabase ( )
inline

Definition at line 207 of file creaImageIOGimmick.h.

207 { return mLocalDatabase; }
const SQLiteTreeHandler* creaImageIO::Gimmick::GetLocalDatabase ( ) const
inline

Definition at line 209 of file creaImageIOGimmick.h.

209 { return mLocalDatabase; }
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().

231  {
232  if (mLocalDatabasePath.size()==0)
233  {
235  mLocalDatabasePath += "share/creaImageIO/";
237  mLocalDatabasePath +=".sqlite3";
238  boost::algorithm::replace_all( mLocalDatabasePath,
241  }
242  return mLocalDatabasePath;
243  }

Here is the call graph for this function:

Here is the caller graph for this function:

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.

437  {
438  value = mSettings->getValue(name);
439  }

Here is the call graph for this function:

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().

573 {
574  const AddProgress& p = GetAddProgress();
575  std::stringstream mess;
576  mess << "Dirs \tscanned\t: " << p.GetNumberScannedDirs() << "\n";
577  mess << "Files\tscanned\t: " << p.GetNumberScannedFiles() << "\n";
578  mess << "Files\thandled\t: " << p.GetNumberHandledFiles() << "\n\n";
579  mess << "Files\tadded \t: " << p.GetNumberAddedFiles() << "\n\n";
580  return mess.str();
581 }

Here is the call graph for this function:

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().

354  {
355  TreeHandlerMapType::const_iterator i;
356  i = GetTreeHandlerMap().find(name);
357  if ( i == GetTreeHandlerMap().end() )
358  {
359  GimmickError("TreeHandler '"<<name<<"' does not exist");
360  }
361  return i->second;
362  }

Here is the call graph for this function:

Here is the caller graph for this function:

TreeHandlerMapType& creaImageIO::Gimmick::GetTreeHandlerMap ( )
inline

Returns the TreeHandlerMap (ref)

Definition at line 162 of file creaImageIOGimmick.h.

Referenced by GetTreeHandler().

162 { return mTreeHandlerMap; }

Here is the caller graph for this function:

const TreeHandlerMapType& creaImageIO::Gimmick::GetTreeHandlerMap ( ) const
inline

Returns the TreeHandlerMap (const ref)

Definition at line 165 of file creaImageIOGimmick.h.

166  { return mTreeHandlerMap; }
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().

215  {
216  if (mUserSettingsDirectory.size()==0)
217  {
219  mUserSettingsDirectory += "/.creaImageIO/";
220  boost::algorithm::replace_all( mUserSettingsDirectory,
223  }
224  return mUserSettingsDirectory;
225  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

89  {
90  std::string i_nameDB = mLocalDBName;
91  // Create the UserSettings dir if does not exist
93  // Sets the current directory to the home dir
95  mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"share/creaImageIO/");
96 
97  mSettings = new Settings(mCurrentDirectory);
98 
99  std::string dbpath = GetLocalDatabasePath();
100 
101  // Create or open local database
102  std::string dpath= mCurrentDirectory + "/.creaImageIO/share/creaImageIO/" + mLocalDescpName;
103 
104  boost::algorithm::replace_all( dpath,
107  mLocalDatabase = createDB(i_nameDB, dpath, dbpath);
108  // Add it to the TreeHandlerMap
109  mTreeHandlerMap[i_nameDB] = mLocalDatabase;
110 
111  //Add additional DB from user Settings
112  addDBSettings();
113  }

Here is the call graph for this function:

Here is the caller graph for this function:

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.

81  {
82  mLocalDescpName = i_namedescp;
83  mLocalDBName = i_namedb;
84  Initialize();
85  }

Here is the call graph for this function:

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().

431  {
432  GetTreeHandler(d)->GetTree().Print();
433  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::Gimmick::RemoveFile ( const std::string &  d,
tree::Node filename 
)
void creaImageIO::Gimmick::SetDebugMessageLevel ( int  level)
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().

346  {
348  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::Gimmick::SetMessageLevel ( int  level)
static

Sets level for messages "Gimmick!".

Sets message level.

Definition at line 337 of file creaImageIOGimmick.cpp.

References creaImageIO::SetGimmickMessageLevel().

Referenced by main().

338  {
340  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

420  {
421  TreeHandler * handler=GetTreeHandler(d);
423  mImageAdder.SetTreeHandler(handler);
425  return mImageAdder.Synchronize(repair, checkAttributes);
426  }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

486  {
487  mSettings->updateSetting(name,value);
489  }

Here is the call graph for this function:

Member Data Documentation

std::string creaImageIO::Gimmick::mCurrentDirectory
private

Definition at line 248 of file creaImageIOGimmick.h.

Referenced by Initialize().

std::string creaImageIO::Gimmick::mHomeDirectory
private

Definition at line 249 of file creaImageIOGimmick.h.

Referenced by GetHomeDirectory().

TreeHandlerImageAdder creaImageIO::Gimmick::mImageAdder
private
SQLiteTreeHandler* creaImageIO::Gimmick::mLocalDatabase
private

Definition at line 244 of file creaImageIOGimmick.h.

Referenced by Initialize().

std::string creaImageIO::Gimmick::mLocalDatabasePath
private

Definition at line 251 of file creaImageIOGimmick.h.

Referenced by GetLocalDatabasePath().

std::string creaImageIO::Gimmick::mLocalDBName
private

Definition at line 254 of file creaImageIOGimmick.h.

Referenced by GetLocalDatabasePath(), Gimmick(), and Initialize().

std::string creaImageIO::Gimmick::mLocalDescpName
private

Definition at line 255 of file creaImageIOGimmick.h.

Referenced by CreateUserSettingsDirectory(), Gimmick(), and Initialize().

Settings* creaImageIO::Gimmick::mSettings
private
Synchronizer* creaImageIO::Gimmick::mSynchronizer
private
TreeHandlerMapType creaImageIO::Gimmick::mTreeHandlerMap
private

Definition at line 245 of file creaImageIOGimmick.h.

Referenced by addDB(), DeleteDrive(), Finalize(), and Initialize().

std::string creaImageIO::Gimmick::mUserSettingsDirectory
private

Definition at line 250 of file creaImageIOGimmick.h.

Referenced by GetUserSettingsDirectory().


The documentation for this class was generated from the following files: