CatalogueSchema.hpp 2.79 KB
Newer Older
1
/*
2
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2015-2021 CERN
4
5
6
7
 * @license        This program is free software: you can redistribute it and/or modify
 *                 it under the terms of the GNU General Public License as published by
 *                 the Free Software Foundation, either version 3 of the License, or
 *                 (at your option) any later version.
8
 *
9
10
11
12
 *                 This program is distributed in the hope that it will be useful,
 *                 but WITHOUT ANY WARRANTY; without even the implied warranty of
 *                 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *                 GNU General Public License for more details.
13
 *
14
15
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18
19
20
21
 */

#pragma once

#include <string>
#include <list>
22
#include <map>
23
24
25
26
27
28
29
30
31
32

namespace cta {
namespace catalogue {

/**
 * Structure containing the common schema procedures of the CTA catalogue
 * database.
 */
struct CatalogueSchema {
  /**
33
34
35
36
   * Constructor.
   *
   * @param sqlSchema The sql for the catalogue schema provided at compilation
   *                  time.
37
38
   */
  CatalogueSchema(const std::string &sqlSchema);
39
  
40
41
42
43
  /**
   * The schema.
   */
  const std::string sql;
44
  
45
  /**
46
47
48
   * Returns the names of all the tables in the catalogue schema.
   *
   * @return The names of all the tables in the catalogue schema.
49
50
   */
  std::list<std::string> getSchemaTableNames() const;
51
  
52
53
54
55
  /**
   * Returns the names of all the column and their type as a map for the given 
   * table in the catalogue schema.
   *
56
   * @param tableName The table name to get the columns.
57
58
   * @return The map of types by name of all the columns for the given table in the catalogue schema.
   */
59
  std::map<std::string, std::string> getSchemaColumns(const std::string &tableName) const;
60
  
61
  /**
62
63
64
   * Returns the names of all the indexes in the catalogue schema.
   *
   * @return The names of all the indexes in the catalogue schema.
65
66
   */
  std::list<std::string> getSchemaIndexNames() const;
67
  
68
  /**
69
   * Returns the names of all the sequences in the catalogue schema.
70
   * 
71
72
73
74
   * if the underlying database technologies does not supported sequences then
   * this method simply returns an empty list.
   *
   * @return The names of all the sequences in the catalogue schema.
75
76
   */
  std::list<std::string> getSchemaSequenceNames() const;
77
  
78
  /**
79
80
81
82
   * Returns the map of strings to uint64 for the catalogue SCHEMA_VERSION_MAJOR
   * and SCHEMA_VERSION_MINOR values.
   * 
   * @return The map for SCHEMA_VERSION_MAJOR and SCHEMA_VERSION_MINOR  values.
83
84
   */
  std::map<std::string, uint64_t> getSchemaVersion() const;
85
86
87
88
};

} // namespace catalogue
} // namespace cta