+++ /dev/null
-#ifndef __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
-#define __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
-#include <vector>
-#include <map>
-#include <creaImageIOTree.h>
-class CppSQLite3DB;
-
-namespace creaImageIO
-{
- using namespace std;
-//=======================================================================
- /// Concrete TreeHandler which manages a Tree stored in a sqlite database
- class TimestampDatabaseHandler
- {
- public:
- //====================================================================
- /// Ctor with database file name
- TimestampDatabaseHandler(const std::string& filename);
- /// Dtor
- virtual ~TimestampDatabaseHandler();
- //====================================================================
-
- //====================================================================
- /// Returns the sqlite db file name
- const std::string& GetFileName() const { return mFileName; }
- //====================================================================
-
- //====================================================================
- // INITIALIZATION / FINALIZATION
- //====================================================================
-
- //====================================================================
- /// Opens an existing 'source'
- bool Open();
- /// Closes the 'source'
- bool Close();
- /// Creates a new 'source'
- bool Create();
- /// Destroys the 'source'
- bool Destroy();
- //====================================================================
-
- //====================================================================
- // READ / WRITE
- //====================================================================
- //====================================================================
- ///Returns the id of the path if it's indexed, blank otherwise
- std::string IsIndexed(const std::string& path, const std::string& refdb);
- ///Sets the current path's parent
- bool AddDirectory(const std::string& parent,
- const std::string& path,
- const time_t lastModif,
- const time_t lastRead,
- const std::string& refdb);
- ///Adds a new file to the database without a parent
- void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
- ///Adds a new file to the database with a parent
- void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
- ///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
- void SetAttribute(const std::string& attName,
- const std::string& attValue,
- const std::string& searchParam,
- const std::string& searchValue);
- ///Removes the given node
- void RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb);
- ///Removes the filename with the given pathname
- void RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
- ///Cleans the path name
- void CleanPath(std::string& str) const;
- ///Checks the timestamp in the database and compares it with the given one.
- //If there is a difference, it will return false, otherwise it will return true.
- bool CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb);
- ///Removes the entries that match the given parameters
- void RemoveEntries(const std::string i_table,
- const std::string i_attribute,
- const std::string i_operand,
- const std::string i_val);
-
- //====================================================================
-
-
- protected:
- //======================================================================
- /// Open the database
- bool DBOpen();
- //======================================================================
- //======================================================================
- // Creation
- /// Creates a new database on disk and the tables
- bool DBCreate();
- //======================================================================
- //======================================================================
- // Removes a file from the database
- void DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
-
- private:
- /// The DB
- CppSQLite3DB* mDB;
- /// The physical location associated to the DicomDatabase (directory, db file...)
- std::string mFileName;
-
- };
- // EO class
- //=======================================================================
-
-
-} // EO namespace creaImageIO
-
-// EOF
-#endif
-