1 #ifndef __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
2 #define __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
5 #include <creaImageIOTree.h>
11 //=======================================================================
12 /// Concrete TreeHandler which manages a Tree stored in a sqlite database
13 class TimestampDatabaseHandler
16 //====================================================================
17 /// Ctor with database file name
18 TimestampDatabaseHandler(const std::string& filename);
20 virtual ~TimestampDatabaseHandler();
21 //====================================================================
23 //====================================================================
24 /// Returns the sqlite db file name
25 const std::string& GetFileName() const { return mFileName; }
26 //====================================================================
28 //====================================================================
29 // INITIALIZATION / FINALIZATION
30 //====================================================================
32 //====================================================================
33 /// Opens an existing 'source'
35 /// Closes the 'source'
37 /// Creates a new 'source'
39 /// Destroys the 'source'
41 //====================================================================
43 //====================================================================
45 //====================================================================
46 //====================================================================
47 ///Returns the id of the path if it's indexed, blank otherwise
48 std::string IsIndexed(const std::string& path, const std::string& refdb);
49 ///Sets the current path's parent
50 bool AddDirectory(const std::string& parent,
51 const std::string& path,
52 const time_t lastModif,
53 const time_t lastRead,
54 const std::string& refdb);
55 ///Adds a new file to the database without a parent
56 void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
57 ///Adds a new file to the database with a parent
58 void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
59 ///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
60 void SetAttribute(const std::string& attName,
61 const std::string& attValue,
62 const std::string& searchParam,
63 const std::string& searchValue);
64 ///Removes the given node
65 void RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb);
66 ///Removes the filename with the given pathname
67 void RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
68 ///Cleans the path name
69 void CleanPath(std::string& str) const;
70 ///Checks the timestamp in the database and compares it with the given one.
71 //If there is a difference, it will return false, otherwise it will return true.
72 bool CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb);
73 ///Removes the entries that match the given parameters
74 void RemoveEntries(const std::string i_table,
75 const std::string i_attribute,
76 const std::string i_operand,
77 const std::string i_val);
79 //====================================================================
83 //======================================================================
86 //======================================================================
87 //======================================================================
89 /// Creates a new database on disk and the tables
91 //======================================================================
92 //======================================================================
93 // Removes a file from the database
94 void DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
99 /// The physical location associated to the DicomDatabase (directory, db file...)
100 std::string mFileName;
104 //=======================================================================
107 } // EO namespace creaImageIO