ArchiveFile.hpp 2.65 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
22
23
 */

#pragma once

#include <list>
#include <map>
#include <string>

24
#include "common/dataStructures/DiskFileInfo.hpp"
25
#include "common/dataStructures/TapeFile.hpp"
26
#include "common/checksum/ChecksumBlob.hpp"
27
28

namespace cta {
29
namespace common {
30
31
namespace dataStructures {

32
/**
33
 * This struct holds all the CTA file metadata 
34
 */
35
struct ArchiveFile {
36

Daniele Kruse's avatar
Daniele Kruse committed
37
  ArchiveFile();
38
  
39
40
41
42
43
44
45
46
  /**
   * Equality operator that does NOT compare the creationTime and
   * reconciliationTime member-variables.
   *
   * @param rhs The operand on the right-hand side of the operator.
   * @return True if the compared objects are equal (ignoring the creationTime
   * and reconciliationTime member-variables).
   */
47
  bool operator==(const ArchiveFile &rhs) const;
48

49
  bool operator!=(const ArchiveFile &rhs) const;
50

51
  uint64_t archiveFileID;
52
  std::string diskFileId;
53
  std::string diskInstance;
54
  uint64_t fileSize;
55
  checksum::ChecksumBlob checksumBlob;
56
  std::string storageClass;
57
  DiskFileInfo diskFileInfo;
58
  /**
59
   * This list represents the non-necessarily-exhaustive set of tape copies 
Daniele Kruse's avatar
Daniele Kruse committed
60
61
   * to be listed by the operator. For example, if the listing requested is 
   * for a single tape, the map will contain only one element. 
62
   */
63
64
65
  class TapeFilesList: public std::list<TapeFile> {
  public:
    using std::list<TapeFile>::list;
66
67
68
69
    TapeFile & at(uint8_t copyNb);
    const TapeFile & at(uint8_t copyNb) const;
    TapeFilesList::iterator find(uint8_t copyNb);
    TapeFilesList::const_iterator find(uint8_t copyNb) const;
Michael Davis's avatar
Michael Davis committed
70
    void removeAllVidsExcept(const std::string &vid);
71
72
  };
  TapeFilesList tapeFiles;
73
  time_t creationTime;
74
  time_t reconciliationTime;
75

76
}; // struct ArchiveFile
77

78
79
std::ostream &operator<<(std::ostream &os, const ArchiveFile &obj);

80
} // namespace dataStructures
81
} // namespace common
82
} // namespace cta