Public Types | Public Member Functions | Static Public Member Functions | Private Attributes

creaImageIO::Gimmick Class Reference

#include <creaImageIOGimmick.h>

Collaboration diagram for creaImageIO::Gimmick:
Collaboration graph
[legend]

List of all members.

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*.
typedef std::map< std::string,
TreeHandler * >
::const_iterator 
ItTreeHandlerMap

Public Member Functions

 Gimmick ()
 Ctor.
 ~Gimmick ()
 Dtor.
void ConnectAddProgressObserver (AddProgressCallbackType callback)
const AddProgressGetAddProgress () const
void Initialize ()
 Initializes with default values (read/creates databases, etc.).
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.).
void Finalize ()
 Finalize (closes databases, etc.).
TreeHandlerMapTypeGetTreeHandlerMap ()
 Returns the TreeHandlerMap (ref).
const TreeHandlerMapTypeGetTreeHandlerMap () const
 Returns the TreeHandlerMap (const ref).
void AddFiles (const std::string &handler, const std::vector< std::string > &filenames)
 Add the files to the given TreeHandler.
void AddDir (const std::string &handler, const std::string &path, bool recurse)
 Add a dir to the given TreeHandler.
void RemoveFile (const std::string &d, tree::Node *filename)
 Removes a file from the given TreeHandler.
void DeleteDrive (const std::string &drive)
 Deletes the given drive name from the databases.
void CopyFiles (const std::vector< std::string > &filenames, const std::string &d)
 Copies the files into the local directory.
std::string Synchronize (const std::string &d, bool repair, bool checkAttributes)
void Print (const std::string &handler)
 Prints the tree handled by the handler.
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
void addDB (const std::string &i_nameDB, const std::string &i_locationDB)
 add an existent DB
TreeHandlerGetTreeHandler (const std::string &name) const
 Returns the TreeHandler with a given name.
SQLiteTreeHandlerGetLocalDatabase ()
const SQLiteTreeHandlerGetLocalDatabase () const
void GetSetting (const std::string &name, std::string &value)
 Returns the given setting value for the given setting parameter.
void UpdateSetting (const std::string &name, const std::string &value)
 Updates the settings file.
void addDBSettings ()
 add DB from Settings file
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.
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.
void GetAttributes (const std::string filename, std::map< std::string, std::string > &i_res, OutputAttr i_attr)
 get Values for given attributes
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.
const std::string getSummary ()
 Get Add Opertaion summary.

Static Public Member Functions

static void SetMessageLevel (int level)
 Sets level for messages "Gimmick!".
static void SetDebugMessageLevel (int level)
 Sets level for debug messages "Gimmick! DEBUG".

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 89 of file creaImageIOGimmick.h.


Member Typedef Documentation

Definition at line 98 of file creaImageIOGimmick.h.

Definition at line 99 of file creaImageIOGimmick.h.

typedef std::map<std::string, TreeHandler*>::const_iterator creaImageIO::Gimmick::ItTreeHandlerMap

Definition at line 131 of file creaImageIOGimmick.h.

typedef std::map<std::string, TreeHandler*> creaImageIO::Gimmick::TreeHandlerMapType

Type of map from TreeHandler name to TreeHandler*.

Definition at line 129 of file creaImageIOGimmick.h.


Constructor & Destructor Documentation

creaImageIO::Gimmick::Gimmick (  ) 

Ctor.

Definition at line 21 of file creaImageIOGimmick.cpp.

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

    : mImageAdder(0)
  {    
  RegisterGimmickMessageTypes();
        mSettings=0;
        mSynchronizer=0;
        mLocalDescpName = "localdatabase_Descriptor.dscp";
        mLocalDBName = "Local database";
  }

Here is the call graph for this function:

creaImageIO::Gimmick::~Gimmick (  ) 

Dtor.

Definition at line 34 of file creaImageIOGimmick.cpp.

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

  {

         if(mSettings!=0)
          {
                mSettings->writeSettingsFile();
                delete mSettings;
          }
        if(mSynchronizer!=0)
          {
                delete mSynchronizer;
          }
  }

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 91 of file creaImageIOGimmick.cpp.

References creaImageIO::Settings::addDB(), mSettings, and mTreeHandlerMap.

Referenced by addDBSettings().

        {
                if(mTreeHandlerMap.find(i_name) == mTreeHandlerMap.end())
                {
                        mTreeHandlerMap[i_name] = new SQLiteTreeHandler(i_location);
                        mTreeHandlerMap[i_name]->Open(true);
                        mSettings->addDB(i_location);
                }
        }

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 490 of file creaImageIOGimmick.cpp.

References addDB(), creaImageIO::Settings::getValue(), mSettings, and SETTINGS_DBPATH.

Referenced by Initialize().

  {

         std::string pathSettings = mSettings->getValue(SETTINGS_DBPATH);
         
         // split to find all paths
         std::vector<std::string> paths;
         std::string separator = ";";
         std::string::size_type last_pos = pathSettings.find_first_not_of(separator);
         //find first separator
         std::string::size_type pos = pathSettings.find_first_of(separator, last_pos);
         while(std::string::npos != pos || std::string::npos != last_pos)
         {
                paths.push_back(pathSettings.substr(last_pos, pos - last_pos));
                last_pos = pathSettings.find_first_not_of(separator, pos);
                pos = pathSettings.find_first_of(separator, last_pos);
         }

         std::vector<std::string>::iterator it_path = paths.begin();
         for(; it_path != paths.end(); ++it_path)
         {
                 pos = it_path->find_last_of("\\");
                 last_pos = it_path->find_last_of(".");
                 std::string name = it_path->substr(pos +1, last_pos -pos-1 );
                 addDB(name, it_path->c_str());
         }
  }     

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

  {
        GimmickMessage(2,"Adding dir '"<<f<<"' to '"<<d<<"' recurse:"
                         <<recurse<<std::endl);

        TreeHandler * handler=GetTreeHandler(d);
        mImageAdder.SetCurrentDatabase(d);
        mImageAdder.SetTreeHandler(handler);
        mImageAdder.SetSynchronizer(mSynchronizer);
        mImageAdder.AddDirectory(f,recurse);  
  }

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

  {
    GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
 
        mImageAdder.SetCurrentDatabase(d);
        mImageAdder.SetTreeHandler(GetTreeHandler(d));
        mImageAdder.SetSynchronizer(mSynchronizer);
        mImageAdder.AddFiles(filenames);        
  }

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 108 of file creaImageIOGimmick.h.

    { mImageAdder.ConnectProgressObserver(callback); }

void creaImageIO::Gimmick::CopyFiles ( const std::vector< std::string > &  filenames,
const std::string &  d 
)

Copies the files into the local directory.

Definition at line 378 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().

  {
          TreeHandler * handler=GetTreeHandler(d);
          mImageAdder.SetCurrentDatabase(d);
          mImageAdder.SetTreeHandler(handler);
          mImageAdder.SetSynchronizer(mSynchronizer);
          mImageAdder.CopyFiles(filenames, mSettings->getValue(SETTINGS_COPY_PATH));
  }

Here is the call graph for this function:

Here is the caller graph for this function:

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

  {
     SQLiteTreeHandler* sqlTreeH( new SQLiteTreeHandler(i_locDB) );
    // Create or open local database
    if (! boost::filesystem::exists(i_locDB) )
     {
         std::string mess = "Local database '";
         mess += i_locDB;
         mess += "' does not exist : creating it";
         GimmickMessage(1,mess<<std::endl);
         
                 // CREATING DB STRUCTURE
         sqlTreeH->GetTree().GetDescriptor().createDescriptorfromFile(i_locDesc);
         if ( ! sqlTreeH->Create(true) )
         {
                GimmickError("ERROR CREATING '"<<i_locDB<<"'");
         }
         sqlTreeH->SetAttribute(0,"Name",i_name);
         }
         else 
         {
                
                GimmickDebugMessage(1,"Opening local database '" <<i_locDB<< "' " << std::endl);
                if ( !sqlTreeH->Open(true) )
                {
                        GimmickError("ERROR OPENING '"<<i_locDB<<"'");
                }
        }
        return sqlTreeH;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::Gimmick::CreateUserSettingsDirectory (  ) 

Definition at line 218 of file creaImageIOGimmick.cpp.

References GetUserSettingsDirectory(), GimmickError, GimmickMessage, INVALID_FILE_SEPARATOR, mLocalDescpName, PATH_MAX, and VALID_FILE_SEPARATOR.

Referenced by Initialize().

  {
          
         // std::string st("C:/Documents and Settings/cervenansky/.gimmick/");
         //     boost::algorithm::replace_all( st, 
                //                     INVALID_FILE_SEPARATOR , 
                //                     VALID_FILE_SEPARATOR);
                //const boost::filesystem::path mpath(st);
//C:\Documents and Settings\cervenansky\.gimmick");
          //if ( !boost::filesystem::exists( path ) )             return ;
         //  boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
         //  for ( boost::filesystem::directory_iterator itr( path );  itr != end_itr;  ++itr )
         // {
                //      if ( boost::filesystem::is_directory(itr->status()) )
                //      return;
         //  }

          //JCP settings dir 02/10/2009
          const std::string settingsdirectory = GetUserSettingsDirectory();
                //boost::algorithm::replace_all( mUserSettingsDirectory, 
                                //       INVALID_FILE_SEPARATOR , 
                                //       VALID_FILE_SEPARATOR);
;//("E:\frederic");
                  //("C:\\Documents and Settings\\cervenansky\\.gimmick\\"); // settingsdirectory );
                bool isdir = false;
           isdir = boost::filesystem::is_directory(settingsdirectory); // settingsdirectory );
    if (! isdir )
      {
        GimmickMessage(1,"Directory '"<<GetUserSettingsDirectory()<<"' "
                       << "does not exist : creating it"<<std::endl);
        
        if ( ! boost::filesystem::create_directory( GetUserSettingsDirectory() ) )
          {
            GimmickError("ERROR CREATING '"<<GetUserSettingsDirectory()<<"'");
          }
      }

        std::string setDir=GetUserSettingsDirectory();
        boost::algorithm::replace_all( setDir,
                                       INVALID_FILE_SEPARATOR , 
                                       VALID_FILE_SEPARATOR);
        setDir+="share/";
        boost::filesystem::create_directory( setDir );
        setDir+="creaImageIO/";
        boost::filesystem::create_directory( setDir );
        setDir+=mLocalDescpName;

        if(!boost::filesystem::is_regular(setDir))
        {
                char name[PATH_MAX];
                crea::System::GetAppPath(name,PATH_MAX);
                std::cout<<name<<std::endl;
                
                std::string path=name;
                path=path.substr(0,path.size()-1);
                path=path.substr(0,path.find_last_of("/"));
                //Creating directories

// The following stuff works on Linux, NOT CHECKED on Windows // JPR
                
#if defined(_WIN32)             
                path+="/bin/share/creaImageIO/";
#endif

#if defined (LINUX)
                path+="/../share/creaImageIO/";
#endif  
#if defined(__APPLE__)
                path+="/../../../../share/creaImageIO/";
#endif 


path+= mLocalDescpName;
                
                std::cout <<"From: " << path   <<std::endl;
                std::cout <<"To: "   << setDir <<std::endl;
                boost::algorithm::replace_all(  path,
                                                INVALID_FILE_SEPARATOR , 
                                                VALID_FILE_SEPARATOR);
                boost::filesystem::copy_file(path,setDir);
        }
          
  }

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 462 of file creaImageIOGimmick.cpp.

References creaImageIO::TreeHandlerImageAdder::DeleteDriveFromMainDB(), creaImageIO::TreeHandlerImageAdder::DeleteDriveFromOtherDB(), mImageAdder, mSynchronizer, mTreeHandlerMap, creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().

  {
        for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin();
                                               it!= mTreeHandlerMap.end(); 
                                               ++it)
           {
                   mImageAdder.SetTreeHandler(it->second);
                   mImageAdder.DeleteDriveFromMainDB(drive);
           }
        mImageAdder.SetSynchronizer(mSynchronizer);
        mImageAdder.DeleteDriveFromOtherDB(drive);
  }

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 476 of file creaImageIOGimmick.cpp.

References creaImageIO::TreeHandlerImageAdder::EditField(), GetTreeHandler(), mImageAdder, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().

  {
        TreeHandler * handler=GetTreeHandler(d);
        mImageAdder.SetCurrentDatabase(d);
        mImageAdder.SetTreeHandler(handler);
        mImageAdder.EditField(node,name,key,val);
  }

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 523 of file creaImageIOGimmick.cpp.

References creaImageIO::OutputAttr::db, GetTreeHandler(), creaImageIO::OutputAttr::inside, creaImageIO::TreeHandlerImageAdder::isAttributeExist(), mImageAdder, creaImageIO::OutputAttr::outside, and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().

{
        //test if a tag is present in Database descriptor
        TreeHandler * handler=GetTreeHandler(infos.db);
        mImageAdder.SetTreeHandler(handler);
        std::vector<std::string>::const_iterator it = i_attr.begin();
        for (;it != i_attr.end(); it++)
        {
                if( mImageAdder.isAttributeExist((*it)) != "" ) // in DB
                {
                        infos.inside.push_back((*it));
                }
                else
                {
                                infos.outside.push_back((*it)); // Need to scan again the files
                }
        }
}

Here is the call graph for this function:

void creaImageIO::Gimmick::Finalize (  ) 

Finalize (closes databases, etc.).

Definition at line 144 of file creaImageIOGimmick.cpp.

References mTreeHandlerMap.

Referenced by main().

  {
          if(mTreeHandlerMap.size() >0)
          {
                // delete SQLiteTreeHandler Object
                for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin();
                                                                                                        it!= mTreeHandlerMap.end(); 
                                                        ++it)
                {
                        delete it->second;
                }
          }
  }

Here is the caller graph for this function:

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

Definition at line 112 of file creaImageIOGimmick.h.

Referenced by getSummary().

{ 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 414 of file creaImageIOGimmick.cpp.

References creaImageIO::TreeHandlerImageAdder::GetAttributes(), GetTreeHandler(), mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), and creaImageIO::TreeHandlerImageAdder::SetTreeHandler().

  {
          TreeHandler * handler=GetTreeHandler(d);
          mImageAdder.SetCurrentDatabase(d);
          mImageAdder.SetTreeHandler(handler);
          mImageAdder.SetSynchronizer(mSynchronizer);
          mImageAdder.GetAttributes(params, filename, results);
  }

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 430 of file creaImageIOGimmick.cpp.

References creaImageIO::OutputAttr::db, creaImageIO::TreeHandler::getAllAttributes(), GetTreeHandler(), and creaImageIO::OutputAttr::inside.

  {
           if (i_attr.inside.size() > 0)
           {
                   std::map<std::string, std::string> map_attr;
                   TreeHandler * handler=GetTreeHandler(i_attr.db);
                   handler->getAllAttributes(filename, map_attr);
                   if(i_attr.inside.front() == "ALL") // we  take all values
                   {
                           std::map<std::string, std::string>::iterator it = map_attr.begin();
                           for(; it != map_attr.end(); it++)
                                   i_res[it->first] = it->second;
                   }
                   else
                   {
                            std::vector<std::string>::iterator it = i_attr.inside.begin();
                            for(; it != i_attr.inside.end(); it++)
                                   i_res[(*it)] = map_attr[(*it)];
                   }
           }
  }

Here is the call graph for this function:

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

Definition at line 171 of file creaImageIOGimmick.cpp.

References mHomeDirectory.

Referenced by GetUserSettingsDirectory(), and Initialize().

  {
    if (mHomeDirectory.size()==0) 
      {
#if defined(__GNUC__)
        mHomeDirectory = getenv("HOME");
#elif defined(_WIN32)
        mHomeDirectory = getenv("USERPROFILE");
#endif
      }
    return mHomeDirectory;
  }

Here is the caller graph for this function:

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

Definition at line 179 of file creaImageIOGimmick.h.

{ return mLocalDatabase; }

const SQLiteTreeHandler* creaImageIO::Gimmick::GetLocalDatabase (  )  const [inline]

Definition at line 181 of file creaImageIOGimmick.h.

{ return mLocalDatabase; }

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

Definition at line 200 of file creaImageIOGimmick.cpp.

References GetUserSettingsDirectory(), INVALID_FILE_SEPARATOR, mLocalDatabasePath, mLocalDBName, and VALID_FILE_SEPARATOR.

Referenced by Initialize().

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 406 of file creaImageIOGimmick.cpp.

References creaImageIO::Settings::getValue(), and mSettings.

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

Here is the call graph for this function:

const std::string creaImageIO::Gimmick::getSummary (  ) 

Get Add Opertaion summary.

Definition at line 542 of file creaImageIOGimmick.cpp.

References GetAddProgress(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberAddedFiles(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberHandledFiles(), creaImageIO::TreeHandlerImageAdder::Progress::GetNumberScannedDirs(), and creaImageIO::TreeHandlerImageAdder::Progress::GetNumberScannedFiles().

{
      const AddProgress& p = GetAddProgress();
    std::stringstream mess;
    mess << "Dirs \tscanned\t: " << p.GetNumberScannedDirs()  << "\n";
    mess << "Files\tscanned\t: " << p.GetNumberScannedFiles() << "\n";
    mess << "Files\thandled\t: " << p.GetNumberHandledFiles() << "\n\n";
    mess << "Files\tadded  \t: " << p.GetNumberAddedFiles()   << "\n\n";
    return mess.str();
}

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 323 of file creaImageIOGimmick.cpp.

References GetTreeHandlerMap(), and GimmickError.

Referenced by AddDir(), AddFiles(), CopyFiles(), EditField(), fillVectInfos(), GetAttributes(), main(), Print(), and Synchronize().

  {  
    TreeHandlerMapType::const_iterator i;
    i = GetTreeHandlerMap().find(name);
    if ( i == GetTreeHandlerMap().end() )
      {
        GimmickError("TreeHandler '"<<name<<"' does not exist");
      }
    return i->second;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns the TreeHandlerMap (const ref).

Definition at line 137 of file creaImageIOGimmick.h.

    { return mTreeHandlerMap; }    

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

Returns the TreeHandlerMap (ref).

Definition at line 134 of file creaImageIOGimmick.h.

Referenced by GetTreeHandler().

{ return mTreeHandlerMap; }

Here is the caller graph for this function:

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

Definition at line 184 of file creaImageIOGimmick.cpp.

References GetHomeDirectory(), INVALID_FILE_SEPARATOR, mUserSettingsDirectory, and VALID_FILE_SEPARATOR.

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

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 50 of file creaImageIOGimmick.cpp.

References Initialize(), mLocalDBName, and mLocalDescpName.

  {
          mLocalDescpName = i_namedescp;
          mLocalDBName = i_namedb;
          Initialize();
  }

Here is the call graph for this function:

void creaImageIO::Gimmick::Initialize (  ) 

Initializes with default values (read/creates databases, etc.).

Definition at line 58 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().

  {
        std::string i_nameDB = mLocalDBName;
    // Create the UserSettings dir if does not exist
    CreateUserSettingsDirectory();
    // Sets the current directory to the home dir
    mCurrentDirectory =  GetHomeDirectory();
    mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"share/creaImageIO/");

    mSettings  = new Settings(mCurrentDirectory);
        
    std::string dbpath = GetLocalDatabasePath();

    // Create or open local database
    std::string dpath= mCurrentDirectory + "/.creaImageIO/share/creaImageIO/" + mLocalDescpName;
        
    boost::algorithm::replace_all( dpath,
                                   INVALID_FILE_SEPARATOR , 
                                   VALID_FILE_SEPARATOR);
    mLocalDatabase = createDB(i_nameDB, dpath, dbpath);
    // Add it to the TreeHandlerMap
    mTreeHandlerMap[i_nameDB] = mLocalDatabase;
    
    //Add additional DB from user Settings
    addDBSettings();    
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::Gimmick::Print ( const std::string &  handler  ) 

Prints the tree handled by the handler.

Definition at line 400 of file creaImageIOGimmick.cpp.

References creaImageIO::TreeHandler::GetTree(), GetTreeHandler(), and creaImageIO::tree::Tree::Print().

Referenced by main().

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

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 
)

Removes a file from the given TreeHandler.

Definition at line 366 of file creaImageIOGimmick.cpp.

References mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::RemoveFile(), creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), and creaImageIO::TreeHandlerImageAdder::SetSynchronizer().

  {
          mImageAdder.SetCurrentDatabase(d);
          mImageAdder.SetSynchronizer(mSynchronizer);
          mImageAdder.RemoveFile(node);
  }

Here is the call graph for this function:

void creaImageIO::Gimmick::SetDebugMessageLevel ( int  level  )  [static]

Sets level for debug messages "Gimmick! DEBUG".

Sets message level.

Definition at line 315 of file creaImageIOGimmick.cpp.

References creaImageIO::SetGimmickDebugMessageLevel().

Referenced by main().

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 307 of file creaImageIOGimmick.cpp.

References creaImageIO::SetGimmickMessageLevel().

Referenced by main().

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 389 of file creaImageIOGimmick.cpp.

References GetTreeHandler(), mImageAdder, mSynchronizer, creaImageIO::TreeHandlerImageAdder::SetCurrentDatabase(), creaImageIO::TreeHandlerImageAdder::SetSynchronizer(), creaImageIO::TreeHandlerImageAdder::SetTreeHandler(), and creaImageIO::TreeHandlerImageAdder::Synchronize().

Referenced by main().

  {
          TreeHandler * handler=GetTreeHandler(d);
          mImageAdder.SetCurrentDatabase(d);
          mImageAdder.SetTreeHandler(handler);
          mImageAdder.SetSynchronizer(mSynchronizer);
          return mImageAdder.Synchronize(repair, checkAttributes);
  }

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 455 of file creaImageIOGimmick.cpp.

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

  {
          mSettings->updateSetting(name,value);
          mSettings->writeSettingsFile();
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 220 of file creaImageIOGimmick.h.

Referenced by Initialize().

std::string creaImageIO::Gimmick::mHomeDirectory [private]

Definition at line 221 of file creaImageIOGimmick.h.

Referenced by GetHomeDirectory().

Definition at line 216 of file creaImageIOGimmick.h.

Referenced by Initialize().

Definition at line 223 of file creaImageIOGimmick.h.

Referenced by GetLocalDatabasePath().

std::string creaImageIO::Gimmick::mLocalDBName [private]

Definition at line 226 of file creaImageIOGimmick.h.

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

Definition at line 227 of file creaImageIOGimmick.h.

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

Definition at line 217 of file creaImageIOGimmick.h.

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

Definition at line 222 of file creaImageIOGimmick.h.

Referenced by GetUserSettingsDirectory().


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