]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOGimmick.h
move directory
[creaImageIO.git] / src2 / creaImageIOGimmick.h
index c351332ba7725d09bec92c1ed79d2ef733b27474..017d153ce92e0f8f6f1705c6f65ea85843ac7501 100644 (file)
@@ -2,6 +2,42 @@
 #define __creaImageIOGimmick_h_INCLUDED__
 
 #include <creaImageIOSQLiteTreeHandler.h>
+#include <creaImageIOTreeHandlerImageAdder.h>
+#include <creaImageIOSynchron.h>
+#include <creaImageIOSettings.h>
+
+
+
+#ifdef _DEBUG
+#include <crtdbg.h>
+#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
+#else
+#define DEBUG_NEW new
+#endif
+// Only when asked
+/*
+#ifdef TRACKING_MEMORY_LEAKS
+#ifdef WIN32
+#pragma warning(disable : 4291)
+#endif
+
+void * operator new( size_t size, int line, const char *file );
+void * operator new[]( size_t size, int line, const char *file );
+void operator delete( void *p );
+void operator delete[]( void *p );
+
+#ifdef OMISCID_NEW
+#undef OMISCID_NEW
+#endif
+
+#define OMISCID_NEW new( __LINE__, __FILE__ )
+
+#else // TRACKING_MEMORY_LEAKS is not defined
+
+#define OMISCID_NEW new
+
+#endif*/
+
 
 namespace creaImageIO
 {
@@ -14,6 +50,18 @@ namespace creaImageIO
        /**
        * \defgroup Model Model
        */
+       /**
+       * \defgroup GUI Top level graphical user interfaces
+       */
+       /**
+       * \defgroup IO Image I/O classes
+       */
+       /**
+       * \defgroup Tree Attributed tree management
+       */
+       /**
+       * \defgroup Previewer Preview related
+       */
 
        /**
        * \ingroup Controller
@@ -21,7 +69,7 @@ namespace creaImageIO
 
   //=======================================================================
   /// Central controler of the gimmick application
-  class Gimmick
+  class CREAIMAGEIO_EXPORT Gimmick
   {
   public:
     /// Ctor
@@ -29,29 +77,132 @@ namespace creaImageIO
     /// Dtor
     ~Gimmick();
     
-    /// Initialize (read/creates databases, etc.)
-    bool Initialize();
+    ///
+    typedef TreeHandlerImageAdder::Progress AddProgress;
+    typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
+    
+    /// 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 ) );
+     void ConnectAddProgressObserver( AddProgressCallbackType callback )
+    { mImageAdder.ConnectProgressObserver(callback); }
+    
+    ///
+    const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
+
+    /// Initializes with default values (read/creates databases, etc.)
+    void Initialize();
+
+       /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
+       void Initialize(const std::string namedescp, const std::string namedb = "Local Database");
     
     /// Finalize (closes databases, etc.)
-    bool Finalize();
+    void Finalize();
+
+    /// Sets level for messages "Gimmick!" 
+    static void SetMessageLevel(int level);
+    /// Sets level for debug messages "Gimmick! DEBUG" 
+    static void SetDebugMessageLevel(int level);
+    
+    /// Type of map from TreeHandler name to TreeHandler*
+       typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
+
+       typedef std::map<std::string, TreeHandler*>::const_iterator ItTreeHandlerMap;
+
+    /// Returns the TreeHandlerMap (ref)
+    TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
+       
+    /// Returns the TreeHandlerMap (const ref)
+    const TreeHandlerMapType& GetTreeHandlerMap() const
+    { return mTreeHandlerMap; }    
+
+    /// Add the files to the given TreeHandler
+    void AddFiles(const std::string& handler,
+                 const std::vector<std::string>& filenames);
+
+    /// Add a dir to the given TreeHandler
+    void AddDir(const std::string& handler, const std::string& path, 
+               bool recurse);
+
+       /// Removes a file from the given TreeHandler
+       void RemoveFile(const std::string& d, 
+                       tree::Node* filename);
+
+       ///Deletes the given drive name from the databases
+       void DeleteDrive(const std::string& drive);
+  
+
+       /// Copies the files into the local directory
+       void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
+  
+
+       ///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
+       std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
 
+    /// Prints the tree handled by the handler
+    void Print(const std::string& handler);
+       
+    ///create a DB from a given descriptor file and for a specific location
+       SQLiteTreeHandler* createDB(const std::string &i_name, 
+                               const std::string &i_locDesc, 
+                               const std::string &i_locDB);
 
-    /// Sets debug mode
-    void SetDebugMode(bool );
+       /// add an existent DB 
+       void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
 
+    /// Returns the TreeHandler with a given name
+    TreeHandler* GetTreeHandler(const std::string& name) const;
+
+       /// 
+       SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
+
+    const SQLiteTreeHandler* GetLocalDatabase() const     { return mLocalDatabase; }
+
+       ///Returns the given setting value for the given setting parameter
+       void GetSetting(const std::string& name, std::string& value);
+
+       ///Updates the settings file
+       void UpdateSetting(const std::string& name, const std::string& value);
+
+       /// add DB from Settings file
+    void addDBSettings();
+
+       ///Edits the field described by the name and key provided with the value given
+       void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
+
+       /// Returns the attributes in results described in params
+       void GetAttributes(const std::string& d, 
+         const std::string& filename, 
+         const std::vector<std::string>& params, 
+         std::vector<std::string>& results);
+  
+    /// 
     const std::string& GetHomeDirectory();
     const std::string& GetUserSettingsDirectory();
-    bool CreateUserSettingsDirectory();
+    void CreateUserSettingsDirectory();
     const std::string& GetLocalDatabasePath();
+       
+
 
+    //=============================================
   private:
-    SQLiteTreeHandler* mLocalDatabase;
+       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;
   };
   // EO class Gimmick
   //=======================================================================