InMemoryCatalogue.hpp 2.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * The CERN Tape Archive(CTA) project
 * Copyright(C) 2015  CERN
 *
 * 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.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

21
#include "catalogue/RdbmsCatalogue.hpp"
22
23
24
25

namespace cta {
namespace catalogue {

26
27
class CatalogueFactory;

28
/**
29
 * CTA catalogue class to be used for unit testing.
30
 */
31
32
class InMemoryCatalogue: public RdbmsCatalogue {

33
  /**
34
35
36
37
38
39
40
41
42
43
   * The CatalogueFactory is a friend so that it can call the private
   * constructor of this class.
   */
  friend CatalogueFactory;

private:

  /**
   * Private constructor only to be called by the CatalogueFactory class (a
   * friend).
44
   *
Steven Murray's avatar
Steven Murray committed
45
   * @param conn The connection to the underlying relational database.  Please
46
   * note that the InMemoryCatalogue will own and therefore delete the
Steven Murray's avatar
Steven Murray committed
47
   * specified database connection.
48
   */
49
  InMemoryCatalogue();
50

51
52
public:

53
54
55
  /**
   * Destructor.
   */
56
  virtual ~InMemoryCatalogue();
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
protected:

  /**
   * This is an InMemoryCatalogue specific method that creates the catalogue
   * database schema.
   */
  void createCatalogueSchema();

  /**
   * This is an InMemoryCatalogue specific method that executes the specified
   * non-query multi-line SQL statement.
   *
   * Please note that each statement must end with a semicolon.  If the last
   * statement is missing a semicolon then it will not be executed.
   *
   * @param multiStmt Non-query multi-line SQL statement.
   */
  void executeNonQueryMultiStmt(const std::string &multiStmt);

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  /**
   * Returns a unique archive ID that can be used by a new archive file within
   * the catalogue.
   *
   * This method must be implemented by the sub-classes of RdbmsCatalogue
   * because different database technologies propose different solution to the
   * problem of generating ever increasing numeric identifiers.
   */
  virtual uint64_t getNextArchiveFileId();

private:

  /**
   * Creates the ARCHIVE_FILE_ID table that will be used to generate ever
   * incrementing identifiers for archive files.
   */
  void createArchiveFileIdTable();

95
}; // class InMemoryCatalogue
96
97
98

} // namespace catalogue
} // namespace cta