Xmipp  v3.23.11-Nereus
xmipp_program_sql.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: J.M. de la Rosa Trevin (jmdelarosa@cnb.csic.es)
3  *
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef CORE_PROGRAM_SQL_H_
27 #define CORE_PROGRAM_SQL_H_
28 
29 #include "sqlite3.h"
30 #include "argsprinter.h"
31 #include "xmipp_filename.h"
32 #include "metadata_label.h"
33 #include "metadata_static.h"
34 
35 typedef std::map<const char*, String> DictDB;
36 
37 class CommentList;
38 
40 
45 class ProgramDb: public Printer
46 {
47 private:
48  sqlite3 * db;
49  int rc;
50  char * errmsg, *zLeftover;
51 
52 
53 public:
55  void init(const FileName &dbName);
57  ProgramDb();
59  ProgramDb(const FileName &dbName);
61  virtual ~ProgramDb() {}
63  bool execStmt(const String &stmt, const String &error="");
64  bool beginTrans();
65  bool commitTrans();
67  bool createProgramTables();
69  bool insertProgram(DictDB &program);
71  String getLabelComment(const MDLabel &label);
72 
73  //Methods inherits from Program Printer
74  virtual void printProgram(const ProgramDef &program, int v = 0);
75  virtual void printSection(const SectionDef &section, int v = 0);
76  virtual void printParam(const ParamDef &param, int v = 0);
77  virtual void printArgument(const ArgumentDef & argument, int v = 0);
78  virtual void printCommentList(const CommentList &comments, int v = 0);
79 
80 }
81 ;//end of class ProgramDB
82 //
84 //class SqlitePrinter: public Printer
85 //{
86 //protected:
87 // ProgramDb *db;
88 //
89 //public:
90 // /**Constructor */
91 // SqlitePrinter(ProgramDb *db);
92 //};
93 #endif /* PROGRAM_SQL_H_ */
virtual void printCommentList(const CommentList &comments, int v=0)
bool createProgramTables()
void init(const FileName &dbName)
bool execStmt(const String &stmt, const String &error="")
virtual void printParam(const ParamDef &param, int v=0)
virtual void printArgument(const ArgumentDef &argument, int v=0)
String & escapeSqliteStr(String &str)
virtual void printProgram(const ProgramDef &program, int v=0)
virtual void printSection(const SectionDef &section, int v=0)
virtual ~ProgramDb()
struct _parameter * param
std::map< const char *, String > DictDB
std::string String
Definition: xmipp_strings.h:34
String getLabelComment(const MDLabel &label)
bool insertProgram(DictDB &program)
MDLabel