2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #ifndef __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
30 #define __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
33 #include <creaImageIOTree.h>
39 //=======================================================================
40 /// Concrete TreeHandler which manages a Tree stored in a sqlite database
41 class TimestampDatabaseHandler
44 //====================================================================
45 /// Ctor with database file name
46 TimestampDatabaseHandler(const std::string& filename);
48 virtual ~TimestampDatabaseHandler();
49 //====================================================================
51 //====================================================================
52 /// Returns the sqlite db file name
53 const std::string& GetFileName() const { return mFileName; }
54 //====================================================================
56 //====================================================================
57 // INITIALIZATION / FINALIZATION
58 //====================================================================
60 //====================================================================
61 /// Opens an existing 'source'
63 /// Closes the 'source'
65 /// Creates a new 'source'
67 /// Destroys the 'source'
69 //====================================================================
71 //====================================================================
73 //====================================================================
74 //====================================================================
75 ///Returns the id of the path if it's indexed, blank otherwise
76 std::string IsIndexed(const std::string& path, const std::string& refdb);
77 ///Sets the current path's parent
78 bool AddDirectory(const std::string& parent,
79 const std::string& path,
80 const time_t lastModif,
81 const time_t lastRead,
82 const std::string& refdb);
83 ///Adds a new file to the database without a parent
84 void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
85 ///Adds a new file to the database with a parent
86 void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
87 ///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
88 void SetAttribute(const std::string& attName,
89 const std::string& attValue,
90 const std::string& searchParam,
91 const std::string& searchValue);
92 ///Removes the given node
93 void RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb);
94 ///Removes the filename with the given pathname
95 void RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
96 ///Cleans the path name
97 void CleanPath(std::string& str) const;
98 ///Checks the timestamp in the database and compares it with the given one.
99 //If there is a difference, it will return false, otherwise it will return true.
100 bool CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb);
101 ///Removes the entries that match the given parameters
102 void RemoveEntries(const std::string i_table,
103 const std::string i_attribute,
104 const std::string i_operand,
105 const std::string i_val);
107 //====================================================================
111 //======================================================================
112 /// Open the database
114 //======================================================================
115 //======================================================================
117 /// Creates a new database on disk and the tables
119 //======================================================================
120 //======================================================================
121 // Removes a file from the database
122 void DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
127 /// The physical location associated to the DicomDatabase (directory, db file...)
128 std::string mFileName;
132 //=======================================================================
135 } // EO namespace creaImageIO