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);
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 ///Adds a new file to the database without a parent
55 void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead);
56 ///Adds a new file to the database with a parent
57 void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead);
58 ///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
59 void SetAttribute(const std::string& attName,
60 const std::string& attValue,
61 const std::string& searchParam,
62 const std::string& searchValue);
63 ///Removes the given node
64 void RemoveNode(const std::string& searchAtt, tree::Node* node);
65 ///Removes the filename with the given pathname
66 void RemoveFile(const std::string& searchAtt, const std::string& searchVal);
67 ///Cleans the path name
68 void CleanName(std::string& str) const;
69 ///Checks the timestamp in the database and compares it with the given one.
70 //If there is a difference, it will return false, otherwise it will return true.
71 bool CheckTimestamp(const std::string pathId, const time_t lastModif);
73 //====================================================================
77 //======================================================================
80 //======================================================================
81 //======================================================================
83 /// Creates a new database on disk and the tables
85 //======================================================================
86 //======================================================================
87 // Removes a file from the database
88 void DBRemove(const std::string& searchAtt, const std::string& searchVal);
93 /// The physical location associated to the DicomDatabase (directory, db file...)
94 std::string mFileName;
98 //=======================================================================
101 } // EO namespace creaImageIO