File: DatabaseReport.h

package info (click to toggle)
mediaconch 25.04-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,828 kB
  • sloc: ansic: 126,293; cpp: 39,636; javascript: 34,300; xml: 2,950; sh: 2,121; makefile: 200; python: 183
file content (116 lines) | stat: -rw-r--r-- 6,287 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license that can
 *  be found in the License.html file in the root of the source tree.
 */

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Database functions
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//---------------------------------------------------------------------------
#ifndef DatabaseReportH
#define DatabaseReportH
//---------------------------------------------------------------------------

#include <map>
#include <vector>
#include "MediaConchLib.h"
#include "Database.h"
//---------------------------------------------------------------------------

namespace MediaConch {

//***************************************************************************
// Class Database
//***************************************************************************

class DatabaseReport : public Database
{
public:
    //Constructor/Destructor
    DatabaseReport();
    virtual ~DatabaseReport();

    void        set_database_directory(const std::string& dirname);
    void        set_database_filename(const std::string& name);

    // Init
    virtual int create_report_table() = 0;
    virtual int update_report_table() = 0;

    //User
    virtual void get_users_id(std::vector<long>& id, std::string& err) = 0;

    // File
    virtual long add_file(int user, const std::string& filename, const std::string& file_last_modification,
                          const std::string& options, std::string& err,
                          const std::vector<long>& generated_id,
                          long source_id=-1, size_t generated_time=(size_t)-1,
                          const std::string& generated_log="", const std::string& generated_error_log="") = 0;
    virtual long update_file(int user, long file_id, const std::string& file_last_modification,
                             const std::string& options, std::string& err,
                             const std::vector<long>& generated_id, long source_id=-1, size_t generated_time=(size_t)-1,
                             const std::string& generated_log="", const std::string& generated_error_log="") = 0;
    virtual long get_file_id(int user, const std::string& file, const std::string& file_last_modification,
                             const std::string& options, std::string& err) = 0;
    virtual int  get_file_name_from_id(int user, long id, std::string& file, std::string& err) = 0;
    virtual int  get_file_information_from_id(int user, long id, std::string& filename, std::string& file_last_modification,
                                              std::vector<long>& generated_id, long& source_id, size_t& generated_time,
                                              std::string& generated_log, std::string& generated_error_log,
                                              std::string& options,
                                              bool& analyzed, bool& has_error, std::string& error_log, std::string& err) = 0;
    virtual bool file_is_analyzed(int user, long id, std::string& err) = 0;
    virtual int  remove_file(int user, long file_id, std::string& err) = 0;
    virtual int  reset_file(int user, long file_id, std::string& err) = 0;
    virtual int  remove_all_files(int user, std::string& err) = 0;
    virtual int  add_file_generated_id(int user, long source_id, long generated_id, std::string& err) = 0;
    virtual int  update_file_analyzed(int user, long id, std::string& err, bool analyzed=true) = 0;
    virtual int  update_file_error(int user, long id, std::string& err,
                                   bool has_error=true, const std::string& error_log="") = 0;

    // Report
    virtual int  save_report(int user, long file_id, MediaConchLib::report reportKind, MediaConchLib::format format,
                             const std::string& options,
                             const std::string& report, MediaConchLib::compression,
                             unsigned long long int mil_version, std::string& err) = 0;
    virtual int  remove_report(int user, long file_id, std::string& err) = 0;
    virtual int  remove_all_reports(int user, std::string& err) = 0;
    virtual int  get_report(int user, long file_id, MediaConchLib::report reportKind, MediaConchLib::format format,
                            const std::string& options,
                            std::string& report, MediaConchLib::compression&, std::string& err) = 0;
    virtual int  report_is_registered(int user, long file_id, MediaConchLib::report reportKind,
                                      MediaConchLib::format format, const std::string& options,
                                      bool& registered, std::string& err) = 0;
    virtual unsigned long long int  version_registered(int user, long file_id, std::string& err) = 0;
    virtual int  get_elements(int user, std::vector<std::string>& vec, std::string& err) = 0;
    virtual int  get_elements(int user, std::vector<long>& vec, std::string& err) = 0;
    virtual int  get_element_report_kind(int user, long file_id, MediaConchLib::report& report_kind, std::string& err) = 0;

    virtual int init_report() = 0;

protected:
    // Database dependant
    void        get_sql_query_for_create_report_table(std::string& q);
    void        get_sql_query_for_update_report_table_v0(std::string& q);
    void        get_sql_query_for_update_report_table_v1(std::string& q);
    void        get_sql_query_for_update_report_table_v2(std::string& q);
    void        get_sql_query_for_update_report_table_v3(std::string& q);
    void        get_sql_query_for_update_report_table_v4(std::string& q);
    void        get_sql_query_for_update_report_table_v5(std::string& q);
    void        get_sql_query_for_update_report_table_v6(std::string& q);

    // Helpers
    void        longs_to_string(const std::vector<long>&, std::string&);
    void        string_to_longs(const std::string&, std::vector<long>&);

private:
    DatabaseReport (const DatabaseReport&);
    DatabaseReport& operator=(const DatabaseReport&);
};

}

#endif