creaImageIO_lib
creaImageIOTimestampDatabaseHandler.h
Go to the documentation of this file.
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # pour la Santé)
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
9 #
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.
16 #
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
21 # liability.
22 #
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 # ------------------------------------------------------------------------
26 */
27 
28 
29 #ifndef __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
30 #define __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
31 #include <vector>
32 #include <map>
33 #include <creaImageIOTree.h>
34 class CppSQLite3DB;
35 
36 namespace creaImageIO
37 {
38  using namespace std;
39 //=======================================================================
42  {
43  public:
44  //====================================================================
46  TimestampDatabaseHandler(const std::string& filename);
48  virtual ~TimestampDatabaseHandler();
49  //====================================================================
50 
51  //====================================================================
53  const std::string& GetFileName() const { return mFileName; }
54  //====================================================================
55 
56  //====================================================================
57  // INITIALIZATION / FINALIZATION
58  //====================================================================
59 
60  //====================================================================
62  bool Open();
64  bool Close();
66  bool Create();
68  bool Destroy();
69  //====================================================================
70 
71  //====================================================================
72  // READ / WRITE
73  //====================================================================
74  //====================================================================
76  std::string IsIndexed(const std::string& path, const std::string& refdb);
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);
84  void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
86  void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
88  void SetAttribute(const std::string& attName,
89  const std::string& attValue,
90  const std::string& searchParam,
91  const std::string& searchValue);
93  void RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb);
95  void RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
97  void CleanPath(std::string& str) const;
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);
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);
106 
107  //====================================================================
108 
109 
110  protected:
111  //======================================================================
113  bool DBOpen();
114  //======================================================================
115  //======================================================================
116  // Creation
118  bool DBCreate();
119  //======================================================================
120  //======================================================================
121  // Removes a file from the database
122  void DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
123 
124  private:
128  std::string mFileName;
129 
130  };
131  // EO class
132  //=======================================================================
133 
134 
135 } // EO namespace creaImageIO
136 
137 // EOF
138 #endif
139