creaImageIOGimmick.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOGimmick_h_INCLUDED__
00002 #define __creaImageIOGimmick_h_INCLUDED__
00003 
00004 #include <creaImageIOSQLiteTreeHandler.h>
00005 #include <creaImageIOTreeHandlerImageAdder.h>
00006 #include <creaImageIOSynchron.h>
00007 #include <creaImageIOSettings.h>
00008 
00009 
00010 
00011 
00012 #ifdef _DEBUG
00013 #include <crtdbg.h>
00014 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
00015 #else
00016 #define DEBUG_NEW new
00017 #endif
00018 // Only when asked
00019 /*
00020 #ifdef TRACKING_MEMORY_LEAKS
00021 #ifdef WIN32
00022 #pragma warning(disable : 4291)
00023 #endif
00024 
00025 void * operator new( size_t size, int line, const char *file );
00026 void * operator new[]( size_t size, int line, const char *file );
00027 void operator delete( void *p );
00028 void operator delete[]( void *p );
00029 
00030 #ifdef OMISCID_NEW
00031 #undef OMISCID_NEW
00032 #endif
00033 
00034 #define OMISCID_NEW new( __LINE__, __FILE__ )
00035 
00036 #else // TRACKING_MEMORY_LEAKS is not defined
00037 
00038 #define OMISCID_NEW new
00039 
00040 #endif*/
00041 
00042 
00043 namespace creaImageIO
00044 {
00071   //=======================================================================
00073 
00074 
00075 
00077         typedef struct
00078         {
00079                 // name of database to get attributes
00080                 std::string db;
00081                 // attributes available in this databse
00082                 std::vector<std::string> inside;
00083                 // attributes not available in this databse
00084                 std::vector<std::string> outside;
00085                 //
00086                 bool mult;
00087         }OutputAttr;
00088 
00089   class CREAIMAGEIO_EXPORT Gimmick
00090   {
00091   public:
00093     Gimmick();
00095     ~Gimmick();
00096     
00098     typedef TreeHandlerImageAdder::Progress AddProgress;
00099     typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
00100     
00108      void ConnectAddProgressObserver( AddProgressCallbackType callback )
00109     { mImageAdder.ConnectProgressObserver(callback); }
00110     
00112     const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
00113 
00115     void Initialize();
00116 
00118         void Initialize(const std::string namedescp, const std::string namedb = "Local Database");
00119     
00121     void Finalize();
00122 
00124     static void SetMessageLevel(int level);
00126     static void SetDebugMessageLevel(int level);
00127     
00129         typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
00130 
00131         typedef std::map<std::string, TreeHandler*>::const_iterator ItTreeHandlerMap;
00132 
00134     TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
00135         
00137     const TreeHandlerMapType& GetTreeHandlerMap() const
00138     { return mTreeHandlerMap; }    
00139 
00141     void AddFiles(const std::string& handler,
00142                   const std::vector<std::string>& filenames);
00143 
00145     void AddDir(const std::string& handler, const std::string& path, 
00146                 bool recurse);
00147 
00149         void RemoveFile(const std::string& d, 
00150                         tree::Node* filename);
00151 
00153         void DeleteDrive(const std::string& drive);
00154   
00155 
00157         void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
00158   
00159 
00162         std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
00163 
00165     void Print(const std::string& handler);
00166         
00168         SQLiteTreeHandler* createDB(const std::string &i_name, 
00169                                 const std::string &i_locDesc, 
00170                                 const std::string &i_locDB);
00171 
00173         void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
00174 
00176     TreeHandler* GetTreeHandler(const std::string& name) const;
00177 
00179         SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
00180 
00181     const SQLiteTreeHandler* GetLocalDatabase() const     { return mLocalDatabase; }
00182 
00184         void GetSetting(const std::string& name, std::string& value);
00185 
00187         void UpdateSetting(const std::string& name, const std::string& value);
00188 
00190     void addDBSettings();
00191 
00193         void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
00194 
00196         void GetAttributes(const std::string& d, 
00197           const std::string& filename, 
00198           const std::vector<std::string>& params, 
00199           std::vector<std::string>& results);
00200   
00202         void GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr);
00203     
00204     const std::string& GetHomeDirectory();
00205     const std::string& GetUserSettingsDirectory();
00206     void CreateUserSettingsDirectory();
00207     const std::string& GetLocalDatabasePath();
00208         
00210         void fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos);
00211 
00213     const std::string getSummary();
00214     //=============================================
00215   private:
00216         SQLiteTreeHandler* mLocalDatabase;
00217         TreeHandlerMapType mTreeHandlerMap;
00218         Synchronizer* mSynchronizer;
00219 
00220     std::string mCurrentDirectory;
00221     std::string mHomeDirectory;
00222     std::string mUserSettingsDirectory;
00223     std::string mLocalDatabasePath;
00224         Settings        *mSettings;
00225     TreeHandlerImageAdder mImageAdder;
00226         std::string mLocalDBName;
00227         std::string mLocalDescpName;
00228   };
00229   // EO class Gimmick
00230   //=======================================================================
00231 
00232 
00233 } // EO namespace creaImageIO
00234 
00235 // EOF
00236 #endif  
00237 
00238